Skip to content

Commit

Permalink
bump github.com/mgechev/revive from v1.1.3 to v1.1.4 (golangci#2576)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored and SeigeC committed Apr 4, 2023
1 parent 75d8aad commit 7d8f68d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
9 changes: 9 additions & 0 deletions .golangci.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,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 @@ -1067,6 +1071,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

0 comments on commit 7d8f68d

Please sign in to comment.