Skip to content

Commit

Permalink
linter: enable all the things
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan committed Mar 20, 2024
1 parent d5ae293 commit 1252ed4
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 53 deletions.
38 changes: 0 additions & 38 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,61 +56,23 @@ linters-settings:
- style
disabled-checks:
# diagnostic
- badRegexp
- badSorting
- badSyncOnceFunc
- builtinShadowDecl
- commentedOutCode
- dynamicFmtString
- emptyDecl
- evalOrder
- externalErrorReassign
- filepathJoin
- regexpPattern
- returnAfterHttpError
- sloppyReassign
- sortSlice
- sprintfQuotedString
- sqlQuery
- syncMapLoadAndDelete
- truncateCmp
- uncheckedInlineErr
- unnecessaryDefer

# style
- commentedOutImport
- deferUnlambda
- docStub
- dupImport
- emptyStringTest
- exitAfterDefer
- exposedSyncMutex
- httpNoBody
- ifElseChain
- importShadow
- initClause
- methodExprCall
- nestingReduce
- octalLiteral
- paramTypeCombine
- preferFilepathJoin
- ptrToRefParam
- redundantSprint
- regexpSimplify
- ruleguard
- stringConcatSimplify
- stringsCompare
- timeExprSimplify
- todoCommentWithoutDetail
- tooManyResultsChecker
- typeAssertChain
- typeDefFirst
- typeUnparen
- unlabelStmt
- unnamedResult
- unnecessaryBlock
- whyNoLint
- yodaStyleExpr
revive:
ignore-generated-header: true
rules:
Expand Down
2 changes: 1 addition & 1 deletion api/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@ func (opts HostsForScanningOptions) Apply(values url.Values) {
values.Set("limit", fmt.Sprint(opts.Limit))
}
if !opts.MaxLastScan.IsZero() {
values.Set("lastScan", fmt.Sprint(TimeRFC3339(opts.MaxLastScan)))
values.Set("lastScan", TimeRFC3339(opts.MaxLastScan).String())
}
}
2 changes: 1 addition & 1 deletion api/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func (opts SearchObjectOptions) Apply(values url.Values) {
}

func FormatETag(eTag string) string {
return fmt.Sprintf("\"%s\"", eTag)
return fmt.Sprintf("%q", eTag)
}

func ObjectPathEscape(path string) string {
Expand Down
2 changes: 1 addition & 1 deletion api/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (t *TimeRFC3339) UnmarshalText(b []byte) error {

// MarshalJSON implements json.Marshaler.
func (t TimeRFC3339) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`"%s"`, (time.Time)(t).UTC().Format(time.RFC3339Nano))), nil
return []byte(fmt.Sprintf("%q", (time.Time)(t).UTC().Format(time.RFC3339Nano))), nil
}

// String implements fmt.Stringer.
Expand Down
4 changes: 2 additions & 2 deletions api/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ func (rs RedundancySettings) Validate() error {
// valid.
func (s3as S3AuthenticationSettings) Validate() error {
for accessKeyID, secretAccessKey := range s3as.V4Keypairs {
if len(accessKeyID) == 0 {
if accessKeyID == "" {
return fmt.Errorf("AccessKeyID cannot be empty")
} else if len(accessKeyID) < S3MinAccessKeyLen || len(accessKeyID) > S3MaxAccessKeyLen {
return fmt.Errorf("AccessKeyID must be between %d and %d characters long but was %d", S3MinAccessKeyLen, S3MaxAccessKeyLen, len(accessKeyID))
} else if len(secretAccessKey) == 0 {
} else if secretAccessKey == "" {
return fmt.Errorf("SecretAccessKey cannot be empty")
} else if len(secretAccessKey) != S3SecretKeyLen {
return fmt.Errorf("SecretAccessKey must be %d characters long but was %d", S3SecretKeyLen, len(secretAccessKey))
Expand Down
4 changes: 2 additions & 2 deletions bus/client/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (c *Client) PruneMetrics(ctx context.Context, metric string, cutoff time.Ti
panic(err)
}
u.RawQuery = values.Encode()
req, err := http.NewRequestWithContext(ctx, "DELETE", u.String(), nil)
req, err := http.NewRequestWithContext(ctx, "DELETE", u.String(), http.NoBody)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -180,7 +180,7 @@ func (c *Client) metric(ctx context.Context, key string, values url.Values, res
panic(err)
}
u.RawQuery = values.Encode()
req, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil)
req, err := http.NewRequestWithContext(ctx, "GET", u.String(), http.NoBody)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion bus/client/slabs.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (c *Client) FetchPartialSlab(ctx context.Context, key object.EncryptionKey,
panic(err)
}
u.RawQuery = values.Encode()
req, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil)
req, err := http.NewRequestWithContext(ctx, "GET", u.String(), http.NoBody)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion bus/client/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (c *Client) WalletTransactions(ctx context.Context, opts ...api.WalletTrans
panic(err)
}
u.RawQuery = values.Encode()
req, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil)
req, err := http.NewRequestWithContext(ctx, "GET", u.String(), http.NoBody)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/renterd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func cmdBuildConfig() {

// write the config file
configPath := "renterd.yml"
if str := os.Getenv("RENTERD_CONFIG_FILE"); len(str) != 0 {
if str := os.Getenv("RENTERD_CONFIG_FILE"); str != "" {
configPath = str
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/renterd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func check(context string, err error) {
}

func mustLoadAPIPassword() {
if len(cfg.HTTP.Password) != 0 {
if cfg.HTTP.Password != "" {
return
}

Expand Down Expand Up @@ -192,7 +192,7 @@ func mustParseWorkers(workers, password string) {
// loaded.
func tryLoadConfig() {
configPath := "renterd.yml"
if str := os.Getenv("RENTERD_CONFIG_FILE"); len(str) != 0 {
if str := os.Getenv("RENTERD_CONFIG_FILE"); str != "" {
configPath = str
}

Expand Down
2 changes: 1 addition & 1 deletion hostdb/hostdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func ForEachAnnouncement(b types.Block, height uint64, fn func(types.PublicKey,
// verify signature
var hostKey types.PublicKey
copy(hostKey[:], ha.PublicKey.Key)
annHash := types.Hash256(crypto.HashObject(ha.HostAnnouncement)) // TODO
annHash := types.Hash256(crypto.HashObject(ha.HostAnnouncement))
if !hostKey.VerifyHash(annHash, ha.Signature) {
continue
}
Expand Down
4 changes: 2 additions & 2 deletions worker/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (c *Client) HeadObject(ctx context.Context, bucket, path string, opts api.H
path += "?" + values.Encode()

// TODO: support HEAD in jape client
req, err := http.NewRequestWithContext(ctx, "HEAD", fmt.Sprintf("%s/objects/%s", c.c.BaseURL, path), nil)
req, err := http.NewRequestWithContext(ctx, "HEAD", fmt.Sprintf("%s/objects/%s", c.c.BaseURL, path), http.NoBody)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -271,7 +271,7 @@ func (c *Client) object(ctx context.Context, bucket, path string, opts api.Downl
path += "?" + values.Encode()

c.c.Custom("GET", fmt.Sprintf("/objects/%s", path), nil, (*[]api.ObjectMetadata)(nil))
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("%s/objects/%s", c.c.BaseURL, path), nil)
req, err := http.NewRequestWithContext(ctx, "GET", fmt.Sprintf("%s/objects/%s", c.c.BaseURL, path), http.NoBody)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 1252ed4

Please sign in to comment.