Skip to content

Commit

Permalink
1. renamed linter
Browse files Browse the repository at this point in the history
2. renamed options
3. changed linter version
  • Loading branch information
maranqz committed Dec 15, 2023
1 parent 930e2b2 commit c1195cf
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .golangci.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ linters-settings:
- github.com/author/repository/path/to/package/**
# Use a factory to initiate a structure for glob packages only.
# Default: false
onlyPackageGlobs: true
packageGlobsOnly: true

gofmt:
# Simplify code: gofmt with `-s` option.
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ require (
github.com/leonklingele/grouper v1.1.1
github.com/lufeee/execinquery v1.2.1
github.com/macabu/inamedparam v0.1.2
github.com/maranqz/go-factory-lint/v2 v2.0.0-beta.5
github.com/maranqz/gofactory v1.0.0-rc1
github.com/maratori/testableexamples v1.0.0
github.com/maratori/testpackage v1.1.1
github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26
Expand Down Expand Up @@ -124,7 +124,7 @@ require (
go-simpler.org/musttag v0.8.0
go-simpler.org/sloglint v0.3.0
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea
golang.org/x/tools v0.15.0
golang.org/x/tools v0.16.0
gopkg.in/yaml.v3 v3.0.1
honnef.co/go/tools v0.4.6
mvdan.cc/gofumpt v0.5.0
Expand Down
10 changes: 5 additions & 5 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 pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ type LintersSettings struct {
Gocyclo GoCycloSettings
Godot GodotSettings
Godox GodoxSettings
Gofactory GoFactoryLintSettings
Gofactory GoFactorySettings
Gofmt GoFmtSettings
Gofumpt GofumptSettings
Goheader GoHeaderSettings
Expand Down Expand Up @@ -480,9 +480,9 @@ type GodoxSettings struct {
Keywords []string
}

type GoFactoryLintSettings struct {
type GoFactorySettings struct {
PackageGlobs []string `mapstructure:"packageGlobs"`
OnlyPackageGlobs bool `mapstructure:"onlyPackageGlobs"`
PackageGlobsOnly bool `mapstructure:"packageGlobsOnly"`
}

type GoFmtSettings struct {
Expand Down
8 changes: 4 additions & 4 deletions pkg/golinters/gofactorylint.go → pkg/golinters/gofactory.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package golinters

import (
"github.com/maranqz/go-factory-lint/v2"
"github.com/maranqz/gofactory"
"golang.org/x/tools/go/analysis"

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

func NewGoFactoryLint(settings *config.GoFactoryLintSettings) *goanalysis.Linter {
analyzer := factory.NewAnalyzer()
func NewGoFactory(settings *config.GoFactorySettings) *goanalysis.Linter {
analyzer := gofactory.NewAnalyzer()

cfg := make(map[string]map[string]any)
if settings != nil {
cfg[analyzer.Name] = map[string]any{}

if len(settings.PackageGlobs) > 0 {
cfg[analyzer.Name]["packageGlobs"] = settings.PackageGlobs
cfg[analyzer.Name]["onlyPackageGlobs"] = settings.OnlyPackageGlobs
cfg[analyzer.Name]["packageGlobsOnly"] = settings.PackageGlobsOnly
}
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/lint/lintersdb/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
gocycloCfg *config.GoCycloSettings
godotCfg *config.GodotSettings
godoxCfg *config.GodoxSettings
goFactoryCfg *config.GoFactoryLintSettings
goFactoryCfg *config.GoFactorySettings
gofmtCfg *config.GoFmtSettings
gofumptCfg *config.GofumptSettings
goheaderCfg *config.GoHeaderSettings
Expand Down Expand Up @@ -490,11 +490,11 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithLoadForGoAnalysis().
WithURL("https://github.com/Djarvur/go-err113"),

linter.NewConfig(golinters.NewGoFactoryLint(goFactoryCfg)).
linter.NewConfig(golinters.NewGoFactory(goFactoryCfg)).
WithSince("1.56.0").
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/maranqz/go-factory-lint"),
WithURL("https://github.com/maranqz/gofactory"),

linter.NewConfig(golinters.NewGofmt(gofmtCfg)).
WithSince("v1.0.0").
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/gofactory/blocked.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//golangcitest:args -Egofactory
//golangcitest:config_path configs/go_factory_only_blocked.yml
//golangcitest:config_path configs/go_factory_package_globs_only.yml
package gofactory

import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ linters-settings:
gofactory:
packageGlobs:
- net/url/**
onlyPackageGlobs: true
packageGlobsOnly: true

0 comments on commit c1195cf

Please sign in to comment.