Skip to content

Commit

Permalink
Refactor to avoid undersore in var names
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed Oct 22, 2024
1 parent f9da2b6 commit 5d2cc49
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
10 changes: 10 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ linters:
- prealloc
- predeclared
- reassign
- revive
- testifylint
linters-settings:
revive:
enable-all-rules: false
rules:
- name: 'var-naming'
staticcheck:
checks:
- all
Expand All @@ -34,3 +39,8 @@ linters-settings:
- empty
- expected-actual
- len
issues:
exclude-rules:
- linters:
- revive
text: "var-naming: don't use an underscore in package name"
16 changes: 8 additions & 8 deletions cmd/mockery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ func TestNewRootCmd(t *testing.T) {
func Test_initConfig(t *testing.T) {
tests := []struct {
name string
base_path string
basePath string
configPath string
}{
{
name: "test config at base directory",
base_path: "1/2/3/4",
basePath: "1/2/3/4",
configPath: "1/2/3/4/.mockery.yaml",
},
{
name: "test config at upper directory",
base_path: "1/2/3/4",
basePath: "1/2/3/4",
configPath: "1/.mockery.yaml",
},
{
name: "no config file found",
base_path: "1/2/3/4",
name: "no config file found",
basePath: "1/2/3/4",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tmpDir := pathlib.NewPath(t.TempDir())
baseDir := tmpDir.Join(strings.Split(tt.base_path, "/")...)
baseDir := tmpDir.Join(strings.Split(tt.basePath, "/")...)
require.NoError(t, baseDir.MkdirAll())

configPath := pathlib.NewPath("")
Expand Down Expand Up @@ -164,15 +164,15 @@ packages:
goModPath := pathlib.NewPath(tmpDir).Join("go.mod")
err := goModPath.WriteFile([]byte(`
module github.com/testuser/testpackage
go 1.20`))
require.NoError(t, err)

interfacePath := pathlib.NewPath(tmpDir).Join("internal", "foopkg", "interface.go")
require.NoError(t, interfacePath.Parent().MkdirAll())
require.NoError(t, interfacePath.WriteFile([]byte(`
package foopkg
type FooInterface interface {
Foo()
Bar()
Expand Down
2 changes: 1 addition & 1 deletion pkg/fixtures/requester_unexported.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package test

type requester_unexported interface {
type requesterUnexported interface {
Get()
}
5 changes: 3 additions & 2 deletions pkg/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const (
LogKeyPath = "path"
LogKeyQualifiedName = "qualified-name"
LogKeyPackageName = "package-name"
_defaultSemVer = "v0.0.0-dev"

defaultSemVer = "v0.0.0-dev"
)

// SemVer is the version of mockery at build time.
Expand All @@ -38,7 +39,7 @@ func GetSemverInfo() string {
if ok && version.Main.Version != "(devel)" && version.Main.Version != "" {
return version.Main.Version
}
return _defaultSemVer
return defaultSemVer
}

func getMinorSemver(semver string) string {
Expand Down

0 comments on commit 5d2cc49

Please sign in to comment.