Skip to content

Commit df2e9e2

Browse files
author
Denis Krivak
authored
Update godot to 1.3.0 (#1498)
1 parent 947dae1 commit df2e9e2

File tree

6 files changed

+34
-8
lines changed

6 files changed

+34
-8
lines changed

.golangci.example.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,10 @@ linters-settings:
155155
# minimal code complexity to report, 30 by default (but we recommend 10-20)
156156
min-complexity: 10
157157
godot:
158-
# check all top-level comments, not only declarations
159-
check-all: false
158+
# comments to be checked: `declarations`, `toplevel`, or `all`
159+
scope: declarations
160+
# check that each sentence starts with a capital letter
161+
capital: false
160162
godox:
161163
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
162164
# might be left in the code accidentally and should be resolved before merging

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ require (
5555
github.com/ssgreg/nlreturn/v2 v2.1.0
5656
github.com/stretchr/testify v1.6.1
5757
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2
58-
github.com/tetafro/godot v0.4.9
58+
github.com/tetafro/godot v1.3.0
5959
github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e
6060
github.com/tomarrell/wrapcheck v0.0.0-20200807122107-df9e8bcb914d
6161
github.com/tommy-muehle/go-mnd v1.3.1-0.20200224220436-e6f9a994e8fa

go.sum

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

pkg/config/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ type WSLSettings struct {
334334
}
335335

336336
type GodotSettings struct {
337+
Scope string `mapstructure:"scope"`
338+
Capital bool `mapstructure:"capital"`
339+
340+
// Deprecated: use `Scope` instead
337341
CheckAll bool `mapstructure:"check-all"`
338342
}
339343

pkg/golinters/godot.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,29 @@ func NewGodot() *goanalysis.Linter {
2828
nil,
2929
).WithContextSetter(func(lintCtx *linter.Context) {
3030
cfg := lintCtx.Cfg.LintersSettings.Godot
31-
settings := godot.Settings{CheckAll: cfg.CheckAll}
31+
settings := godot.Settings{
32+
Scope: godot.Scope(cfg.Scope),
33+
Period: true,
34+
Capital: cfg.Capital,
35+
}
36+
37+
// Convert deprecated setting
38+
if cfg.CheckAll { // nolint: staticcheck
39+
settings.Scope = godot.TopLevelScope
40+
}
41+
42+
if settings.Scope == "" {
43+
settings.Scope = godot.DeclScope
44+
}
3245

3346
analyzer.Run = func(pass *analysis.Pass) (interface{}, error) {
3447
var issues []godot.Issue
3548
for _, file := range pass.Files {
36-
issues = append(issues, godot.Run(file, pass.Fset, settings)...)
49+
iss, err := godot.Run(file, pass.Fset, settings)
50+
if err != nil {
51+
return nil, err
52+
}
53+
issues = append(issues, iss...)
3754
}
3855

3956
if len(issues) == 0 {

test/testdata/godot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//args: -Egodot
22
package testdata
33

4-
// Godot checks top-level comments // ERROR "Top level comment should end in a period"
4+
// Godot checks top-level comments // ERROR "Comment should end in a period"
55
func Godot() {
66
// nothing to do here
77
}

0 commit comments

Comments
 (0)