Skip to content

Commit c69abc8

Browse files
dependabot[bot]ldez
authored andcommitted
build(deps): bump github.com/maratori/testpackage from 1.0.1 to 1.1.0 (#2945)
Co-authored-by: Fernandez Ludovic <[email protected]>
1 parent 3071fec commit c69abc8

File tree

8 files changed

+61
-13
lines changed

8 files changed

+61
-13
lines changed

.golangci.reference.yml

+5
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,11 @@ linters-settings:
16071607
# Regexp pattern to skip files.
16081608
# Default: "(export|internal)_test\\.go"
16091609
skip-regexp: (export|internal)_test\.go
1610+
# List of packages that don't end with _test that tests are allowed to be in.
1611+
# Default: "main"
1612+
allow-packages:
1613+
- example
1614+
- main
16101615

16111616
thelper:
16121617
test:

go.mod

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ require (
5555
github.com/ldez/tagliatelle v0.3.1
5656
github.com/leonklingele/grouper v1.1.0
5757
github.com/lufeee/execinquery v1.2.1
58-
github.com/maratori/testpackage v1.0.1
58+
github.com/maratori/testpackage v1.1.0
5959
github.com/matoous/godox v0.0.0-20210227103229-6504466cf951 // v1.0
6060
github.com/mattn/go-colorable v0.1.12
6161
github.com/mbilski/exhaustivestruct v1.2.0
@@ -155,6 +155,7 @@ require (
155155
github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5 // indirect
156156
github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect
157157
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
158+
github.com/sivchari/nosnakecase v1.0.1
158159
github.com/spf13/afero v1.8.2 // indirect
159160
github.com/spf13/cast v1.5.0 // indirect
160161
github.com/spf13/jwalterweatherman v1.1.0 // indirect

go.sum

+4-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/config/linters_settings.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ var defaultLintersSettings = LintersSettings{
8888
Qualified: false,
8989
},
9090
Testpackage: TestpackageSettings{
91-
SkipRegexp: `(export|internal)_test\.go`,
91+
SkipRegexp: `(export|internal)_test\.go`,
92+
AllowPackages: []string{"main"},
9293
},
9394
Unparam: UnparamSettings{
9495
Algo: "cha",
@@ -558,7 +559,8 @@ type TagliatelleSettings struct {
558559
}
559560

560561
type TestpackageSettings struct {
561-
SkipRegexp string `mapstructure:"skip-regexp"`
562+
SkipRegexp string `mapstructure:"skip-regexp"`
563+
AllowPackages []string `mapstructure:"allow-packages"`
562564
}
563565

564566
type ThelperSettings struct {

pkg/golinters/nosnakecase.go

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package golinters
2+
3+
import (
4+
"github.com/sivchari/nosnakecase"
5+
"golang.org/x/tools/go/analysis"
6+
7+
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
8+
)
9+
10+
func NewNoSnakeCase() *goanalysis.Linter {
11+
a := nosnakecase.Analyzer
12+
13+
return goanalysis.NewLinter(
14+
a.Name,
15+
a.Doc,
16+
[]*analysis.Analyzer{a},
17+
nil,
18+
).WithLoadMode(goanalysis.LoadModeSyntax)
19+
}

pkg/golinters/testpackage.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package golinters
22

33
import (
4+
"strings"
5+
46
"github.com/maratori/testpackage/pkg/testpackage"
57
"golang.org/x/tools/go/analysis"
68

@@ -15,7 +17,8 @@ func NewTestpackage(cfg *config.TestpackageSettings) *goanalysis.Linter {
1517
if cfg != nil {
1618
settings = map[string]map[string]interface{}{
1719
a.Name: {
18-
testpackage.SkipRegexpFlagName: cfg.SkipRegexp,
20+
testpackage.SkipRegexpFlagName: cfg.SkipRegexp,
21+
testpackage.AllowPackagesFlagName: strings.Join(cfg.AllowPackages, ","),
1922
},
2023
}
2124
}

pkg/lint/lintersdb/manager.go

+5
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,11 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
631631
WithPresets(linter.PresetStyle).
632632
WithURL("https://github.com/firefart/nonamedreturns"),
633633

634+
linter.NewConfig(golinters.NewNoSnakeCase()).
635+
WithSince("v1.46.0").
636+
WithPresets(linter.PresetStyle).
637+
WithURL("https://github.com/sivchari/nosnakecase"),
638+
634639
linter.NewConfig(golinters.NewNoSprintfHostPort()).
635640
WithSince("v1.46.0").
636641
WithPresets(linter.PresetStyle).

test/testdata/nosnakecase.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// args: -Enosnakecase
2+
package testdata
3+
4+
func a_() { // ERROR "a_ is used under score. You should use mixedCap or MixedCap."
5+
}
6+
7+
func b(a_a int) { // ERROR "a_a is used under score. You should use mixedCap or MixedCap."
8+
}
9+
10+
func c() (c_c int) { // ERROR "c_c is used under score. You should use mixedCap or MixedCap."
11+
c_c = 1 // ERROR "c_c is used under score. You should use mixedCap or MixedCap."
12+
return c_c // It's never detected, because `c_c` is already detected.
13+
}
14+
15+
func d() {
16+
var d_d int // ERROR "d_d is used under score. You should use mixedCap or MixedCap."
17+
_ = d_d // It's never detected, because `_` is meaningful in Go and `d_d` is already detected.
18+
}

0 commit comments

Comments
 (0)