build(deps): bump github.com/ghostiam/protogetter from 0.2.3 to 0.3.1 (#4167)

This commit is contained in:
Vladislav Fursov 2023-11-05 16:10:43 +04:00 committed by GitHub
parent f17fef34b2
commit 97cb9054a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 5 deletions

View File

@ -1422,6 +1422,22 @@ linters-settings:
- CamelCase - CamelCase
- UnitAbbreviations - UnitAbbreviations
protogetter:
# Skip files generated by specified generators from the checking.
# Checks only the file's initial comment, which must follow the format: "// Code generated by <generator-name>".
# Files generated by protoc-gen-go, protoc-gen-go-grpc, and protoc-gen-grpc-gateway are always excluded automatically.
# Default: []
skip-generated-by: ["protoc-gen-go-my-own-generator"]
# Skip files matching the specified glob pattern from the checking.
# Default: []
skip-files:
- "*.pb.go"
- "*/vendor/*"
- "/full/path/to/file.go"
# Skip any generated files from the checking.
# Default: false
skip-any-generated: true
reassign: reassign:
# Patterns for global variable names that are checked for reassignment. # Patterns for global variable names that are checked for reassignment.
# See https://github.com/curioswitch/go-reassign#usage # See https://github.com/curioswitch/go-reassign#usage

2
go.mod
View File

@ -36,7 +36,7 @@ require (
github.com/fatih/color v1.15.0 github.com/fatih/color v1.15.0
github.com/firefart/nonamedreturns v1.0.4 github.com/firefart/nonamedreturns v1.0.4
github.com/fzipp/gocyclo v0.6.0 github.com/fzipp/gocyclo v0.6.0
github.com/ghostiam/protogetter v0.2.3 github.com/ghostiam/protogetter v0.3.1
github.com/go-critic/go-critic v0.9.0 github.com/go-critic/go-critic v0.9.0
github.com/go-xmlfmt/xmlfmt v1.1.2 github.com/go-xmlfmt/xmlfmt v1.1.2
github.com/gofrs/flock v0.8.1 github.com/gofrs/flock v0.8.1

2
go.sum generated
View File

@ -154,6 +154,8 @@ github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo=
github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA=
github.com/ghostiam/protogetter v0.2.3 h1:qdv2pzo3BpLqezwqfGDLZ+nHEYmc5bUpIdsMbBVwMjw= github.com/ghostiam/protogetter v0.2.3 h1:qdv2pzo3BpLqezwqfGDLZ+nHEYmc5bUpIdsMbBVwMjw=
github.com/ghostiam/protogetter v0.2.3/go.mod h1:KmNLOsy1v04hKbvZs8EfGI1fk39AgTdRDxWNYPfXVc4= github.com/ghostiam/protogetter v0.2.3/go.mod h1:KmNLOsy1v04hKbvZs8EfGI1fk39AgTdRDxWNYPfXVc4=
github.com/ghostiam/protogetter v0.3.1 h1:4BQ2YZu9v3C+0QUzVmzjh9iVd/b2SgpLBjv9hvyIAdM=
github.com/ghostiam/protogetter v0.3.1/go.mod h1:A0JgIhs0fgVnotGinjQiKaFVG3waItLJNwPmcMzDnvk=
github.com/go-critic/go-critic v0.9.0 h1:Pmys9qvU3pSML/3GEQ2Xd9RZ/ip+aXHKILuxczKGV/U= github.com/go-critic/go-critic v0.9.0 h1:Pmys9qvU3pSML/3GEQ2Xd9RZ/ip+aXHKILuxczKGV/U=
github.com/go-critic/go-critic v0.9.0/go.mod h1:5P8tdXL7m/6qnyG6oRAlYLORvoXH0WDypYgAEmagT40= github.com/go-critic/go-critic v0.9.0/go.mod h1:5P8tdXL7m/6qnyG6oRAlYLORvoXH0WDypYgAEmagT40=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=

View File

@ -231,6 +231,7 @@ type LintersSettings struct {
Prealloc PreallocSettings Prealloc PreallocSettings
Predeclared PredeclaredSettings Predeclared PredeclaredSettings
Promlinter PromlinterSettings Promlinter PromlinterSettings
ProtoGetter ProtoGetterSettings
Reassign ReassignSettings Reassign ReassignSettings
Revive ReviveSettings Revive ReviveSettings
RowsErrCheck RowsErrCheckSettings RowsErrCheck RowsErrCheckSettings
@ -707,6 +708,12 @@ type PromlinterSettings struct {
DisabledLinters []string `mapstructure:"disabled-linters"` DisabledLinters []string `mapstructure:"disabled-linters"`
} }
type ProtoGetterSettings struct {
SkipGeneratedBy []string `mapstructure:"skip-generated-by"`
SkipFiles []string `mapstructure:"skip-files"`
SkipAnyGenerated bool `mapstructure:"skip-any-generated"`
}
type ReassignSettings struct { type ReassignSettings struct {
Patterns []string `mapstructure:"patterns"` Patterns []string `mapstructure:"patterns"`
} }

View File

@ -6,18 +6,32 @@ import (
"github.com/ghostiam/protogetter" "github.com/ghostiam/protogetter"
"golang.org/x/tools/go/analysis" "golang.org/x/tools/go/analysis"
"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis" "github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
"github.com/golangci/golangci-lint/pkg/lint/linter" "github.com/golangci/golangci-lint/pkg/lint/linter"
"github.com/golangci/golangci-lint/pkg/result" "github.com/golangci/golangci-lint/pkg/result"
) )
func NewProtoGetter() *goanalysis.Linter { func NewProtoGetter(settings *config.ProtoGetterSettings) *goanalysis.Linter {
var mu sync.Mutex var mu sync.Mutex
var resIssues []goanalysis.Issue var resIssues []goanalysis.Issue
a := protogetter.NewAnalyzer() var cfg protogetter.Config
if settings != nil {
cfg = protogetter.Config{
SkipGeneratedBy: settings.SkipGeneratedBy,
SkipFiles: settings.SkipFiles,
SkipAnyGenerated: settings.SkipAnyGenerated,
}
}
cfg.Mode = protogetter.GolangciLintMode
a := protogetter.NewAnalyzer(&cfg)
a.Run = func(pass *analysis.Pass) (any, error) { a.Run = func(pass *analysis.Pass) (any, error) {
pgIssues := protogetter.Run(pass, protogetter.GolangciLintMode) pgIssues, err := protogetter.Run(pass, &cfg)
if err != nil {
return nil, err
}
issues := make([]goanalysis.Issue, len(pgIssues)) issues := make([]goanalysis.Issue, len(pgIssues))
for i, issue := range pgIssues { for i, issue := range pgIssues {

View File

@ -125,6 +125,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
preallocCfg *config.PreallocSettings preallocCfg *config.PreallocSettings
predeclaredCfg *config.PredeclaredSettings predeclaredCfg *config.PredeclaredSettings
promlinterCfg *config.PromlinterSettings promlinterCfg *config.PromlinterSettings
protogetterCfg *config.ProtoGetterSettings
reassignCfg *config.ReassignSettings reassignCfg *config.ReassignSettings
reviveCfg *config.ReviveSettings reviveCfg *config.ReviveSettings
rowserrcheckCfg *config.RowsErrCheckSettings rowserrcheckCfg *config.RowsErrCheckSettings
@ -208,6 +209,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
preallocCfg = &m.cfg.LintersSettings.Prealloc preallocCfg = &m.cfg.LintersSettings.Prealloc
predeclaredCfg = &m.cfg.LintersSettings.Predeclared predeclaredCfg = &m.cfg.LintersSettings.Predeclared
promlinterCfg = &m.cfg.LintersSettings.Promlinter promlinterCfg = &m.cfg.LintersSettings.Promlinter
protogetterCfg = &m.cfg.LintersSettings.ProtoGetter
reassignCfg = &m.cfg.LintersSettings.Reassign reassignCfg = &m.cfg.LintersSettings.Reassign
reviveCfg = &m.cfg.LintersSettings.Revive reviveCfg = &m.cfg.LintersSettings.Revive
rowserrcheckCfg = &m.cfg.LintersSettings.RowsErrCheck rowserrcheckCfg = &m.cfg.LintersSettings.RowsErrCheck
@ -735,7 +737,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithPresets(linter.PresetStyle). WithPresets(linter.PresetStyle).
WithURL("https://github.com/yeya24/promlinter"), WithURL("https://github.com/yeya24/promlinter"),
linter.NewConfig(golinters.NewProtoGetter()). linter.NewConfig(golinters.NewProtoGetter(protogetterCfg)).
WithSince("v1.55.0"). WithSince("v1.55.0").
WithPresets(linter.PresetBugs). WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis(). WithLoadForGoAnalysis().