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

godot: add period option #2483

Merged
merged 4 commits into from
Jan 15, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
15 changes: 9 additions & 6 deletions .golangci.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,17 @@ linters-settings:
min-complexity: 10

godot:
# comments to be checked: `declarations`, `toplevel`, or `all`
scope: declarations
# comments to be checked: `declarations`, `toplevel`, or `all` (default: declarations)
scope: toplevel
# list of regexps for excluding particular comment lines from check
exclude:
# example: exclude comments which contain numbers
# - '[0-9]+'
# check that each sentence starts with a capital letter
capital: false
# exclude todo and fixme comments
- "^fixme:"
- "^todo:"
butuzov marked this conversation as resolved.
Show resolved Hide resolved
# don't check that each sentence ends with a period (default: true)
ldez marked this conversation as resolved.
Show resolved Hide resolved
period: false
# check that each sentence starts with a capital letter (default: false)
capital: true

godox:
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
Expand Down
5 changes: 5 additions & 0 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ var defaultLintersSettings = LintersSettings{
Godox: GodoxSettings{
Keywords: []string{},
},
Godot: GodotSettings{
Scope: "declarations",
Period: true,
ldez marked this conversation as resolved.
Show resolved Hide resolved
},
Gofumpt: GofumptSettings{
LangVersion: "",
ExtraRules: false,
Expand Down Expand Up @@ -253,6 +257,7 @@ type GodotSettings struct {
Scope string `mapstructure:"scope"`
Exclude []string `mapstructure:"exclude"`
Capital bool `mapstructure:"capital"`
Period bool `mapstructure:"period"`

// Deprecated: use `Scope` instead
CheckAll bool `mapstructure:"check-all"`
Expand Down
5 changes: 3 additions & 2 deletions pkg/golinters/godot.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ func NewGodot() *goanalysis.Linter {
settings := godot.Settings{
Scope: godot.Scope(cfg.Scope),
Exclude: cfg.Exclude,
Period: true,
Period: cfg.Period,
Capital: cfg.Capital,
}

// Convert deprecated setting
// todo(butuzov): remove on v2 release
if cfg.CheckAll { // nolint:staticcheck
settings.Scope = godot.TopLevelScope
settings.Scope = godot.AllScope
}

if settings.Scope == "" {
Expand Down