Skip to content
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

bump github.com/mgechev/revive from v1.1.3 to v1.1.4 #2576

Merged
merged 5 commits into from
Feb 16, 2022
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
9 changes: 9 additions & 0 deletions .golangci.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,10 @@ linters-settings:
- UnitAbbreviations

revive:
# Maximum number of open files at the same time.
# https://github.com/mgechev/revive#command-line-flags
# Defaults to unlimited.
max-open-files: 2048
# See https://github.com/mgechev/revive#available-rules for details.
ignore-generated-header: true
severity: warning
Expand All @@ -1042,6 +1046,11 @@ linters-settings:
allowInts: "0,1,2"
allowFloats: "0.0,0.,1.0,1.,2.0,2."
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#atomic
- name: argument-limit
severity: warning
disabled: false
arguments: [4]
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#atomic
- name: atomic
severity: warning
disabled: false
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ require (
github.com/mattn/go-colorable v0.1.12
github.com/mbilski/exhaustivestruct v1.2.0
github.com/mgechev/dots v0.0.0-20210922191527-e955255bf517
github.com/mgechev/revive v1.1.3
github.com/mgechev/revive v1.1.4
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/go-ps v1.0.0
github.com/moricho/tparallel v0.2.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ type PromlinterSettings struct {
}

type ReviveSettings struct {
MaxOpenFiles int `mapstructure:"max-open-files"`
IgnoreGeneratedHeader bool `mapstructure:"ignore-generated-header"`
Confidence float64
Severity string
Expand Down
19 changes: 8 additions & 11 deletions pkg/golinters/revive.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func NewRevive(cfg *config.ReviveSettings) *goanalysis.Linter {
return nil, err
}

revive := lint.New(os.ReadFile)
revive := lint.New(os.ReadFile, cfg.MaxOpenFiles)

lintingRules, err := reviveConfig.GetLintingRules(conf)
if err != nil {
Expand Down Expand Up @@ -148,7 +148,7 @@ func reviveToIssue(pass *analysis.Pass, object *jsonObject) goanalysis.Issue {
// This function mimics the GetConfig function of revive.
// This allows to get default values and right types.
// https://github.com/golangci/golangci-lint/issues/1745
// https://github.com/mgechev/revive/blob/389ba853b0b3587f0c3b71b5f0c61ea4e23928ec/config/config.go#L155
// https://github.com/mgechev/revive/blob/v1.1.4/config/config.go#L182
func getReviveConfig(cfg *config.ReviveSettings) (*lint.Config, error) {
conf := defaultConfig()

Expand Down Expand Up @@ -235,7 +235,7 @@ func safeTomlSlice(r []interface{}) []interface{} {
}

// This element is not exported by revive, so we need copy the code.
// Extracted from https://github.com/mgechev/revive/blob/111721be475b73b5a2304dd01ccbcab587357fca/config/config.go#L15
// Extracted from https://github.com/mgechev/revive/blob/v1.1.4/config/config.go#L15
var defaultRules = []lint.Rule{
&rule.VarDeclarationsRule{},
&rule.PackageCommentsRule{},
Expand Down Expand Up @@ -310,14 +310,11 @@ var allRules = append([]lint.Rule{
&rule.OptimizeOperandsOrderRule{},
}, defaultRules...)

const defaultConfidence = 0.8

// This element is not exported by revive, so we need copy the code.
// Extracted from https://github.com/mgechev/revive/blob/111721be475b73b5a2304dd01ccbcab587357fca/config/config.go#L143
// Extracted from https://github.com/mgechev/revive/blob/v1.1.4/config/config.go#L145
func normalizeConfig(cfg *lint.Config) {
const defaultConfidence = 0.8
if cfg.Confidence == 0 {
cfg.Confidence = defaultConfidence
}

if len(cfg.Rules) == 0 {
cfg.Rules = map[string]lint.RuleConfig{}
}
Expand Down Expand Up @@ -352,10 +349,10 @@ func normalizeConfig(cfg *lint.Config) {
}

// This element is not exported by revive, so we need copy the code.
// Extracted from https://github.com/mgechev/revive/blob/111721be475b73b5a2304dd01ccbcab587357fca/config/config.go#L210
// Extracted from https://github.com/mgechev/revive/blob/v1.1.4/config/config.go#L214
func defaultConfig() *lint.Config {
defaultConfig := lint.Config{
Confidence: 0.0,
Confidence: defaultConfidence,
Severity: lint.SeverityWarning,
Rules: map[string]lint.RuleConfig{},
}
Expand Down