Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .golangci.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,22 @@ linters-settings:
- CamelCase
- 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:
# Patterns for global variable names that are checked for reassignment.
# See https://github.com/curioswitch/go-reassign#usage
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require (
github.com/fatih/color v1.15.0
github.com/firefart/nonamedreturns v1.0.4
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-xmlfmt/xmlfmt v1.1.2
github.com/gofrs/flock v0.8.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum

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

7 changes: 7 additions & 0 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ type LintersSettings struct {
Prealloc PreallocSettings
Predeclared PredeclaredSettings
Promlinter PromlinterSettings
ProtoGetter ProtoGetterSettings
Reassign ReassignSettings
Revive ReviveSettings
RowsErrCheck RowsErrCheckSettings
Expand Down Expand Up @@ -696,6 +697,12 @@ type PromlinterSettings struct {
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 {
Patterns []string `mapstructure:"patterns"`
}
Expand Down
20 changes: 17 additions & 3 deletions pkg/golinters/protogetter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,32 @@ import (
"github.com/ghostiam/protogetter"
"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/lint/linter"
"github.com/golangci/golangci-lint/pkg/result"
)

func NewProtoGetter() *goanalysis.Linter {
func NewProtoGetter(settings *config.ProtoGetterSettings) *goanalysis.Linter {
var mu sync.Mutex
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) {
pgIssues := protogetter.Run(pass, protogetter.GolangciLintMode)
pgIssues, err := protogetter.Run(pass, &cfg)
if err != nil {
return nil, err
}

issues := make([]goanalysis.Issue, len(pgIssues))
for i, issue := range pgIssues {
Expand Down
4 changes: 3 additions & 1 deletion pkg/lint/lintersdb/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
preallocCfg *config.PreallocSettings
predeclaredCfg *config.PredeclaredSettings
promlinterCfg *config.PromlinterSettings
protogetterCfg *config.ProtoGetterSettings
reassignCfg *config.ReassignSettings
reviveCfg *config.ReviveSettings
rowserrcheckCfg *config.RowsErrCheckSettings
Expand Down Expand Up @@ -206,6 +207,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
parallelTestCfg = &m.cfg.LintersSettings.ParallelTest
predeclaredCfg = &m.cfg.LintersSettings.Predeclared
promlinterCfg = &m.cfg.LintersSettings.Promlinter
protogetterCfg = &m.cfg.LintersSettings.ProtoGetter
reassignCfg = &m.cfg.LintersSettings.Reassign
reviveCfg = &m.cfg.LintersSettings.Revive
rowserrcheckCfg = &m.cfg.LintersSettings.RowsErrCheck
Expand Down Expand Up @@ -733,7 +735,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithPresets(linter.PresetStyle).
WithURL("https://github.com/yeya24/promlinter"),

linter.NewConfig(golinters.NewProtoGetter()).
linter.NewConfig(golinters.NewProtoGetter(protogetterCfg)).
WithSince("v1.55.0").
WithPresets(linter.PresetBugs).
WithLoadForGoAnalysis().
Expand Down
Loading