From fd997edeeb4ac277823750d746394d80f03d7ec1 Mon Sep 17 00:00:00 2001 From: Trevor Pounds Date: Thu, 3 Oct 2019 12:34:19 -0400 Subject: [PATCH] Cleanup nolint directives. (#779) --- .golangci.yml | 12 ++++-------- README.md | 12 ++++-------- internal/cache/cache.go | 3 +-- pkg/config/config.go | 2 +- pkg/config/config_gocritic.go | 2 -- pkg/golinters/goanalysis/runner.go | 1 - pkg/lint/lintersdb/enabled_set.go | 1 - pkg/lint/load.go | 1 - pkg/packages/util.go | 1 - pkg/printers/codeclimate.go | 4 ++-- pkg/result/processors/fixer.go | 1 - 11 files changed, 12 insertions(+), 28 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 08f995bf..a46c27ed 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -85,21 +85,17 @@ linters: - whitespace # don't enable: - # - godox - # - maligned,prealloc # - gochecknoglobals + # - gocognit + # - godox + # - maligned + # - prealloc run: skip-dirs: - test/testdata_etc - internal/(cache|renameio|robustio) -issues: - exclude-rules: - - text: "weak cryptographic primitive" - linters: - - gosec - # golangci.com configuration # https://github.com/golangci/golangci/wiki/Configuration service: diff --git a/README.md b/README.md index 47fb0738..a86618e0 100644 --- a/README.md +++ b/README.md @@ -969,21 +969,17 @@ linters: - whitespace # don't enable: - # - godox - # - maligned,prealloc # - gochecknoglobals + # - gocognit + # - godox + # - maligned + # - prealloc run: skip-dirs: - test/testdata_etc - internal/(cache|renameio|robustio) -issues: - exclude-rules: - - text: "weak cryptographic primitive" - linters: - - gosec - # golangci.com configuration # https://github.com/golangci/golangci/wiki/Configuration service: diff --git a/internal/cache/cache.go b/internal/cache/cache.go index 2157c9f2..6f3f93be 100644 --- a/internal/cache/cache.go +++ b/internal/cache/cache.go @@ -159,8 +159,7 @@ func (c *Cache) get(id ActionID) (Entry, error) { eid, entry := entry[3:3+hexSize], entry[3+hexSize:] eout, entry := entry[1:1+hexSize], entry[1+hexSize:] esize, entry := entry[1:1+20], entry[1+20:] - //lint:ignore SA4006 See https://github.com/dominikh/go-tools/issues/465 - etime, entry := entry[1:1+20], entry[1+20:] //nolint:staticcheck + etime, entry := entry[1:1+20], entry[1+20:] var buf [HashSize]byte if _, err := hex.Decode(buf[:], eid); err != nil || buf != id { return missing() diff --git a/pkg/config/config.go b/pkg/config/config.go index 7f974908..eb0f6ef4 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -342,7 +342,7 @@ type Issues struct { NeedFix bool `mapstructure:"fix"` } -type Config struct { //nolint:maligned +type Config struct { Run Run Output struct { diff --git a/pkg/config/config_gocritic.go b/pkg/config/config_gocritic.go index faf2a8bf..0964d817 100644 --- a/pkg/config/config_gocritic.go +++ b/pkg/config/config_gocritic.go @@ -97,7 +97,6 @@ func (s *GocriticSettings) gocriticDisabledCheckersDebugf() { } } -//nolint:gocyclo func (s *GocriticSettings) InferEnabledChecks(log logutils.Log) { gocriticCheckerTagsDebugf() @@ -175,7 +174,6 @@ func validateStringsUniq(ss []string) error { return nil } -//nolint:gocyclo func (s *GocriticSettings) Validate(log logutils.Log) error { if len(s.EnabledTags) == 0 { if len(s.EnabledChecks) != 0 && len(s.DisabledChecks) != 0 { diff --git a/pkg/golinters/goanalysis/runner.go b/pkg/golinters/goanalysis/runner.go index 4f730a00..e194a811 100644 --- a/pkg/golinters/goanalysis/runner.go +++ b/pkg/golinters/goanalysis/runner.go @@ -95,7 +95,6 @@ func newRunner(prefix string, logger logutils.Log, pkgCache *pkgcache.Cache, loa // It provides most of the logic for the main functions of both the // singlechecker and the multi-analysis commands. // It returns the appropriate exit code. -//nolint:gocyclo func (r *runner) run(analyzers []*analysis.Analyzer, initialPackages []*packages.Package) ([]Diagnostic, []error) { debugf("Analyzing %d packages on load mode %s", len(initialPackages), r.loadMode) defer r.pkgCache.Trim() diff --git a/pkg/lint/lintersdb/enabled_set.go b/pkg/lint/lintersdb/enabled_set.go index 8339f6f7..73e3bcfe 100644 --- a/pkg/lint/lintersdb/enabled_set.go +++ b/pkg/lint/lintersdb/enabled_set.go @@ -27,7 +27,6 @@ func NewEnabledSet(m *Manager, v *Validator, log logutils.Log, cfg *config.Confi } } -// nolint:gocyclo func (es EnabledSet) build(lcfg *config.Linters, enabledByDefaultLinters []*linter.Config) map[string]*linter.Config { resultLintersSet := map[string]*linter.Config{} switch { diff --git a/pkg/lint/load.go b/pkg/lint/load.go index ff235cac..de0ab411 100644 --- a/pkg/lint/load.go +++ b/pkg/lint/load.go @@ -275,7 +275,6 @@ func (cl *ContextLoader) filterDuplicatePackages(pkgs []*packages.Package) []*pa return retPkgs } -//nolint:gocyclo func (cl *ContextLoader) Load(ctx context.Context, linters []*linter.Config) (*linter.Context, error) { loadMode := cl.findLoadMode(linters) pkgs, err := cl.loadPackages(ctx, loadMode) diff --git a/pkg/packages/util.go b/pkg/packages/util.go index 476978d4..3c8642af 100644 --- a/pkg/packages/util.go +++ b/pkg/packages/util.go @@ -6,7 +6,6 @@ import ( "golang.org/x/tools/go/packages" ) -//nolint:gocyclo func ExtractErrors(pkg *packages.Package) []packages.Error { errors := extractErrorsImpl(pkg, map[*packages.Package]bool{}) if len(errors) == 0 { diff --git a/pkg/printers/codeclimate.go b/pkg/printers/codeclimate.go index e36a5934..8e184464 100644 --- a/pkg/printers/codeclimate.go +++ b/pkg/printers/codeclimate.go @@ -2,7 +2,7 @@ package printers import ( "context" - "crypto/md5" + "crypto/md5" //nolint:gosec "encoding/json" "fmt" @@ -39,7 +39,7 @@ func (p CodeClimate) Print(ctx context.Context, issues []result.Issue) error { issue.Location.Lines.Begin = i.Pos.Line // Need a checksum of the issue, so we use MD5 of the filename, text, and first line of source - hash := md5.New() + hash := md5.New() //nolint:gosec _, _ = hash.Write([]byte(i.Pos.Filename + i.Text + i.SourceLines[0])) issue.Fingerprint = fmt.Sprintf("%X", hash.Sum(nil)) diff --git a/pkg/result/processors/fixer.go b/pkg/result/processors/fixer.go index dd2a686a..0ca027b8 100644 --- a/pkg/result/processors/fixer.go +++ b/pkg/result/processors/fixer.go @@ -115,7 +115,6 @@ func (f Fixer) fixIssuesInFile(filePath string, issues []result.Issue) error { return nil } -//nolint:gocyclo func (f Fixer) mergeLineIssues(lineNum int, lineIssues []result.Issue, origFileLines [][]byte) *result.Issue { origLine := origFileLines[lineNum-1] // lineNum is 1-based