Skip to content

dev: handle old TODO #4374

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
Feb 10, 2024
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
17 changes: 5 additions & 12 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
linters-settings:
depguard:
# new configuration
rules:
logger:
deny:
# logging is allowed only by logutils.Log,
# logrus is allowed to use only in logutils package.
- pkg: "github.com/sirupsen/logrus"
desc: logging is allowed only by logutils.Log
desc: logging is allowed only by logutils.Log.
- pkg: "github.com/pkg/errors"
desc: Should be replaced by standard lib errors package.
- pkg: "github.com/instana/testify"
desc: It's a fork of github.com/stretchr/testify.
dupl:
threshold: 100
funlen:
Expand Down Expand Up @@ -50,7 +53,6 @@ linters-settings:
- '3'
ignored-functions:
- strings.SplitN

govet:
settings:
printf:
Expand Down Expand Up @@ -118,14 +120,11 @@ linters:

# don't enable:
# - asciicheck
# - scopelint
# - gochecknoglobals
# - gocognit
# - godot
# - godox
# - goerr113
# - interfacer
# - maligned
# - nestif
# - prealloc
# - testpackage
Expand Down Expand Up @@ -156,12 +155,6 @@ issues:
- path: test/(fix|linters)_test.go
text: "string `gocritic.go` has 3 occurrences, make it a constant"

# Due to a change inside go-critic v0.10.0, some reports have been removed,
# but as we run analysis with the previous version of golangci-lint this leads to a paradoxical situation.
# This exclusion will be removed when the next version of golangci-lint (v1.56.0) will be released.
- path: pkg/golinters/nolintlint/nolintlint.go
text: "hugeParam: (i|b) is heavy \\(\\d+ bytes\\); consider passing it by pointer"

run:
timeout: 5m
skip-dirs:
Expand Down
8 changes: 8 additions & 0 deletions pkg/golinters/nolintlint/nolintlint.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ type BaseIssue struct {
replacement *result.Replacement
}

//nolint:gocritic // TODO(ldez) must be change in the future.
func (b BaseIssue) Position() token.Position {
return b.position
}

//nolint:gocritic // TODO(ldez) must be change in the future.
func (b BaseIssue) Replacement() *result.Replacement {
return b.replacement
}
Expand All @@ -31,6 +33,7 @@ type ExtraLeadingSpace struct {
BaseIssue
}

//nolint:gocritic // TODO(ldez) must be change in the future.
func (i ExtraLeadingSpace) Details() string {
return fmt.Sprintf("directive `%s` should not have more than one leading space", i.fullDirective)
}
Expand All @@ -41,6 +44,7 @@ type NotMachine struct {
BaseIssue
}

//nolint:gocritic // TODO(ldez) must be change in the future.
func (i NotMachine) Details() string {
expected := i.fullDirective[:2] + strings.TrimLeftFunc(i.fullDirective[2:], unicode.IsSpace)
return fmt.Sprintf("directive `%s` should be written without leading space as `%s`",
Expand All @@ -53,6 +57,7 @@ type NotSpecific struct {
BaseIssue
}

//nolint:gocritic // TODO(ldez) must be change in the future.
func (i NotSpecific) Details() string {
return fmt.Sprintf("directive `%s` should mention specific linter such as `%s:my-linter`",
i.fullDirective, i.directiveWithOptionalLeadingSpace)
Expand All @@ -64,6 +69,7 @@ type ParseError struct {
BaseIssue
}

//nolint:gocritic // TODO(ldez) must be change in the future.
func (i ParseError) Details() string {
return fmt.Sprintf("directive `%s` should match `%s[:<comma-separated-linters>] [// <explanation>]`",
i.fullDirective,
Expand All @@ -77,6 +83,7 @@ type NoExplanation struct {
fullDirectiveWithoutExplanation string
}

//nolint:gocritic // TODO(ldez) must be change in the future.
func (i NoExplanation) Details() string {
return fmt.Sprintf("directive `%s` should provide explanation such as `%s // this is why`",
i.fullDirective, i.fullDirectiveWithoutExplanation)
Expand All @@ -89,6 +96,7 @@ type UnusedCandidate struct {
ExpectedLinter string
}

//nolint:gocritic // TODO(ldez) must be change in the future.
func (i UnusedCandidate) Details() string {
details := fmt.Sprintf("directive `%s` is unused", i.fullDirective)
if i.ExpectedLinter != "" {
Expand Down
8 changes: 2 additions & 6 deletions pkg/lint/lintersdb/custom_linters.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package lintersdb
import (
"errors"
"fmt"
"os"
"path/filepath"
"plugin"

Expand Down Expand Up @@ -115,11 +114,8 @@ func (m *Manager) lookupAnalyzerPlugin(plug *plugin.Plugin) ([]*analysis.Analyze
return nil, err
}

// TODO(ldez): remove this env var (but keep the log) in the next minor version (v1.55.0)
if _, ok := os.LookupEnv("GOLANGCI_LINT_HIDE_WARNING_ABOUT_PLUGIN_API_DEPRECATION"); !ok {
m.log.Warnf("plugin: 'AnalyzerPlugin' plugins are deprecated, please use the new plugin signature: " +
"https://golangci-lint.run/contributing/new-linters/#create-a-plugin")
}
m.log.Warnf("plugin: 'AnalyzerPlugin' plugins are deprecated, please use the new plugin signature: " +
"https://golangci-lint.run/contributing/new-linters/#create-a-plugin")

analyzerPlugin, ok := symbol.(AnalyzerPlugin)
if !ok {
Expand Down