Skip to content

Commit 97cb905

Browse files
authored
build(deps): bump github.com/ghostiam/protogetter from 0.2.3 to 0.3.1 (#4167)
1 parent f17fef3 commit 97cb905

File tree

6 files changed

+46
-5
lines changed

6 files changed

+46
-5
lines changed

.golangci.reference.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,22 @@ linters-settings:
14221422
- CamelCase
14231423
- UnitAbbreviations
14241424

1425+
protogetter:
1426+
# Skip files generated by specified generators from the checking.
1427+
# Checks only the file's initial comment, which must follow the format: "// Code generated by <generator-name>".
1428+
# Files generated by protoc-gen-go, protoc-gen-go-grpc, and protoc-gen-grpc-gateway are always excluded automatically.
1429+
# Default: []
1430+
skip-generated-by: ["protoc-gen-go-my-own-generator"]
1431+
# Skip files matching the specified glob pattern from the checking.
1432+
# Default: []
1433+
skip-files:
1434+
- "*.pb.go"
1435+
- "*/vendor/*"
1436+
- "/full/path/to/file.go"
1437+
# Skip any generated files from the checking.
1438+
# Default: false
1439+
skip-any-generated: true
1440+
14251441
reassign:
14261442
# Patterns for global variable names that are checked for reassignment.
14271443
# See https://github.com/curioswitch/go-reassign#usage

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ require (
3636
github.com/fatih/color v1.15.0
3737
github.com/firefart/nonamedreturns v1.0.4
3838
github.com/fzipp/gocyclo v0.6.0
39-
github.com/ghostiam/protogetter v0.2.3
39+
github.com/ghostiam/protogetter v0.3.1
4040
github.com/go-critic/go-critic v0.9.0
4141
github.com/go-xmlfmt/xmlfmt v1.1.2
4242
github.com/gofrs/flock v0.8.1

go.sum

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/config/linters_settings.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ type LintersSettings struct {
231231
Prealloc PreallocSettings
232232
Predeclared PredeclaredSettings
233233
Promlinter PromlinterSettings
234+
ProtoGetter ProtoGetterSettings
234235
Reassign ReassignSettings
235236
Revive ReviveSettings
236237
RowsErrCheck RowsErrCheckSettings
@@ -707,6 +708,12 @@ type PromlinterSettings struct {
707708
DisabledLinters []string `mapstructure:"disabled-linters"`
708709
}
709710

711+
type ProtoGetterSettings struct {
712+
SkipGeneratedBy []string `mapstructure:"skip-generated-by"`
713+
SkipFiles []string `mapstructure:"skip-files"`
714+
SkipAnyGenerated bool `mapstructure:"skip-any-generated"`
715+
}
716+
710717
type ReassignSettings struct {
711718
Patterns []string `mapstructure:"patterns"`
712719
}

pkg/golinters/protogetter.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,32 @@ import (
66
"github.com/ghostiam/protogetter"
77
"golang.org/x/tools/go/analysis"
88

9+
"github.com/golangci/golangci-lint/pkg/config"
910
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
1011
"github.com/golangci/golangci-lint/pkg/lint/linter"
1112
"github.com/golangci/golangci-lint/pkg/result"
1213
)
1314

14-
func NewProtoGetter() *goanalysis.Linter {
15+
func NewProtoGetter(settings *config.ProtoGetterSettings) *goanalysis.Linter {
1516
var mu sync.Mutex
1617
var resIssues []goanalysis.Issue
1718

18-
a := protogetter.NewAnalyzer()
19+
var cfg protogetter.Config
20+
if settings != nil {
21+
cfg = protogetter.Config{
22+
SkipGeneratedBy: settings.SkipGeneratedBy,
23+
SkipFiles: settings.SkipFiles,
24+
SkipAnyGenerated: settings.SkipAnyGenerated,
25+
}
26+
}
27+
cfg.Mode = protogetter.GolangciLintMode
28+
29+
a := protogetter.NewAnalyzer(&cfg)
1930
a.Run = func(pass *analysis.Pass) (any, error) {
20-
pgIssues := protogetter.Run(pass, protogetter.GolangciLintMode)
31+
pgIssues, err := protogetter.Run(pass, &cfg)
32+
if err != nil {
33+
return nil, err
34+
}
2135

2236
issues := make([]goanalysis.Issue, len(pgIssues))
2337
for i, issue := range pgIssues {

pkg/lint/lintersdb/manager.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
125125
preallocCfg *config.PreallocSettings
126126
predeclaredCfg *config.PredeclaredSettings
127127
promlinterCfg *config.PromlinterSettings
128+
protogetterCfg *config.ProtoGetterSettings
128129
reassignCfg *config.ReassignSettings
129130
reviveCfg *config.ReviveSettings
130131
rowserrcheckCfg *config.RowsErrCheckSettings
@@ -208,6 +209,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
208209
preallocCfg = &m.cfg.LintersSettings.Prealloc
209210
predeclaredCfg = &m.cfg.LintersSettings.Predeclared
210211
promlinterCfg = &m.cfg.LintersSettings.Promlinter
212+
protogetterCfg = &m.cfg.LintersSettings.ProtoGetter
211213
reassignCfg = &m.cfg.LintersSettings.Reassign
212214
reviveCfg = &m.cfg.LintersSettings.Revive
213215
rowserrcheckCfg = &m.cfg.LintersSettings.RowsErrCheck
@@ -735,7 +737,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
735737
WithPresets(linter.PresetStyle).
736738
WithURL("https://github.com/yeya24/promlinter"),
737739

738-
linter.NewConfig(golinters.NewProtoGetter()).
740+
linter.NewConfig(golinters.NewProtoGetter(protogetterCfg)).
739741
WithSince("v1.55.0").
740742
WithPresets(linter.PresetBugs).
741743
WithLoadForGoAnalysis().

0 commit comments

Comments
 (0)