Skip to content

Commit

Permalink
build(deps): bump github.com/maratori/testpackage from 1.0.1 to 1.1.0 (
Browse files Browse the repository at this point in the history
…golangci#2945)

Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
  • Loading branch information
2 people authored and sivchari committed Jun 28, 2022
1 parent 3071fec commit c69abc8
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .golangci.reference.yml
Expand Up @@ -1607,6 +1607,11 @@ linters-settings:
# Regexp pattern to skip files.
# Default: "(export|internal)_test\\.go"
skip-regexp: (export|internal)_test\.go
# List of packages that don't end with _test that tests are allowed to be in.
# Default: "main"
allow-packages:
- example
- main

thelper:
test:
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Expand Up @@ -55,7 +55,7 @@ require (
github.com/ldez/tagliatelle v0.3.1
github.com/leonklingele/grouper v1.1.0
github.com/lufeee/execinquery v1.2.1
github.com/maratori/testpackage v1.0.1
github.com/maratori/testpackage v1.1.0
github.com/matoous/godox v0.0.0-20210227103229-6504466cf951 // v1.0
github.com/mattn/go-colorable v0.1.12
github.com/mbilski/exhaustivestruct v1.2.0
Expand Down Expand Up @@ -155,6 +155,7 @@ require (
github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5 // indirect
github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
github.com/sivchari/nosnakecase v1.0.1
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
Expand Down
13 changes: 4 additions & 9 deletions go.sum

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

6 changes: 4 additions & 2 deletions pkg/config/linters_settings.go
Expand Up @@ -88,7 +88,8 @@ var defaultLintersSettings = LintersSettings{
Qualified: false,
},
Testpackage: TestpackageSettings{
SkipRegexp: `(export|internal)_test\.go`,
SkipRegexp: `(export|internal)_test\.go`,
AllowPackages: []string{"main"},
},
Unparam: UnparamSettings{
Algo: "cha",
Expand Down Expand Up @@ -558,7 +559,8 @@ type TagliatelleSettings struct {
}

type TestpackageSettings struct {
SkipRegexp string `mapstructure:"skip-regexp"`
SkipRegexp string `mapstructure:"skip-regexp"`
AllowPackages []string `mapstructure:"allow-packages"`
}

type ThelperSettings struct {
Expand Down
19 changes: 19 additions & 0 deletions pkg/golinters/nosnakecase.go
@@ -0,0 +1,19 @@
package golinters

import (
"github.com/sivchari/nosnakecase"
"golang.org/x/tools/go/analysis"

"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
)

func NewNoSnakeCase() *goanalysis.Linter {
a := nosnakecase.Analyzer

return goanalysis.NewLinter(
a.Name,
a.Doc,
[]*analysis.Analyzer{a},
nil,
).WithLoadMode(goanalysis.LoadModeSyntax)
}
5 changes: 4 additions & 1 deletion pkg/golinters/testpackage.go
@@ -1,6 +1,8 @@
package golinters

import (
"strings"

"github.com/maratori/testpackage/pkg/testpackage"
"golang.org/x/tools/go/analysis"

Expand All @@ -15,7 +17,8 @@ func NewTestpackage(cfg *config.TestpackageSettings) *goanalysis.Linter {
if cfg != nil {
settings = map[string]map[string]interface{}{
a.Name: {
testpackage.SkipRegexpFlagName: cfg.SkipRegexp,
testpackage.SkipRegexpFlagName: cfg.SkipRegexp,
testpackage.AllowPackagesFlagName: strings.Join(cfg.AllowPackages, ","),
},
}
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/lint/lintersdb/manager.go
Expand Up @@ -631,6 +631,11 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithPresets(linter.PresetStyle).
WithURL("https://github.com/firefart/nonamedreturns"),

linter.NewConfig(golinters.NewNoSnakeCase()).
WithSince("v1.46.0").
WithPresets(linter.PresetStyle).
WithURL("https://github.com/sivchari/nosnakecase"),

linter.NewConfig(golinters.NewNoSprintfHostPort()).
WithSince("v1.46.0").
WithPresets(linter.PresetStyle).
Expand Down
18 changes: 18 additions & 0 deletions test/testdata/nosnakecase.go
@@ -0,0 +1,18 @@
// args: -Enosnakecase
package testdata

func a_() { // ERROR "a_ is used under score. You should use mixedCap or MixedCap."
}

func b(a_a int) { // ERROR "a_a is used under score. You should use mixedCap or MixedCap."
}

func c() (c_c int) { // ERROR "c_c is used under score. You should use mixedCap or MixedCap."
c_c = 1 // ERROR "c_c is used under score. You should use mixedCap or MixedCap."
return c_c // It's never detected, because `c_c` is already detected.
}

func d() {
var d_d int // ERROR "d_d is used under score. You should use mixedCap or MixedCap."
_ = d_d // It's never detected, because `_` is meaningful in Go and `d_d` is already detected.
}

0 comments on commit c69abc8

Please sign in to comment.