Skip to content

Commit 794a340

Browse files
build(deps): bump github.com/ldez/gomoddirectives from 0.4.2 to 0.5.0 (#5187)
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
1 parent 9686758 commit 794a340

8 files changed

+66
-14
lines changed

.golangci.next.reference.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,17 +1355,29 @@ linters-settings:
13551355
gomoddirectives:
13561356
# Allow local `replace` directives.
13571357
# Default: false
1358-
replace-local: false
1358+
replace-local: true
13591359
# List of allowed `replace` directives.
13601360
# Default: []
13611361
replace-allow-list:
13621362
- launchpad.net/gocheck
13631363
# Allow to not explain why the version has been retracted in the `retract` directives.
13641364
# Default: false
1365-
retract-allow-no-explanation: false
1365+
retract-allow-no-explanation: true
13661366
# Forbid the use of the `exclude` directives.
13671367
# Default: false
1368-
exclude-forbidden: false
1368+
exclude-forbidden: true
1369+
# Forbid the use of the `toolchain` directive.
1370+
# Default: false
1371+
toolchain-forbidden: true
1372+
# Forbid the use of the `tool` directives.
1373+
# Default: false
1374+
tool-forbidden: true
1375+
# Forbid the use of the `godebug` directive.
1376+
# Default: false
1377+
go-debug-forbidden: true
1378+
# Defines a pattern to validate `go` minimum version directive.
1379+
# Default: '' (no match)
1380+
go-version-pattern: '\d\.\d+(\.0)?'
13691381

13701382
gomodguard:
13711383
allowed:

.golangci.reference.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,17 +1353,19 @@ linters-settings:
13531353
gomoddirectives:
13541354
# Allow local `replace` directives.
13551355
# Default: false
1356-
replace-local: false
1356+
replace-local: true
1357+
13571358
# List of allowed `replace` directives.
13581359
# Default: []
13591360
replace-allow-list:
13601361
- launchpad.net/gocheck
13611362
# Allow to not explain why the version has been retracted in the `retract` directives.
13621363
# Default: false
1363-
retract-allow-no-explanation: false
1364+
retract-allow-no-explanation: true
1365+
13641366
# Forbid the use of the `exclude` directives.
13651367
# Default: false
1366-
exclude-forbidden: false
1368+
exclude-forbidden: true
13671369

13681370
gomodguard:
13691371
allowed:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ require (
6666
github.com/kunwardeep/paralleltest v1.0.10
6767
github.com/kyoh86/exportloopref v0.1.11
6868
github.com/lasiar/canonicalheader v1.1.2
69-
github.com/ldez/gomoddirectives v0.4.2
69+
github.com/ldez/gomoddirectives v0.5.0
7070
github.com/ldez/grignotin v0.6.0
7171
github.com/ldez/tagliatelle v0.6.0
7272
github.com/ldez/usetesting v0.2.1

go.sum

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsonschema/golangci.jsonschema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,7 @@
16381638
"replace-local": {
16391639
"description": "Allow local `replace` directives.",
16401640
"type": "boolean",
1641-
"default": true
1641+
"default": false
16421642
},
16431643
"replace-allow-list": {
16441644
"description": "List of allowed `replace` directives.",
@@ -1650,12 +1650,12 @@
16501650
"retract-allow-no-explanation": {
16511651
"description": "Allow to not explain why the version has been retracted in the `retract` directives.",
16521652
"type": "boolean",
1653-
"default": true
1653+
"default": false
16541654
},
16551655
"exclude-forbidden": {
16561656
"description": "Forbid the use of the `exclude` directives.",
16571657
"type": "boolean",
1658-
"default": true
1658+
"default": false
16591659
}
16601660
}
16611661
},

jsonschema/golangci.next.jsonschema.json

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,12 +1668,32 @@
16681668
"retract-allow-no-explanation": {
16691669
"description": "Allow to not explain why the version has been retracted in the `retract` directives.",
16701670
"type": "boolean",
1671-
"default": true
1671+
"default": false
16721672
},
16731673
"exclude-forbidden": {
16741674
"description": "Forbid the use of the `exclude` directives.",
16751675
"type": "boolean",
1676-
"default": true
1676+
"default": false
1677+
},
1678+
"toolchain-forbidden": {
1679+
"description": "Forbid the use of the `toolchain` directive.",
1680+
"type": "boolean",
1681+
"default": false
1682+
},
1683+
"tool-forbidden": {
1684+
"description": "Forbid the use of the `tool` directives.",
1685+
"type": "boolean",
1686+
"default": false
1687+
},
1688+
"go-debug-forbidden": {
1689+
"description": "Forbid the use of the `godebug` directive.",
1690+
"type": "boolean",
1691+
"default": false
1692+
},
1693+
"go-version-pattern": {
1694+
"description": "Defines a pattern to validate `go` minimum version directive.",
1695+
"type": "string",
1696+
"default": ""
16771697
}
16781698
}
16791699
},

pkg/config/linters_settings.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,10 @@ type GoModDirectivesSettings struct {
585585
ReplaceLocal bool `mapstructure:"replace-local"`
586586
ExcludeForbidden bool `mapstructure:"exclude-forbidden"`
587587
RetractAllowNoExplanation bool `mapstructure:"retract-allow-no-explanation"`
588+
ToolchainForbidden bool `mapstructure:"toolchain-forbidden"`
589+
ToolForbidden bool `mapstructure:"tool-forbidden"`
590+
GoDebugForbidden bool `mapstructure:"go-debug-forbidden"`
591+
GoVersionPattern string `mapstructure:"go-version-pattern"`
588592
}
589593

590594
type GoModGuardSettings struct {

pkg/golinters/gomoddirectives/gomoddirectives.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package gomoddirectives
22

33
import (
4+
"regexp"
45
"sync"
56

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

910
"github.com/golangci/golangci-lint/pkg/config"
1011
"github.com/golangci/golangci-lint/pkg/goanalysis"
12+
"github.com/golangci/golangci-lint/pkg/golinters/internal"
1113
"github.com/golangci/golangci-lint/pkg/lint/linter"
1214
"github.com/golangci/golangci-lint/pkg/result"
1315
)
@@ -24,6 +26,18 @@ func New(settings *config.GoModDirectivesSettings) *goanalysis.Linter {
2426
opts.ReplaceAllowList = settings.ReplaceAllowList
2527
opts.RetractAllowNoExplanation = settings.RetractAllowNoExplanation
2628
opts.ExcludeForbidden = settings.ExcludeForbidden
29+
opts.ToolchainForbidden = settings.ToolchainForbidden
30+
opts.ToolForbidden = settings.ToolForbidden
31+
opts.GoDebugForbidden = settings.GoDebugForbidden
32+
33+
if settings.GoVersionPattern != "" {
34+
exp, err := regexp.Compile(settings.GoVersionPattern)
35+
if err != nil {
36+
internal.LinterLogger.Fatalf("%s: invalid Go version pattern: %v", linterName, err)
37+
} else {
38+
opts.GoVersionPattern = exp
39+
}
40+
}
2741
}
2842

2943
analyzer := &analysis.Analyzer{

0 commit comments

Comments
 (0)