Skip to content

Commit 990b43f

Browse files
committed
Merge remote-tracking branch 'golangci/master' into add-gomodguard-linter
2 parents a48cc71 + 3fd6db7 commit 990b43f

File tree

1,639 files changed

+173
-554170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,639 files changed

+173
-554170
lines changed

.github/stale.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# Number of days of inactivity before an issue becomes stale
2-
daysUntilStale: 180
2+
daysUntilStale: 366
33

44
# Number of days of inactivity before a stale issue is closed
5-
daysUntilClose: 14
5+
daysUntilClose: 30
66

77
# Issues with these labels will never be considered stale
88
exemptLabels:
99
- pinned
1010
- security
11+
- bug
12+
- blocked
13+
- protected
14+
- triaged
1115

1216
# Label to use when marking an issue as stale
1317
staleLabel: stale

.golangci.example.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ linters-settings:
126126
gocyclo:
127127
# minimal code complexity to report, 30 by default (but we recommend 10-20)
128128
min-complexity: 10
129+
godot:
130+
# check all top-level comments, not only declarations
131+
check-all: false
129132
godox:
130133
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
131134
# might be left in the code accidentally and should be resolved before merging

Makefile

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
# enable module support across all go commands.
55
export GO111MODULE = on
6-
# opt-in to vendor deps across all go commands.
7-
export GOFLAGS = -mod=vendor
86
# enable consistent Go 1.12/1.13 GOPROXY behavior.
97
export GOPROXY = https://proxy.golang.org
108

@@ -46,25 +44,25 @@ test_linters:
4644

4745
# Maintenance
4846

49-
generate: README.md docs/demo.svg install.sh vendor
47+
generate: README.md docs/demo.svg install.sh
5048
.PHONY: generate
5149

52-
fast_generate: README.md vendor
50+
fast_generate: README.md
5351
.PHONY: fast_generate
5452

5553
maintainer-clean: clean
56-
rm -rf docs/demo.svg README.md install.sh vendor
54+
rm -rf docs/demo.svg README.md install.sh
5755
.PHONY: maintainer-clean
5856

5957
check_generated:
6058
$(MAKE) --always-make generate
61-
git checkout -- vendor/modules.txt go.mod go.sum # can differ between go1.12 and go1.13
59+
git checkout -- go.mod go.sum # can differ between go1.12 and go1.13
6260
git diff --exit-code # check no changes
6361
.PHONY: check_generated
6462

6563
fast_check_generated:
6664
$(MAKE) --always-make fast_generate
67-
git checkout -- vendor/modules.txt go.mod go.sum # can differ between go1.12 and go1.13
65+
git checkout -- go.mod go.sum # can differ between go1.12 and go1.13
6866
git diff --exit-code # check no changes
6967
.PHONY: fast_check_generated
7068

@@ -105,11 +103,3 @@ go.mod: FORCE
105103
go mod tidy
106104
go mod verify
107105
go.sum: go.mod
108-
109-
vendor: go.mod go.sum
110-
go mod vendor
111-
112-
unexport GOFLAGS
113-
vendor_free_build: FORCE
114-
go build -o golangci-lint ./cmd/golangci-lint
115-
.PHONY: vendor_free_build vendor

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ gocognit: Computes and checks the cognitive complexity of functions [fast: true,
217217
goconst: Finds repeated strings that could be replaced by a constant [fast: true, auto-fix: false]
218218
gocritic: The most opinionated Go source code linter [fast: true, auto-fix: false]
219219
gocyclo: Computes and checks the cyclomatic complexity of functions [fast: true, auto-fix: false]
220+
godot: Check if comments end in a period [fast: true, auto-fix: false]
220221
godox: Tool for detection of FIXME, TODO and other comment keywords [fast: true, auto-fix: false]
221222
gofmt: Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification [fast: true, auto-fix: true]
222223
goimports: Goimports does everything that gofmt does. Additionally it checks unused imports [fast: true, auto-fix: true]
@@ -489,7 +490,7 @@ golangci-lint help linters
489490
- [wsl](https://github.com/bombsimon/wsl) - Whitespace Linter - Forces you to use empty lines!
490491
- [goprintffuncname](https://github.com/jirfag/go-printf-func-name) - Checks that printf-like functions are named with `f` at the end
491492
- [gomnd](https://github.com/tommy-muehle/go-mnd) - An analyzer to detect magic numbers.
492-
- [gomodguard](https://github.com/ryancurrah/gomodguard) - Allow and block list linter for direct Go module dependencies.
493+
- [godot](https://github.com/tetafro/godot) - Check if comments end in a period
493494
494495
## Configuration
495496
@@ -511,7 +512,7 @@ Usage:
511512
golangci-lint run [flags]
512513
513514
Flags:
514-
--out-format string Format of output: colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml (default "colored-line-number")
515+
--out-format string Format of output: colored-line-number|line-number|json|tab|checkstyle|code-climate|junit-xml|github-actions (default "colored-line-number")
515516
--print-issued-lines Print lines of code with issue (default true)
516517
--print-linter-name Print linter name in issue line (default true)
517518
--uniq-by-line Make issues output unique by line (default true)
@@ -738,6 +739,9 @@ linters-settings:
738739
gocyclo:
739740
# minimal code complexity to report, 30 by default (but we recommend 10-20)
740741
min-complexity: 10
742+
godot:
743+
# check all top-level comments, not only declarations
744+
check-all: false
741745
godox:
742746
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
743747
# might be left in the code accidentally and should be resolved before merging
@@ -1275,7 +1279,7 @@ Thanks to developers and authors of used linters:
12751279
- [bombsimon](https://github.com/bombsimon)
12761280
- [jirfag](https://github.com/jirfag)
12771281
- [tommy-muehle](https://github.com/tommy-muehle)
1278-
- [ryancurrah](https://github.com/ryancurrah)
1282+
- [tetafro](https://github.com/tetafro)
12791283
12801284
## Changelog
12811285

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ require (
3939
github.com/spf13/pflag v1.0.5
4040
github.com/spf13/viper v1.6.1
4141
github.com/stretchr/testify v1.5.1
42+
github.com/tetafro/godot v0.2.5
4243
github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e
4344
github.com/tommy-muehle/go-mnd v1.3.1-0.20200224220436-e6f9a994e8fa
4445
github.com/ultraware/funlen v0.0.2

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H
270270
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
271271
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
272272
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
273+
github.com/tetafro/godot v0.2.5 h1:7+EYJM/Z4gYZhBFdRrVm6JTj5ZLw/QI1j4RfEOXJviE=
274+
github.com/tetafro/godot v0.2.5/go.mod h1:pT6/T8+h6//L/LwQcFc4C0xpfy1euZwzS1sHdrFCms0=
273275
github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e h1:RumXZ56IrCj4CL+g1b9OL/oH0QnsF976bC8xQFYUD5Q=
274276
github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk=
275277
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=

pkg/commands/run.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ func (e *Executor) createPrinter() (printers.Printer, error) {
396396
p = printers.NewCodeClimate()
397397
case config.OutFormatJunitXML:
398398
p = printers.NewJunitXML()
399+
case config.OutFormatGithubActions:
400+
p = printers.NewGithub()
399401
default:
400402
return nil, fmt.Errorf("unknown output format %s", format)
401403
}

pkg/config/config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const (
1515
OutFormatCheckstyle = "checkstyle"
1616
OutFormatCodeClimate = "code-climate"
1717
OutFormatJunitXML = "junit-xml"
18+
OutFormatGithubActions = "github-actions"
1819
)
1920

2021
var OutFormats = []string{
@@ -25,6 +26,7 @@ var OutFormats = []string{
2526
OutFormatCheckstyle,
2627
OutFormatCodeClimate,
2728
OutFormatJunitXML,
29+
OutFormatGithubActions,
2830
}
2931

3032
type ExcludePattern struct {
@@ -208,6 +210,7 @@ type LintersSettings struct {
208210
Godox GodoxSettings
209211
Dogsled DogsledSettings
210212
Gocognit GocognitSettings
213+
Godot GodotSettings
211214

212215
Custom map[string]CustomLinterSettings
213216
}
@@ -285,6 +288,10 @@ type WSLSettings struct {
285288
ForceCaseTrailingWhitespaceLimit int `mapstructure:"force-case-trailing-whitespace"`
286289
}
287290

291+
type GodotSettings struct {
292+
CheckAll bool `mapstructure:"check-all"`
293+
}
294+
288295
//nolint:gomnd
289296
var defaultLintersSettings = LintersSettings{
290297
Lll: LllSettings{

pkg/golinters/godot.go

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package golinters
2+
3+
import (
4+
"sync"
5+
6+
"github.com/tetafro/godot"
7+
"golang.org/x/tools/go/analysis"
8+
9+
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
10+
"github.com/golangci/golangci-lint/pkg/lint/linter"
11+
"github.com/golangci/golangci-lint/pkg/result"
12+
)
13+
14+
const godotName = "godot"
15+
16+
func NewGodot() *goanalysis.Linter {
17+
var mu sync.Mutex
18+
var resIssues []goanalysis.Issue
19+
20+
analyzer := &analysis.Analyzer{
21+
Name: godotName,
22+
Doc: goanalysis.TheOnlyanalyzerDoc,
23+
}
24+
return goanalysis.NewLinter(
25+
godotName,
26+
"Check if comments end in a period",
27+
[]*analysis.Analyzer{analyzer},
28+
nil,
29+
).WithContextSetter(func(lintCtx *linter.Context) {
30+
cfg := lintCtx.Cfg.LintersSettings.Godot
31+
settings := godot.Settings{CheckAll: cfg.CheckAll}
32+
33+
analyzer.Run = func(pass *analysis.Pass) (interface{}, error) {
34+
var issues []godot.Message
35+
for _, file := range pass.Files {
36+
issues = append(issues, godot.Run(file, pass.Fset, settings)...)
37+
}
38+
39+
if len(issues) == 0 {
40+
return nil, nil
41+
}
42+
43+
res := make([]goanalysis.Issue, len(issues))
44+
for k, i := range issues {
45+
issue := result.Issue{
46+
Pos: i.Pos,
47+
Text: i.Message,
48+
FromLinter: godotName,
49+
Replacement: &result.Replacement{},
50+
}
51+
52+
res[k] = goanalysis.NewIssue(&issue, pass)
53+
}
54+
55+
mu.Lock()
56+
resIssues = append(resIssues, res...)
57+
mu.Unlock()
58+
59+
return nil, nil
60+
}
61+
}).WithIssuesReporter(func(*linter.Context) []goanalysis.Issue {
62+
return resIssues
63+
}).WithLoadMode(goanalysis.LoadModeSyntax)
64+
}

pkg/lint/lintersdb/manager.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
251251
WithPresets(linter.PresetStyle).
252252
WithLoadForGoAnalysis().
253253
WithURL("https://github.com/ryancurrah/gomodguard"),
254+
linter.NewConfig(golinters.NewGodot()).
255+
WithPresets(linter.PresetStyle).
256+
WithURL("https://github.com/tetafro/godot"),
254257
}
255258

256259
isLocalRun := os.Getenv("GOLANGCI_COM_RUN") == ""

0 commit comments

Comments
 (0)