Skip to content

Cleanup nolint directives #779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2019
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: 4 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions internal/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ type Issues struct {
NeedFix bool `mapstructure:"fix"`
}

type Config struct { //nolint:maligned
type Config struct {
Run Run

Output struct {
Expand Down
2 changes: 0 additions & 2 deletions pkg/config/config_gocritic.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ func (s *GocriticSettings) gocriticDisabledCheckersDebugf() {
}
}

//nolint:gocyclo
func (s *GocriticSettings) InferEnabledChecks(log logutils.Log) {
gocriticCheckerTagsDebugf()

Expand Down Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion pkg/golinters/goanalysis/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion pkg/lint/lintersdb/enabled_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion pkg/lint/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion pkg/packages/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/printers/codeclimate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package printers

import (
"context"
"crypto/md5"
"crypto/md5" //nolint:gosec
"encoding/json"
"fmt"

Expand Down Expand Up @@ -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))

Expand Down
1 change: 0 additions & 1 deletion pkg/result/processors/fixer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down