diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index 75d995bd96e6..527d0651c590 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -26,6 +26,7 @@ jobs: # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] # TODO: Enable for javascript later language: [ 'go' ] + golang: [ '1.16' ] # Learn more... # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection @@ -42,6 +43,11 @@ jobs: - run: git checkout HEAD^2 if: ${{ github.event_name == 'pull_request' }} + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.golang }} + # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v1 @@ -56,4 +62,4 @@ jobs: - run: make build test - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 \ No newline at end of file + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d08a6ef61c4b..0d9f9ff935aa 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -66,7 +66,6 @@ jobs: strategy: matrix: golang: - - 1.15 - 1.16 - 1.17 steps: diff --git a/.golangci.yml b/.golangci.yml index bc6efa238693..18386725cc95 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -50,8 +50,6 @@ linters-settings: - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf lll: line-length: 140 - maligned: - suggest-new: true misspell: locale: US nolintlint: @@ -117,6 +115,9 @@ linters: # - wsl issues: + exclude: + # disable this rule for go1.15 compatibility + - 'ioutilDeprecated:' # Excluding configuration per-path, per-linter, per-text and per-source exclude-rules: - path: _test\.go @@ -141,7 +142,6 @@ issues: linters: - gomnd - run: skip-dirs: - test/testdata_etc diff --git a/go.mod b/go.mod index 0242ee045d13..b7fc760f3cbb 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/golangci/golangci-lint -go 1.15 +go 1.16 require ( 4d63.com/gochecknoglobals v0.0.0-20201008074935-acfc0b28355a @@ -21,7 +21,7 @@ require ( github.com/esimonov/ifshort v1.0.2 github.com/fatih/color v1.13.0 github.com/fzipp/gocyclo v0.3.1 - github.com/go-critic/go-critic v0.5.6 + github.com/go-critic/go-critic v0.6.1 github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b github.com/gofrs/flock v0.8.1 github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 diff --git a/go.sum b/go.sum index 288191078fcb..d7ca8c47eb76 100644 --- a/go.sum +++ b/go.sum @@ -177,8 +177,8 @@ github.com/fullstorydev/grpcurl v1.6.0/go.mod h1:ZQ+ayqbKMJNhzLmbpCiurTVlaK2M/3n github.com/fzipp/gocyclo v0.3.1 h1:A9UeX3HJSXTBzvHzhqoYVuE0eAhe+aM8XBCCwsPMZOc= github.com/fzipp/gocyclo v0.3.1/go.mod h1:DJHO6AUmbdqj2ET4Z9iArSuwWgYDRryYt2wASxc7x3E= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-critic/go-critic v0.5.6 h1:siUR1+322iVikWXoV75I1YRfNaC/yaLzhdF9Zwd8Tus= -github.com/go-critic/go-critic v0.5.6/go.mod h1:cVjj0DfqewQVIlIAGexPCaGaZDAqGE29PYDDADIVNEo= +github.com/go-critic/go-critic v0.6.1 h1:lS8B9LH/VVsvQQP7Ao5TJyQqteVKVs3E4dXiHMyubtI= +github.com/go-critic/go-critic v0.6.1/go.mod h1:SdNCfU0yF3UBjtaZGw6586/WocupMOJuiqgom5DsQxM= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -197,8 +197,9 @@ github.com/go-toolsmith/astcast v1.0.0 h1:JojxlmI6STnFVG9yOImLeGREv8W2ocNUM+iOhR github.com/go-toolsmith/astcast v1.0.0/go.mod h1:mt2OdQTeAQcY4DQgPSArJjHCcOwlX+Wl/kwN+LbLGQ4= github.com/go-toolsmith/astcopy v1.0.0 h1:OMgl1b1MEpjFQ1m5ztEO06rz5CUd3oBv9RF7+DyvdG8= github.com/go-toolsmith/astcopy v1.0.0/go.mod h1:vrgyG+5Bxrnz4MZWPF+pI4R8h3qKRjjyvV/DSez4WVQ= -github.com/go-toolsmith/astequal v1.0.0 h1:4zxD8j3JRFNyLN46lodQuqz3xdKSrur7U/sr0SDS/gQ= github.com/go-toolsmith/astequal v1.0.0/go.mod h1:H+xSiq0+LtiDC11+h1G32h7Of5O3CYFJ99GVbS5lDKY= +github.com/go-toolsmith/astequal v1.0.1 h1:JbSszi42Jiqu36Gnf363HWS9MTEAz67vTQLponh3Moc= +github.com/go-toolsmith/astequal v1.0.1/go.mod h1:4oGA3EZXTVItV/ipGiOx7NWkY5veFfcsOJVS2YxltLw= github.com/go-toolsmith/astfmt v1.0.0 h1:A0vDDXt+vsvLEdbMFJAUBI/uTbRw1ffOPnxsILnFL6k= github.com/go-toolsmith/astfmt v1.0.0/go.mod h1:cnWmsOAuq4jJY6Ct5YWlVLmcmLMn1JUPuQIHCY7CJDw= github.com/go-toolsmith/astinfo v0.0.0-20180906194353-9809ff7efb21/go.mod h1:dDStQCHtmZpYOmjRP/8gHHnCCch3Zz3oEgCdZVdtweU= @@ -615,12 +616,12 @@ github.com/pseudomuto/protoc-gen-doc v1.3.2/go.mod h1:y5+P6n3iGrbKG+9O04V5ld71in github.com/pseudomuto/protokit v0.2.0/go.mod h1:2PdH30hxVHsup8KpBTOXTBeMVhJZVio3Q8ViKSAXT0Q= github.com/quasilyte/go-consistent v0.0.0-20190521200055-c6f3937de18c/go.mod h1:5STLWrekHfjyYwxBRVRXNOSewLJ3PWfDJd1VyTS21fI= github.com/quasilyte/go-ruleguard v0.3.1-0.20210203134552-1b5a410e1cc8/go.mod h1:KsAh3x0e7Fkpgs+Q9pNLS5XpFSvYCEVl5gP9Pp1xp30= -github.com/quasilyte/go-ruleguard v0.3.4 h1:F6l5p6+7WBcTKS7foNQ4wqA39zjn2+RbdbyzGxIq1B0= -github.com/quasilyte/go-ruleguard v0.3.4/go.mod h1:57FZgMnoo6jqxkYKmVj5Fc8vOt0rVzoE/UNAmFFIPqA= +github.com/quasilyte/go-ruleguard v0.3.13 h1:O1G41cq1jUr3cJmqp7vOUT0SokqjzmS9aESWJuIDRaY= +github.com/quasilyte/go-ruleguard v0.3.13/go.mod h1:Ul8wwdqR6kBVOCt2dipDBkE+T6vAV/iixkrKuRTN1oQ= github.com/quasilyte/go-ruleguard/dsl v0.3.0/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= -github.com/quasilyte/go-ruleguard/dsl v0.3.2/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= +github.com/quasilyte/go-ruleguard/dsl v0.3.10/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= github.com/quasilyte/go-ruleguard/rules v0.0.0-20201231183845-9e62ed36efe1/go.mod h1:7JTjp89EGyU1d6XfBiXihJNG37wB2VRkd125Q1u7Plc= -github.com/quasilyte/go-ruleguard/rules v0.0.0-20210203162857-b223e0831f88/go.mod h1:4cgAphtvu7Ftv7vOT2ZOYhC6CvBxZixcasr8qIOTA50= +github.com/quasilyte/go-ruleguard/rules v0.0.0-20210428214800-545e0d2e0bf7/go.mod h1:4cgAphtvu7Ftv7vOT2ZOYhC6CvBxZixcasr8qIOTA50= github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 h1:L8QM9bvf68pVdQ3bCFZMDmnt9yqcMBro1pC7F+IPYMY= github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95/go.mod h1:rlzQ04UMyJXu/aOvhd8qT+hvDrFpiwqp8MRXDY9szc0= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= diff --git a/netlify.toml b/netlify.toml index 2ab7a5f46210..aecacc67a42e 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,8 +1,8 @@ [context.production.environment] - GO_VERSION = "1.15" + GO_VERSION = "1.16" [context.deploy-preview.environment] - GO_VERSION = "1.15" + GO_VERSION = "1.16" [context.branch-deploy.environment] - GO_VERSION = "1.15" \ No newline at end of file + GO_VERSION = "1.16" diff --git a/pkg/golinters/goanalysis/runner_loadingpackage.go b/pkg/golinters/goanalysis/runner_loadingpackage.go index 9fa396854ee0..f9a43f3f5cf1 100644 --- a/pkg/golinters/goanalysis/runner_loadingpackage.go +++ b/pkg/golinters/goanalysis/runner_loadingpackage.go @@ -492,6 +492,6 @@ func sizeOfReflectValueTreeBytes(rv reflect.Value, visitedPtrs map[uintptr]struc case reflect.Invalid: return 0 default: - panic("unknown rv of type " + fmt.Sprint(rv)) + panic("unknown rv of type " + rv.String()) } } diff --git a/pkg/golinters/gocritic.go b/pkg/golinters/gocritic.go index e98f23445ae9..ffb44058c375 100644 --- a/pkg/golinters/gocritic.go +++ b/pkg/golinters/gocritic.go @@ -34,7 +34,7 @@ func NewGocritic() *goanalysis.Linter { } return goanalysis.NewLinter( gocriticName, - `Provides many diagnostics that check for bugs, performance and style issues. + `Provides diagnostics that check for bugs, performance and style issues. Extensible without recompilation through dynamic rules. Dynamic rules are written declaratively with AST patterns, filters, report message and optional suggestion.`, []*analysis.Analyzer{analyzer}, diff --git a/pkg/result/issue.go b/pkg/result/issue.go index 707a2b17cd95..1e8cd30524b0 100644 --- a/pkg/result/issue.go +++ b/pkg/result/issue.go @@ -92,7 +92,7 @@ func (i *Issue) Fingerprint() string { } hash := md5.New() //nolint:gosec - _, _ = hash.Write([]byte(fmt.Sprintf("%s%s%s", i.Pos.Filename, i.Text, firstLine))) + _, _ = fmt.Fprintf(hash, "%s%s%s", i.Pos.Filename, i.Text, firstLine) return fmt.Sprintf("%X", hash.Sum(nil)) } diff --git a/pkg/timeutils/stopwatch.go b/pkg/timeutils/stopwatch.go index 9628bd80f2b6..ecb7ded31a99 100644 --- a/pkg/timeutils/stopwatch.go +++ b/pkg/timeutils/stopwatch.go @@ -15,10 +15,10 @@ const noStagesText = "no stages" type Stopwatch struct { name string startedAt time.Time - stages map[string]time.Duration log logutils.Log - sync.Mutex + stages map[string]time.Duration + mu sync.Mutex } func NewStopwatch(name string, log logutils.Log) *Stopwatch { @@ -110,7 +110,7 @@ func (s *Stopwatch) TrackStage(name string, f func()) { startedAt := time.Now() f() - s.Lock() + s.mu.Lock() s.stages[name] += time.Since(startedAt) - s.Unlock() + s.mu.Unlock() } diff --git a/scripts/expand_website_templates/main.go b/scripts/expand_website_templates/main.go index 2a54e890e97c..a6dfe435f7bd 100644 --- a/scripts/expand_website_templates/main.go +++ b/scripts/expand_website_templates/main.go @@ -136,7 +136,7 @@ func getLatestVersion() (string, error) { req, err := http.NewRequest( // nolint:noctx http.MethodGet, "https://api.github.com/repos/golangci/golangci-lint/releases/latest", - nil, + http.NoBody, ) if err != nil { return "", fmt.Errorf("failed to prepare a http request: %s", err) @@ -286,7 +286,7 @@ func check(b bool, title string) string { } func span(title, icon string) string { - return fmt.Sprintf(`%s`, title, icon) + return fmt.Sprintf(`%s`, title, icon) } func getThanksList() string { diff --git a/scripts/gen_github_action_config/go.mod b/scripts/gen_github_action_config/go.mod index 76f8176db5d0..a4d3bba1e454 100644 --- a/scripts/gen_github_action_config/go.mod +++ b/scripts/gen_github_action_config/go.mod @@ -1,6 +1,6 @@ module github.com/golangci/golangci-lint/scripts/gen_github_action_config -go 1.15 +go 1.16 require ( github.com/shurcooL/githubv4 v0.0.0-20200627185320-e003124d66e4