Skip to content

Commit

Permalink
build(deps): bump github.com/ldez/gomoddirectives from 0.4.2 to 0.5.0 (
Browse files Browse the repository at this point in the history
…#5187)

Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
  • Loading branch information
dependabot[bot] and ldez authored Dec 2, 2024
1 parent 9686758 commit 794a340
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 14 deletions.
18 changes: 15 additions & 3 deletions .golangci.next.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1355,17 +1355,29 @@ linters-settings:
gomoddirectives:
# Allow local `replace` directives.
# Default: false
replace-local: false
replace-local: true
# List of allowed `replace` directives.
# Default: []
replace-allow-list:
- launchpad.net/gocheck
# Allow to not explain why the version has been retracted in the `retract` directives.
# Default: false
retract-allow-no-explanation: false
retract-allow-no-explanation: true
# Forbid the use of the `exclude` directives.
# Default: false
exclude-forbidden: false
exclude-forbidden: true
# Forbid the use of the `toolchain` directive.
# Default: false
toolchain-forbidden: true
# Forbid the use of the `tool` directives.
# Default: false
tool-forbidden: true
# Forbid the use of the `godebug` directive.
# Default: false
go-debug-forbidden: true
# Defines a pattern to validate `go` minimum version directive.
# Default: '' (no match)
go-version-pattern: '\d\.\d+(\.0)?'

gomodguard:
allowed:
Expand Down
8 changes: 5 additions & 3 deletions .golangci.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1353,17 +1353,19 @@ linters-settings:
gomoddirectives:
# Allow local `replace` directives.
# Default: false
replace-local: false
replace-local: true

# List of allowed `replace` directives.
# Default: []
replace-allow-list:
- launchpad.net/gocheck
# Allow to not explain why the version has been retracted in the `retract` directives.
# Default: false
retract-allow-no-explanation: false
retract-allow-no-explanation: true

# Forbid the use of the `exclude` directives.
# Default: false
exclude-forbidden: false
exclude-forbidden: true

gomodguard:
allowed:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ require (
github.com/kunwardeep/paralleltest v1.0.10
github.com/kyoh86/exportloopref v0.1.11
github.com/lasiar/canonicalheader v1.1.2
github.com/ldez/gomoddirectives v0.4.2
github.com/ldez/gomoddirectives v0.5.0
github.com/ldez/grignotin v0.6.0
github.com/ldez/tagliatelle v0.6.0
github.com/ldez/usetesting 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.

6 changes: 3 additions & 3 deletions jsonschema/golangci.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,7 @@
"replace-local": {
"description": "Allow local `replace` directives.",
"type": "boolean",
"default": true
"default": false
},
"replace-allow-list": {
"description": "List of allowed `replace` directives.",
Expand All @@ -1650,12 +1650,12 @@
"retract-allow-no-explanation": {
"description": "Allow to not explain why the version has been retracted in the `retract` directives.",
"type": "boolean",
"default": true
"default": false
},
"exclude-forbidden": {
"description": "Forbid the use of the `exclude` directives.",
"type": "boolean",
"default": true
"default": false
}
}
},
Expand Down
24 changes: 22 additions & 2 deletions jsonschema/golangci.next.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1668,12 +1668,32 @@
"retract-allow-no-explanation": {
"description": "Allow to not explain why the version has been retracted in the `retract` directives.",
"type": "boolean",
"default": true
"default": false
},
"exclude-forbidden": {
"description": "Forbid the use of the `exclude` directives.",
"type": "boolean",
"default": true
"default": false
},
"toolchain-forbidden": {
"description": "Forbid the use of the `toolchain` directive.",
"type": "boolean",
"default": false
},
"tool-forbidden": {
"description": "Forbid the use of the `tool` directives.",
"type": "boolean",
"default": false
},
"go-debug-forbidden": {
"description": "Forbid the use of the `godebug` directive.",
"type": "boolean",
"default": false
},
"go-version-pattern": {
"description": "Defines a pattern to validate `go` minimum version directive.",
"type": "string",
"default": ""
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,10 @@ type GoModDirectivesSettings struct {
ReplaceLocal bool `mapstructure:"replace-local"`
ExcludeForbidden bool `mapstructure:"exclude-forbidden"`
RetractAllowNoExplanation bool `mapstructure:"retract-allow-no-explanation"`
ToolchainForbidden bool `mapstructure:"toolchain-forbidden"`
ToolForbidden bool `mapstructure:"tool-forbidden"`
GoDebugForbidden bool `mapstructure:"go-debug-forbidden"`
GoVersionPattern string `mapstructure:"go-version-pattern"`
}

type GoModGuardSettings struct {
Expand Down
14 changes: 14 additions & 0 deletions pkg/golinters/gomoddirectives/gomoddirectives.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package gomoddirectives

import (
"regexp"
"sync"

"github.com/ldez/gomoddirectives"
"golang.org/x/tools/go/analysis"

"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/goanalysis"
"github.com/golangci/golangci-lint/pkg/golinters/internal"
"github.com/golangci/golangci-lint/pkg/lint/linter"
"github.com/golangci/golangci-lint/pkg/result"
)
Expand All @@ -24,6 +26,18 @@ func New(settings *config.GoModDirectivesSettings) *goanalysis.Linter {
opts.ReplaceAllowList = settings.ReplaceAllowList
opts.RetractAllowNoExplanation = settings.RetractAllowNoExplanation
opts.ExcludeForbidden = settings.ExcludeForbidden
opts.ToolchainForbidden = settings.ToolchainForbidden
opts.ToolForbidden = settings.ToolForbidden
opts.GoDebugForbidden = settings.GoDebugForbidden

if settings.GoVersionPattern != "" {
exp, err := regexp.Compile(settings.GoVersionPattern)
if err != nil {
internal.LinterLogger.Fatalf("%s: invalid Go version pattern: %v", linterName, err)
} else {
opts.GoVersionPattern = exp
}
}
}

analyzer := &analysis.Analyzer{
Expand Down

0 comments on commit 794a340

Please # to comment.