Skip to content

Commit c0fdaa0

Browse files
[create-pull-request] automated change
1 parent fb09c37 commit c0fdaa0

File tree

4 files changed

+125
-2
lines changed

4 files changed

+125
-2
lines changed

.golangci.reference.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ linters:
8585
- mirror
8686
- misspell
8787
- mnd
88+
- modernize
8889
- musttag
8990
- nakedret
9091
- nestif
@@ -199,6 +200,7 @@ linters:
199200
- mirror
200201
- misspell
201202
- mnd
203+
- modernize
202204
- musttag
203205
- nakedret
204206
- nestif
@@ -396,6 +398,9 @@ linters:
396398
# Default: []
397399
ignore:
398400
- "0C0C"
401+
# Checks only comments, skip strings.
402+
# Default: false
403+
comments-only: true
399404

400405
embeddedstructfieldcheck:
401406
# Checks that there is an empty space between the embedded fields and regular fields.
@@ -809,6 +814,9 @@ linters:
809814
# Detects multiple imports of the same package under different aliases.
810815
# https://go-critic.com/overview.html#dupimport
811816
- dupImport
817+
# Detects duplicated option function arguments in variadic function calls.
818+
# https://go-critic.com/overview.html#dupoption
819+
- dupOption
812820
# Detects suspicious duplicated sub-expressions.
813821
# https://go-critic.com/overview.html#dupsubexpr
814822
- dupSubExpr
@@ -1043,6 +1051,9 @@ linters:
10431051
# Detects Yoda style expressions and suggests to replace them.
10441052
# https://go-critic.com/overview.html#yodastyleexpr
10451053
- yodaStyleExpr
1054+
# Detects bytes.Repeat with 0 value.
1055+
# https://go-critic.com/overview.html#zerobyterepeat
1056+
- zeroByteRepeat
10461057

10471058
# Enable all checks.
10481059
# Default: false
@@ -2106,6 +2117,47 @@ linters:
21062117
- '^math\.'
21072118
- '^http\.StatusText$'
21082119

2120+
modernize:
2121+
# List of analyzers to disable.
2122+
# By default, all analyzers are enabled.
2123+
disable:
2124+
# Replace interface{} with any.
2125+
- any
2126+
# Replace for-range over b.N with b.Loop.
2127+
- bloop
2128+
# Replace []byte(fmt.Sprintf) with fmt.Appendf.
2129+
- fmtappendf
2130+
# Remove redundant re-declaration of loop variables.
2131+
- forvar
2132+
# Replace explicit loops over maps with calls to maps package.
2133+
- mapsloop
2134+
# Replace if/else statements with calls to min or max.
2135+
- minmax
2136+
# Simplify code by using go1.26's new(expr).
2137+
- newexpr
2138+
# Suggest replacing omitempty with omitzero for struct fields.
2139+
- omitzero
2140+
# Replace 3-clause for loops with for-range over integers.
2141+
- rangeint
2142+
# Replace reflect.TypeOf(x) with TypeFor[T]().
2143+
- reflecttypefor
2144+
# Replace loops with slices.Contains or slices.ContainsFunc.
2145+
- slicescontains
2146+
# Replace sort.Slice with slices.Sort for basic types.
2147+
- slicessort
2148+
# Use iterators instead of Len/At-style APIs.
2149+
- stditerators
2150+
# Replace HasPrefix/TrimPrefix with CutPrefix.
2151+
- stringscutprefix
2152+
# Replace ranging over Split/Fields with SplitSeq/FieldsSeq.
2153+
- stringsseq
2154+
# Replace += with strings.Builder.
2155+
- stringsbuilder
2156+
# Replace context.WithCancel with t.Context in tests.
2157+
- testingcontext
2158+
# Replace wg.Add(1)/go/wg.Done() with wg.Go.
2159+
- waitgroup
2160+
21092161
musttag:
21102162
# A set of custom functions to check in addition to the builtin ones.
21112163
# Default: json, xml, gopkg.in/yaml.v3, BurntSushi/toml, mitchellh/mapstructure, jmoiron/sqlx
@@ -2212,6 +2264,12 @@ linters:
22122264
# Enable/disable optimization of hex formatting.
22132265
# Default: true
22142266
hex-format: false
2267+
# Enable/disable optimization of concat loop.
2268+
# Default: true
2269+
concat-loop: false
2270+
# Optimization of `concat-loop` even with other operations.
2271+
# Default: false
2272+
loop-other-ops: true
22152273

22162274
prealloc:
22172275
# IMPORTANT: we don't recommend using this linter before doing performance profiling.

docs/data/linters_info.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,15 @@
408408
"isSlow": false,
409409
"since": "v1.22.0"
410410
},
411+
{
412+
"name": "modernize",
413+
"desc": "A suite of analyzers that suggest simplifications to Go code, using modern language and library features.",
414+
"loadMode": 8767,
415+
"originalURL": "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize",
416+
"internal": false,
417+
"isSlow": true,
418+
"since": "v2.6.0"
419+
},
411420
{
412421
"name": "gomoddirectives",
413422
"desc": "Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.",

docs/data/thanks.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@
263263
"linters": [
264264
"gofmt",
265265
"goimports",
266+
"modernize",
266267
"govet"
267268
],
268269
"profile": "https://github.com/sponsors/golang",

jsonschema/golangci.jsonschema.json

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"dupBranchBody",
3333
"dupCase",
3434
"dupImport",
35+
"dupOption",
3536
"dupSubExpr",
3637
"dynamicFmtString",
3738
"elseif",
@@ -53,7 +54,6 @@
5354
"importShadow",
5455
"indexAlloc",
5556
"initClause",
56-
"ioutilDeprecated",
5757
"mapKey",
5858
"methodExprCall",
5959
"nestingReduce",
@@ -110,7 +110,8 @@
110110
"weakCond",
111111
"whyNoLint",
112112
"wrapperFunc",
113-
"yodaStyleExpr"
113+
"yodaStyleExpr",
114+
"zeroByteRepeat"
114115
]
115116
},
116117
"gocritic-tags": {
@@ -706,6 +707,28 @@
706707
"header"
707708
]
708709
},
710+
"modernize-analyzers": {
711+
"enum": [
712+
"any",
713+
"bloop",
714+
"fmtappendf",
715+
"forvar",
716+
"mapsloop",
717+
"minmax",
718+
"newexpr",
719+
"omitzero",
720+
"rangeint",
721+
"reflecttypefor",
722+
"slicescontains",
723+
"slicessort",
724+
"stditerators",
725+
"stringscutprefix",
726+
"stringsseq",
727+
"stringsbuilder",
728+
"testingcontext",
729+
"waitgroup"
730+
]
731+
},
709732
"wsl-checks": {
710733
"enum": [
711734
"assign",
@@ -835,6 +858,7 @@
835858
"mirror",
836859
"misspell",
837860
"mnd",
861+
"modernize",
838862
"musttag",
839863
"nakedret",
840864
"nestif",
@@ -921,6 +945,11 @@
921945
"type": "string",
922946
"examples": ["0C0C"]
923947
}
948+
},
949+
"comments-only": {
950+
"description": "Checks only comments, skip strings.",
951+
"type": "boolean",
952+
"default": false
924953
}
925954
}
926955
},
@@ -2829,6 +2858,19 @@
28292858
}
28302859
}
28312860
},
2861+
"modernizeSettings": {
2862+
"type": "object",
2863+
"additionalProperties": false,
2864+
"properties": {
2865+
"disable": {
2866+
"description": "List of analyzers to disable.",
2867+
"type": "array",
2868+
"items": {
2869+
"$ref": "#/definitions/modernize-analyzers"
2870+
}
2871+
}
2872+
}
2873+
},
28322874
"nolintlintSettings": {
28332875
"type": "object",
28342876
"additionalProperties": false,
@@ -2968,6 +3010,16 @@
29683010
"description": "Enable/disable optimization of hex formatting.",
29693011
"type": "boolean",
29703012
"default": true
3013+
},
3014+
"concat-loop": {
3015+
"description": "Enable/disable optimization of concat loop.",
3016+
"type": "boolean",
3017+
"default": true
3018+
},
3019+
"loop-other-ops": {
3020+
"description": "Optimization of `concat-loop` even with other operations.",
3021+
"type": "boolean",
3022+
"default": false
29713023
}
29723024
}
29733025
},
@@ -4747,6 +4799,9 @@
47474799
"mnd": {
47484800
"$ref": "#/definitions/settings/definitions/mndSettings"
47494801
},
4802+
"modernize": {
4803+
"$ref": "#/definitions/settings/definitions/modernizeSettings"
4804+
},
47504805
"nolintlint":{
47514806
"$ref": "#/definitions/settings/definitions/nolintlintSettings"
47524807
},

0 commit comments

Comments
 (0)