Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/codetests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: test-and-lint
on:
pull_request:
branches:
- main
- main
permissions:
contents: read
jobs:
Expand Down Expand Up @@ -31,7 +31,7 @@ jobs:
with:
go-version: stable
- name: go-test
run: go test -race -v -covermode=atomic ./...
run: go test -race -v -covermode=atomic ./...
# Runs golangci-lint on macos against freebsd and macos.
golangci-darwin:
strategy:
Expand All @@ -47,9 +47,9 @@ jobs:
go-version: stable
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v8
with:
version: v1.64
version: v2.3
# Runs golangci-lint on linux against linux and windows.
golangci-linux:
strategy:
Expand All @@ -65,6 +65,6 @@ jobs:
go-version: stable
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v8
with:
version: v1.64
version: v2.3
108 changes: 63 additions & 45 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,68 @@
issues:
max-issues-per-linter: 0
max-same-issues: 0
exclude-rules:
- path: 'starrcmd/'
linters:
- nonamedreturns
- path: '(.+)_test\.go'
linters:
- gochecknoglobals
- forcetypeassert
- funlen
- lll
- maintidx # uhg.

version: '2'
linters:
enable-all: true
default: all
disable:
# deprecated
- tenv
# unused
- tagliatelle
- exhaustruct
- dupl
- nlreturn
- exhaustruct
- musttag

linters-settings:
ireturn:
allow: [generic,stdlib,error]
# One day we'll fix all the field alignments. Anyone got a tool that just does it?
# govet:
# enable:
# - fieldalignment
depguard:
- nlreturn
- tagliatelle
- noinlineerr
- wsl
settings:
wsl_v5:
allow-first-in-block: true
allow-whole-block: false
branch-max-lines: 2
depguard:
rules:
main:
files:
- $all
allow:
- $gostd
- github.com/stretchr/testify
- golift.io/starr
- golang.org/x/net
ireturn:
allow:
- generic
- stdlib
- error
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
main:
files:
- $all
allow:
- $gostd
- github.com/stretchr/testify
- golift.io/starr
- golang.org/x/net

run:
timeout: 5m

output:
sort-results: true
- linters:
- nonamedreturns
path: starrcmd/
- linters:
- forcetypeassert
- funlen
- gochecknoglobals
- lll
- maintidx
path: (.+)_test\.go
paths:
- third_party$
- builtin$
- examples$
issues:
max-issues-per-linter: 0
max-same-issues: 0
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
9 changes: 5 additions & 4 deletions debuglog/roundtripper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import (

// Config is the input data for the logger.
type Config struct {
// Limit logged JSON payloads to this many bytes. 0=unlimited
MaxBody int
// This is where logs go. If not set they go to log.Printf.
Debugf func(string, ...interface{})
// This can be used for byte counters, but is optional otherwise.
Caller Caller
// Any strings in this list are replaced with <recated> in the log output.
// Useful for hiding api keys and passwords from debug logs. String must be 4+ chars.
Redact []string
// Limit logged JSON payloads to this many bytes. 0=unlimited
MaxBody int
}

const minRedactChars = 4
Expand All @@ -40,15 +40,16 @@ type LoggingRoundTripper struct {

type fakeCloser struct {
io.Reader
*Config

CloseFn func() error
Body *bytes.Buffer
Sent *bytes.Buffer
Header http.Header
Method string
URL string
Status string
Header http.Header
Elapsed time.Duration
*Config
}

// NewLoggingRoundTripper returns a round tripper to log requests counts and response sizes.
Expand Down
13 changes: 7 additions & 6 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ const API = "api"

// Request contains the GET and/or POST values for an HTTP request.
type Request struct {
URI string // Required: path portion of the URL.
Query url.Values // GET parameters work for any request type.
Body io.Reader // Used in PUT, POST, DELETE. Not for GET.
Query url.Values // GET parameters work for any request type.
URI string // Required: path portion of the URL.
}

// ReqError is returned when a Starr app returns an invalid status code.
type ReqError struct {
Code int
Body []byte
http.Header

Err error // sub error, often nil, or not useful.
Msg string
Name string
Err error // sub error, often nil, or not useful.
http.Header
Body []byte
Code int
}

// String turns a request into a string. Usually used in error messages.
Expand Down
2 changes: 1 addition & 1 deletion lidarr/lidarr.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const APIver = "v1"

// Lidarr contains all the methods to interact with a Lidarr server.
type Lidarr struct {
starr.APIer
starr.APIer `json:"-"`
}

// Filter values are integers. Given names for ease of discovery.
Expand Down
17 changes: 9 additions & 8 deletions paginate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ import (
// PageReq is the input to search requests that have page-able responses.
// These are turned into HTTP parameters.
type PageReq struct {
PageSize int // 10 is default if not provided.
Page int // 1 is default if not provided.
SortKey string // date, timeleft, others?
SortDir Sorting // ascending, descending
Filter Filtering // enums for eventTypes. App specific.
url.Values // Additional values that may be set.
url.Values // Additional values that may be set.

PageSize int // 10 is default if not provided.
Page int // 1 is default if not provided.
SortKey string // date, timeleft, others?
SortDir Sorting // ascending, descending
Filter Filtering // enums for eventTypes. App specific.
}

// Sorting is used as a request parameter value to sort lists, like History and Queue.
Expand Down Expand Up @@ -122,8 +123,8 @@ func (r *PageReq) CheckSet(key, value string) { //nolint:cyclop
r.Values = make(url.Values)
}

if r.Values.Get(key) == "" {
r.Values.Set(key, value)
if r.Get(key) == "" {
r.Set(key, value)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion prowlarr/prowlarr.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

// Prowlarr contains all the methods to interact with a Prowlarr server.
type Prowlarr struct {
starr.APIer
starr.APIer `json:"-"`
}

// APIver is the Prowlarr API version supported by this library.
Expand Down
2 changes: 1 addition & 1 deletion radarr/radarr.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const APIver = "v3"

// Radarr contains all the methods to interact with a Radarr server.
type Radarr struct {
starr.APIer
starr.APIer `json:"-"`
}

// Filter values are integers. Given names for ease of discovery.
Expand Down
2 changes: 1 addition & 1 deletion readarr/readarr.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const APIver = "v1"

// Readarr contains all the methods to interact with a Readarr server.
type Readarr struct {
starr.APIer
starr.APIer `json:"-"`
}

// Filter values are integers. Given names for ease of discovery.
Expand Down
3 changes: 2 additions & 1 deletion shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,9 @@ type FormatItem struct {
// PlayTime is used in at least Sonarr, maybe other places.
// Holds a string duration converted from hh:mm:ss.
type PlayTime struct {
Original string
time.Duration

Original string
}

var _ json.Unmarshaler = (*PlayTime)(nil)
Expand Down
2 changes: 1 addition & 1 deletion sonarr/sonarr.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const APIver = "v3"

// Sonarr contains all the methods to interact with a Sonarr server.
type Sonarr struct {
starr.APIer
starr.APIer `json:"-"`
}

// Filter values are integers. Given names for ease of discovery.
Expand Down
2 changes: 1 addition & 1 deletion starr.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ var (
// HTTPUser and HTTPPass are used for Basic HTTP auth, if enabled (not common).
// Username and Password are for non-API paths with native authentication enabled.
type Config struct {
Client *http.Client `json:"-" toml:"-" xml:"-" yaml:"-"`
APIKey string `json:"apiKey" toml:"api_key" xml:"api_key" yaml:"apiKey"`
URL string `json:"url" toml:"url" xml:"url" yaml:"url"`
HTTPPass string `json:"httpPass" toml:"http_pass" xml:"http_pass" yaml:"httpPass"`
HTTPUser string `json:"httpUser" toml:"http_user" xml:"http_user" yaml:"httpUser"`
Username string `json:"username" toml:"username" xml:"username" yaml:"username"`
Password string `json:"password" toml:"password" xml:"password" yaml:"password"`
Client *http.Client `json:"-" toml:"-" xml:"-" yaml:"-"`
cookie bool // this probably doesn't work right.
}

Expand Down
Loading
Loading