Skip to content

Commit b2901be

Browse files
Mateus Oliveiraldez
Mateus Oliveira
andauthored
docs: improve .golangci.reference.yml defaults (#4271)
Co-authored-by: Fernandez Ludovic <[email protected]>
1 parent 2060066 commit b2901be

File tree

3 files changed

+30
-22
lines changed

3 files changed

+30
-22
lines changed

.golangci.reference.yml

+22-15
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
# Options for analysis running.
88
run:
9-
# The default concurrency value is the number of available CPU.
9+
# Number of CPUs to use when running golangci-lint.
10+
# Default: the number of logical CPUs in the machine
1011
concurrency: 4
1112

1213
# Timeout for analysis, e.g. 30s, 5m.
@@ -22,16 +23,16 @@ run:
2223
tests: false
2324

2425
# List of build tags, all linters use it.
25-
# Default: [].
26+
# Default: []
2627
build-tags:
2728
- mytag
2829

2930
# Which dirs to skip: issues from them won't be reported.
3031
# Can use regexp here: `generated.*`, regexp is applied on full path,
3132
# including the path prefix if one is set.
32-
# Default value is empty list,
33-
# but default dirs are skipped independently of this option's value (see skip-dirs-use-default).
33+
# Default dirs are skipped independently of this option's value (see skip-dirs-use-default).
3434
# "/" will be replaced by current OS file path separator to properly work on Windows.
35+
# Default: []
3536
skip-dirs:
3637
- src/external_libs
3738
- autogenerated_by_my_lib
@@ -42,16 +43,16 @@ run:
4243
skip-dirs-use-default: false
4344

4445
# Which files to skip: they will be analyzed, but issues from them won't be reported.
45-
# Default value is empty list,
46-
# but there is no need to include all autogenerated files,
46+
# There is no need to include all autogenerated files,
4747
# we confidently recognize autogenerated files.
48-
# If it's not please let us know.
48+
# If it's not, please let us know.
4949
# "/" will be replaced by current OS file path separator to properly work on Windows.
50+
# Default: []
5051
skip-files:
5152
- ".*\\.my\\.go$"
5253
- lib/bad.go
5354

54-
# If set we pass it to "go list -mod={option}". From "go help modules":
55+
# If set, we pass it to "go list -mod={option}". From "go help modules":
5556
# If invoked with -mod=readonly, the go command is disallowed from the implicit
5657
# automatic updating of go.mod described above. Instead, it fails when any changes
5758
# to go.mod are needed. This setting is most useful to check that go.mod does
@@ -61,11 +62,12 @@ run:
6162
# the dependency descriptions in go.mod.
6263
#
6364
# Allowed values: readonly|vendor|mod
64-
# By default, it isn't set.
65+
# Default: ""
6566
modules-download-mode: readonly
6667

6768
# Allow multiple parallel golangci-lint instances running.
68-
# If false (default) - golangci-lint acquires file lock on start.
69+
# If false, golangci-lint acquires file lock on start.
70+
# Default: false
6971
allow-parallel-runners: false
7072

7173
# Define the Go version limit.
@@ -99,11 +101,12 @@ output:
99101
uniq-by-line: false
100102

101103
# Add a prefix to the output file references.
102-
# Default is no prefix.
104+
# Default: ""
103105
path-prefix: ""
104106

105107
# Sort results by: filepath, line and column.
106-
sort-results: false
108+
# Default: false
109+
sort-results: true
107110

108111

109112
# All available settings of specific linters.
@@ -2564,6 +2567,7 @@ linters:
25642567

25652568
# Enable presets.
25662569
# https://golangci-lint.run/usage/linters
2570+
# Default: []
25672571
presets:
25682572
- bugs
25692573
- comment
@@ -2631,7 +2635,7 @@ issues:
26312635
# Independently of option `exclude` we use default exclude patterns,
26322636
# it can be disabled by this option.
26332637
# To list all excluded by default patterns execute `golangci-lint run --help`.
2634-
# Default: true.
2638+
# Default: true
26352639
exclude-use-default: false
26362640

26372641
# If set to true exclude and exclude-rules regular expressions become case-sensitive.
@@ -2674,16 +2678,19 @@ issues:
26742678
# It's not practical to fix all existing issues at the moment of integration:
26752679
# much better don't allow issues in new code.
26762680
#
2677-
# Default: false.
2681+
# Default: false
26782682
new: true
26792683

26802684
# Show only new issues created after git revision `REV`.
2685+
# Default: ""
26812686
new-from-rev: HEAD
26822687

26832688
# Show only new issues created in git patch with set file path.
2689+
# Default: ""
26842690
new-from-patch: path/to/patch/file
26852691

26862692
# Fix found issues (if it's supported by the linter).
2693+
# Default: false
26872694
fix: true
26882695

26892696

@@ -2698,7 +2705,7 @@ severity:
26982705
# - GitHub: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
26992706
# - TeamCity: https://www.jetbrains.com/help/teamcity/service-messages.html#Inspection+Instance
27002707
#
2701-
# Default value is an empty string.
2708+
# Default: ""
27022709
default-severity: error
27032710

27042711
# If set to true `severity-rules` regular expressions become case-sensitive.

pkg/commands/root.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func formatMemory(memBytes uint64) string {
119119

120120
func getDefaultConcurrency() int {
121121
if os.Getenv(envHelpRun) == "1" {
122-
// Make stable concurrency for README help generating builds.
122+
// Make stable concurrency for generating help documentation.
123123
const prettyConcurrency = 8
124124
return prettyConcurrency
125125
}
@@ -165,7 +165,8 @@ func initRootFlagSet(fs *pflag.FlagSet, cfg *config.Config, needVersionOption bo
165165
fs.StringVar(&cfg.Run.CPUProfilePath, "cpu-profile-path", "", wh("Path to CPU profile output file"))
166166
fs.StringVar(&cfg.Run.MemProfilePath, "mem-profile-path", "", wh("Path to memory profile output file"))
167167
fs.StringVar(&cfg.Run.TracePath, "trace-path", "", wh("Path to trace output file"))
168-
fs.IntVarP(&cfg.Run.Concurrency, "concurrency", "j", getDefaultConcurrency(), wh("Concurrency (default NumCPU)"))
168+
fs.IntVarP(&cfg.Run.Concurrency, "concurrency", "j", getDefaultConcurrency(),
169+
wh("Number of CPUs to use (Default: number of logical CPUs)"))
169170
if needVersionOption {
170171
fs.BoolVar(&cfg.Run.PrintVersion, "version", false, wh("Print version"))
171172
}

pkg/commands/run.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const (
3535
)
3636

3737
func getDefaultIssueExcludeHelp() string {
38-
parts := []string{"Use or not use default excludes:"}
38+
parts := []string{color.GreenString("Use or not use default excludes:")}
3939
for _, ep := range config.DefaultExcludePatterns {
4040
parts = append(parts,
4141
fmt.Sprintf(" # %s %s: %s", ep.ID, ep.Linter, ep.Why),
@@ -47,7 +47,7 @@ func getDefaultIssueExcludeHelp() string {
4747
}
4848

4949
func getDefaultDirectoryExcludeHelp() string {
50-
parts := []string{"Use or not use default excluded directories:"}
50+
parts := []string{color.GreenString("Use or not use default excluded directories:")}
5151
for _, dir := range packages.StdExcludeDirRegexps {
5252
parts = append(parts, fmt.Sprintf(" - %s", color.YellowString(dir)))
5353
}
@@ -98,7 +98,7 @@ func initFlagSet(fs *pflag.FlagSet, cfg *config.Config, m *lintersdb.Manager, is
9898
// Run config
9999
rc := &cfg.Run
100100
fs.StringVar(&rc.ModulesDownloadMode, "modules-download-mode", "",
101-
"Modules download mode. If not empty, passed as -mod=<mode> to go tools")
101+
wh("Modules download mode. If not empty, passed as -mod=<mode> to go tools"))
102102
fs.IntVar(&rc.ExitCodeIfIssuesFound, "issues-exit-code",
103103
exitcodes.IssuesFound, wh("Exit code when issues were found"))
104104
fs.StringVar(&rc.Go, "go", "", wh("Targeted Go version"))
@@ -203,7 +203,7 @@ func initFlagSet(fs *pflag.FlagSet, cfg *config.Config, m *lintersdb.Manager, is
203203

204204
fs.BoolVar(&lc.DisableAll, "disable-all", false, wh("Disable all linters"))
205205
fs.StringSliceVarP(&lc.Presets, "presets", "p", nil,
206-
wh(fmt.Sprintf("Enable presets (%s) of linters. Run 'golangci-lint linters' to see "+
206+
wh(fmt.Sprintf("Enable presets (%s) of linters. Run 'golangci-lint help linters' to see "+
207207
"them. This option implies option --disable-all", strings.Join(m.AllPresets(), "|"))))
208208
fs.BoolVar(&lc.Fast, "fast", false, wh("Run only fast linters from enabled linters set (first run won't be fast)"))
209209

@@ -232,7 +232,7 @@ func initFlagSet(fs *pflag.FlagSet, cfg *config.Config, m *lintersdb.Manager, is
232232
wh("Show only new issues created in git patch with file path `PATH`"))
233233
fs.BoolVar(&ic.WholeFiles, "whole-files", false,
234234
wh("Show issues in any part of update files (requires new-from-rev or new-from-patch)"))
235-
fs.BoolVar(&ic.NeedFix, "fix", false, "Fix found issues (if it's supported by the linter)")
235+
fs.BoolVar(&ic.NeedFix, "fix", false, wh("Fix found issues (if it's supported by the linter)"))
236236
}
237237

238238
func (e *Executor) initRunConfiguration(cmd *cobra.Command) {

0 commit comments

Comments
 (0)