diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index e52cb21a8e07..7bacc9d84b63 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -10,7 +10,7 @@ linters: # Disable all linters. # Default: false disable-all: true - # Enable specific linter + # Enable specific linter. # https://golangci-lint.run/usage/linters/#enabled-by-default enable: - asasalint @@ -276,6 +276,99 @@ linters: fast: true +formatters: + # Enable specific formatter. + # Default: [] (uses standard Go formatting) + enable: + - gci + - gofmt + - gofumpt + - goimports + - golines + + # Formatters settings. + settings: + gci: + # Section configuration to compare against. + # Section names are case-insensitive and may contain parameters in (). + # The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`, + # If `custom-order` is `true`, it follows the order of `sections` option. + # Default: ["standard", "default"] + sections: + - standard # Standard section: captures all standard packages. + - default # Default section: contains all imports that could not be matched to another section type. + - prefix(github.com/org/project) # Custom section: groups all imports with the specified Prefix. + - blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled. + - dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled. + - alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled. + - localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled. + + # Checks that no inline comments are present. + # Default: false + no-inline-comments: true + + # Checks that no prefix comments (comment lines above an import) are present. + # Default: false + no-prefix-comments: true + + # Skip generated files. + # Default: true + skip-generated: false + + # Enable custom order of sections. + # If `true`, make the section order the same as the order of `sections`. + # Default: false + custom-order: true + + # Drops lexical ordering for custom sections. + # Default: false + no-lex-order: true + + gofmt: + # Simplify code: gofmt with `-s` option. + # Default: true + simplify: false + # Apply the rewrite rules to the source before reformatting. + # https://pkg.go.dev/cmd/gofmt + # Default: [] + rewrite-rules: + - pattern: 'interface{}' + replacement: 'any' + - pattern: 'a[b:len(a)]' + replacement: 'a[b:]' + + gofumpt: + # Module path which contains the source code being formatted. + # Default: "" + module-path: github.com/org/project + + # Choose whether to use the extra rules. + # Default: false + extra-rules: true + + goimports: + # A comma-separated list of prefixes, which, if set, checks import paths + # with the given prefixes are grouped after 3rd-party packages. + # Default: "" + local-prefixes: github.com/org/project + + golines: + # Target maximum line length. + # Default: 100 + max-len: 200 + # Length of a tabulation. + # Default: 4 + tab-len: 8 + # Shorten single-line comments. + # Default: false + shorten-comments: true + # Default: true + reformat-tags: false + # Split chained methods on the dots as opposed to the arguments. + # Default: true + chain-split-dots: false + + # All available settings of specific linters. linters-settings: asasalint: @@ -596,42 +689,6 @@ linters-settings: # Default false ignore-comments: true - gci: - # Section configuration to compare against. - # Section names are case-insensitive and may contain parameters in (). - # The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`, - # If `custom-order` is `true`, it follows the order of `sections` option. - # Default: ["standard", "default"] - sections: - - standard # Standard section: captures all standard packages. - - default # Default section: contains all imports that could not be matched to another section type. - - prefix(github.com/org/project) # Custom section: groups all imports with the specified Prefix. - - blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled. - - dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled. - - alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled. - - localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled. - - # Checks that no inline Comments are present. - # Default: false - no-inline-comments: true - - # Checks that no prefix Comments(comment lines above an import) are present. - # Default: false - no-prefix-comments: true - - # Skip generated files. - # Default: true - skip-generated: false - - # Enable custom order of sections. - # If `true`, make the section order the same as the order of `sections`. - # Default: false - custom-order: true - - # Drops lexical ordering for custom sections. - # Default: false - no-lex-order: true - ginkgolinter: # Suppress the wrong length assertion warning. # Default: false @@ -1313,28 +1370,6 @@ linters-settings: - OPTIMIZE # marks code that should be optimized before merging - HACK # marks hack-around that should be removed before merging - gofmt: - # Simplify code: gofmt with `-s` option. - # Default: true - simplify: false - # Apply the rewrite rules to the source before reformatting. - # https://pkg.go.dev/cmd/gofmt - # Default: [] - rewrite-rules: - - pattern: 'interface{}' - replacement: 'any' - - pattern: 'a[b:len(a)]' - replacement: 'a[b:]' - - gofumpt: - # Module path which contains the source code being formatted. - # Default: "" - module-path: github.com/org/project - - # Choose whether to use the extra rules. - # Default: false - extra-rules: true - goheader: # Supports two types 'const` and `regexp`. # Values can be used recursively. @@ -1374,12 +1409,6 @@ linters-settings: # Default: "" template-path: /path/to/my/template.tmpl - goimports: - # A comma-separated list of prefixes, which, if set, checks import paths - # with the given prefixes are grouped after 3rd-party packages. - # Default: "" - local-prefixes: github.com/org/project - gomoddirectives: # Allow local `replace` directives. # Default: false diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 76f02d15c137..60f55f6733ee 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -324,9 +324,40 @@ "header" ] }, - "linters": { - "$comment": "anyOf with enum is used to allow auto completion of non-custom linters", - "description": "Linters usable.", + "relative-path-modes": { + "enum": [ + "gomod", + "gitroot", + "cfg", + "wd" + ] + }, + "simple-format": { + "type": "object", + "additionalProperties": false, + "properties": { + "path": { + "$ref": "#/definitions/formats-path", + "default": "stdout" + } + } + }, + "formats-path" : { + "anyOf": [ + { + "enum": [ + "stdout", + "stderr" + ] + }, + { + "type": "string" + } + ] + }, + "linter-names": { + "$comment": "anyOf with enum is used to allow auto-completion of non-custom linters", + "description": "Usable linter names.", "anyOf": [ { "enum": [ @@ -356,7 +387,6 @@ "forbidigo", "forcetypeassert", "funlen", - "gci", "ginkgolinter", "gocheckcompilerdirectives", "gochecknoglobals", @@ -368,12 +398,8 @@ "gocyclo", "godot", "godox", - "golines", "err113", - "gofmt", - "gofumpt", "goheader", - "goimports", "gomoddirectives", "gomodguard", "goprintffuncname", @@ -447,223 +473,19 @@ } ] }, - "relative-path-modes": { + "formatter-names": { + "description": "Usable formatter names.", "enum": [ - "gomod", - "gitroot", - "cfg", - "wd" - ] - }, - "simple-format": { - "type": "object", - "additionalProperties": false, - "properties": { - "path": { - "$ref": "#/definitions/formats-path", - "default": "stdout" - } - } - }, - "formats-path" : { - "anyOf": [ - { - "enum": [ - "stdout", - "stderr" - ] - }, - { - "type": "string" - } + "gci", + "gofmt", + "gofumpt", + "goimports", + "golines" ] - } - }, - "type": "object", - "additionalProperties": false, - "required": ["version"], - "properties": { - "version": { - "type": "string", - "default": "2" - }, - "run": { - "description": "Options for analysis running,", - "type": "object", - "additionalProperties": false, - "properties": { - "concurrency": { - "description": "Number of concurrent runners. Defaults to the number of available CPU cores.", - "type": "integer", - "minimum": 0, - "examples": [4] - }, - "timeout": { - "description": "Timeout for the analysis.", - "type": "string", - "pattern": "^\\d*[sm]$", - "default": "1m", - "examples": ["30s", "5m"] - }, - "issues-exit-code": { - "description": "Exit code when at least one issue was found.", - "type": "integer", - "default": 1 - }, - "tests": { - "description": "Enable inclusion of test files.", - "type": "boolean", - "default": true - }, - "build-tags": { - "description": "List of build tags to pass to all linters.", - "type": "array", - "items": { - "type": "string" - }, - "default": [], - "examples": [["mytag"]] - }, - "modules-download-mode": { - "description": "Option to pass to \"go list -mod={option}\".\nSee \"go help modules\" for more information.", - "enum": ["mod", "readonly", "vendor"] - }, - "allow-parallel-runners": { - "description": "Allow multiple parallel golangci-lint instances running. If disabled, golangci-lint acquires file lock on start.", - "type": "boolean", - "default": false - }, - "allow-serial-runners": { - "description": "Allow multiple golangci-lint instances running, but serialize them around a lock.", - "type": "boolean", - "default": false - }, - "go": { - "description": "Targeted Go version.", - "type": "string", - "default": "1.17" - }, - "relative-path-mode": { - "description": "The mode used to evaluate relative paths.", - "type": "string", - "$ref": "#/definitions/relative-path-modes", - "default": "wd" - } - } - }, - "output": { - "description": "Output configuration options.", - "type": "object", - "additionalProperties": false, - "properties": { - "formats": { - "description": "Output formats to use.", - "type": "object", - "additionalProperties": false, - "properties": { - "text": { - "type": "object", - "additionalProperties": false, - "properties": { - "path": { - "$ref": "#/definitions/formats-path", - "default": "stdout" - }, - "print-linter-name": { - "type": "boolean", - "default": true - }, - "print-issued-lines": { - "type": "boolean", - "default": true - }, - "colors": { - "type": "boolean", - "default": true - } - } - }, - "json": { - "$ref": "#/definitions/simple-format" - }, - "tab": { - "type": "object", - "additionalProperties": false, - "properties": { - "path": { - "$ref": "#/definitions/formats-path", - "default": "stdout" - }, - "print-linter-name": { - "type": "boolean", - "default": true - }, - "colors": { - "type": "boolean", - "default": true - } - } - }, - "html": { - "$ref": "#/definitions/simple-format" - }, - "checkstyle": { - "$ref": "#/definitions/simple-format" - }, - "code-climate": { - "$ref": "#/definitions/simple-format" - }, - "junit-xml": { - "type": "object", - "additionalProperties": false, - "properties": { - "path": { - "$ref": "#/definitions/formats-path", - "default": "stdout" - }, - "extended": { - "type": "boolean", - "default": true - } - } - }, - "teamcity": { - "$ref": "#/definitions/simple-format" - }, - "sarif": { - "$ref": "#/definitions/simple-format" - } - } - }, - "path-prefix": { - "description": "Add a prefix to the output file references.", - "type": "string", - "default": "" - }, - "show-stats": { - "description": "Show statistics per linter.", - "type": "boolean", - "default": false - }, - "sort-order": { - "type": "array", - "items": { - "enum": ["linter", "severity", "file"] - } - }, - "sort-results": { - "description": "Sort results by: filepath, line and column.", - "type": "boolean", - "default": true - } - } }, - "linters-settings": { - "description": "All available settings of specific linters.", - "type": "object", - "additionalProperties": false, - "properties": { - "dupword": { + "settings": { + "definitions": { + "dupwordSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -687,7 +509,7 @@ } } }, - "asasalint": { + "asasalintSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -712,7 +534,7 @@ } } }, - "bidichk": { + "bidichkSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -763,7 +585,7 @@ } } }, - "cyclop": { + "cyclopSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -786,7 +608,7 @@ } } }, - "decorder": { + "decorderSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -834,7 +656,7 @@ } } }, - "depguard": { + "depguardSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -893,7 +715,7 @@ } } }, - "dogsled": { + "dogsledSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -905,7 +727,7 @@ } } }, - "dupl": { + "duplSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -917,7 +739,7 @@ } } }, - "errcheck": { + "errcheckSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -946,7 +768,7 @@ } } }, - "errchkjson": { + "errchkjsonSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -961,7 +783,7 @@ } } }, - "errorlint": { + "errorlintSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1017,7 +839,7 @@ } } }, - "exhaustive": { + "exhaustiveSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1070,7 +892,7 @@ } } }, - "exhaustruct": { + "exhaustructSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1092,7 +914,7 @@ } } }, - "fatcontext": { + "fatcontextSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1103,7 +925,7 @@ } } }, - "forbidigo": { + "forbidigoSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1149,7 +971,7 @@ } } }, - "funlen": { + "funlenSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1170,7 +992,7 @@ } } }, - "gci": { + "gciSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1223,7 +1045,7 @@ } } }, - "ginkgolinter": { + "ginkgolinterSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1289,7 +1111,7 @@ } } }, - "gochecksumtype": { + "gochecksumtypeSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1305,7 +1127,7 @@ } } }, - "gocognit": { + "gocognitSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1316,7 +1138,7 @@ } } }, - "goconst": { + "goconstSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1366,7 +1188,7 @@ } } }, - "gocritic": { + "gocriticSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1565,7 +1387,7 @@ } } }, - "gocyclo": { + "gocycloSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1576,7 +1398,7 @@ } } }, - "godot": { + "godotSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1609,7 +1431,7 @@ } } }, - "godox": { + "godoxSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1623,7 +1445,7 @@ } } }, - "gofmt": { + "gofmtSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1650,7 +1472,7 @@ } } }, - "golines": { + "golinesSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1676,7 +1498,7 @@ } } }, - "interfacebloat": { + "interfacebloatSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1686,7 +1508,7 @@ } } }, - "gofumpt": { + "gofumptSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1701,7 +1523,7 @@ } } }, - "goheader": { + "goheaderSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1761,7 +1583,7 @@ { "required": ["template-path"] } ] }, - "goimports": { + "goimportsSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1772,7 +1594,7 @@ } } }, - "gomoddirectives": { + "gomoddirectivesSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1824,7 +1646,7 @@ } } }, - "gomodguard": { + "gomodguardSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1914,7 +1736,7 @@ } } }, - "gosimple": { + "gosimpleSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1933,7 +1755,7 @@ } } }, - "gosec": { + "gosecSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -1980,7 +1802,7 @@ } } }, - "gosmopolitan": { + "gosmopolitanSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2010,7 +1832,7 @@ } } }, - "govet": { + "govetSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2053,7 +1875,7 @@ } } }, - "grouper": { + "grouperSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2091,7 +1913,7 @@ } } }, - "iface": { + "ifaceSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2122,7 +1944,7 @@ } } }, - "importas": { + "importasSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2157,7 +1979,7 @@ } } }, - "inamedparam": { + "inamedparamSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2168,7 +1990,7 @@ } } }, - "ireturn": { + "ireturnSettings": { "type": "object", "additionalProperties": false, "description": "Use either `reject` or `allow` properties for interfaces matching.", @@ -2216,7 +2038,7 @@ } ] }, - "lll": { + "lllSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2234,7 +2056,7 @@ } } }, - "maintidx": { + "maintidxSettings": { "description": "Maintainability index https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022", "type": "object", "additionalProperties": false, @@ -2246,7 +2068,7 @@ } } }, - "makezero": { + "makezeroSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2257,7 +2079,7 @@ } } }, - "loggercheck": { + "loggercheckSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2305,7 +2127,7 @@ } } }, - "misspell": { + "misspellSettings": { "description": "Correct spellings using locale preferences for US or UK. Default is to use a neutral variety of English.", "type": "object", "additionalProperties": false, @@ -2343,7 +2165,7 @@ } } }, - "musttag": { + "musttagSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2367,7 +2189,7 @@ } } }, - "nakedret": { + "nakedretSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2379,7 +2201,7 @@ } } }, - "nestif": { + "nestifSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2390,7 +2212,7 @@ } } }, - "nilnil": { + "nilnilSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2409,7 +2231,7 @@ } } }, - "nlreturn": { + "nlreturnSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2421,7 +2243,7 @@ } } }, - "mnd": { + "mndSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2465,7 +2287,7 @@ } } }, - "nolintlint": { + "nolintlintSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2478,7 +2300,7 @@ "description": "Exclude these linters from requiring an explanation.", "type": "array", "items": { - "$ref": "#/definitions/linters" + "$ref": "#/definitions/linter-names" }, "default": [] }, @@ -2494,7 +2316,7 @@ } } }, - "reassign": { + "reassignSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2506,7 +2328,7 @@ } } }, - "recvcheck": { + "recvcheckSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2524,7 +2346,7 @@ } } }, - "nonamedreturns": { + "nonamedreturnsSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2535,7 +2357,7 @@ } } }, - "paralleltest": { + "paralleltestSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2551,7 +2373,7 @@ } } }, - "perfsprint": { + "perfsprintSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2607,7 +2429,7 @@ } } }, - "prealloc": { + "preallocSettings": { "description": "We do not recommend using this linter before doing performance profiling.\nFor most programs usage of `prealloc` will be premature optimization.", "type": "object", "additionalProperties": false, @@ -2629,7 +2451,7 @@ } } }, - "predeclared": { + "predeclaredSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2644,7 +2466,7 @@ } } }, - "promlinter": { + "promlinterSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2666,7 +2488,7 @@ } } }, - "protogetter": { + "protogetterSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2696,7 +2518,7 @@ } } }, - "revive": { + "reviveSettings": { "type": "object", "additionalProperties": false, "examples": [ @@ -2773,7 +2595,7 @@ } } }, - "rowserrcheck": { + "rowserrcheckSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2787,7 +2609,7 @@ } } }, - "sloglint": { + "sloglintSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2844,7 +2666,7 @@ } } }, - "spancheck": { + "spancheckSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2871,7 +2693,7 @@ } } }, - "staticcheck": { + "staticcheckSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -2890,7 +2712,7 @@ } } }, - "stylecheck": { + "stylecheckSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -3048,7 +2870,7 @@ } } }, - "tagalign": { + "tagalignSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -3088,7 +2910,7 @@ } } }, - "tagliatelle": { + "tagliatelleSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -3220,7 +3042,7 @@ } } }, - "tenv": { + "tenvSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -3231,7 +3053,7 @@ } } }, - "testifylint": { + "testifylintSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -3408,7 +3230,7 @@ } } }, - "testpackage": { + "testpackageSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -3428,7 +3250,7 @@ } } }, - "thelper": { + "thelperSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -3518,7 +3340,7 @@ } } }, - "usestdlibvars": { + "usestdlibvarsSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -3574,7 +3396,7 @@ } } }, - "usetesting": { + "usetestingSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -3608,7 +3430,7 @@ } } }, - "unconvert": { + "unconvertSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -3622,7 +3444,7 @@ } } }, - "unparam": { + "unparamSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -3633,7 +3455,7 @@ } } }, - "unused": { + "unusedSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -3669,7 +3491,7 @@ } } }, - "varnamelen": { + "varnamelenSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -3733,7 +3555,7 @@ } } }, - "whitespace": { + "whitespaceSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -3749,7 +3571,7 @@ } } }, - "wrapcheck": { + "wrapcheckSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -3807,7 +3629,7 @@ } } }, - "wsl": { + "wslSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -3885,7 +3707,7 @@ } } }, - "copyloopvar": { + "copyloopvarSettings": { "type": "object", "additionalProperties": false, "properties": { @@ -3895,7 +3717,7 @@ } } }, - "custom": { + "customSettings": { "description": "The custom section can be used to define linter plugins to be loaded at runtime. See README of golangci-lint for more information.\nEach custom linter should have a unique name.", "type": "object", "patternProperties": { @@ -3930,7 +3752,8 @@ { "properties": { "type": {"enum": ["module"] } - } + }, + "required": ["type"] }, { "required": ["path"] @@ -3940,6 +3763,436 @@ } } } + } + }, + "type": "object", + "additionalProperties": false, + "required": ["version"], + "properties": { + "version": { + "type": "string", + "default": "2" + }, + "run": { + "description": "Options for analysis running,", + "type": "object", + "additionalProperties": false, + "properties": { + "concurrency": { + "description": "Number of concurrent runners. Defaults to the number of available CPU cores.", + "type": "integer", + "minimum": 0, + "examples": [4] + }, + "timeout": { + "description": "Timeout for the analysis.", + "type": "string", + "pattern": "^\\d*[sm]$", + "default": "1m", + "examples": ["30s", "5m"] + }, + "issues-exit-code": { + "description": "Exit code when at least one issue was found.", + "type": "integer", + "default": 1 + }, + "tests": { + "description": "Enable inclusion of test files.", + "type": "boolean", + "default": true + }, + "build-tags": { + "description": "List of build tags to pass to all linters.", + "type": "array", + "items": { + "type": "string" + }, + "default": [], + "examples": [["mytag"]] + }, + "modules-download-mode": { + "description": "Option to pass to \"go list -mod={option}\".\nSee \"go help modules\" for more information.", + "enum": ["mod", "readonly", "vendor"] + }, + "allow-parallel-runners": { + "description": "Allow multiple parallel golangci-lint instances running. If disabled, golangci-lint acquires file lock on start.", + "type": "boolean", + "default": false + }, + "allow-serial-runners": { + "description": "Allow multiple golangci-lint instances running, but serialize them around a lock.", + "type": "boolean", + "default": false + }, + "go": { + "description": "Targeted Go version.", + "type": "string", + "default": "1.17" + }, + "relative-path-mode": { + "description": "The mode used to evaluate relative paths.", + "type": "string", + "$ref": "#/definitions/relative-path-modes", + "default": "wd" + } + } + }, + "output": { + "description": "Output configuration options.", + "type": "object", + "additionalProperties": false, + "properties": { + "formats": { + "description": "Output formats to use.", + "type": "object", + "additionalProperties": false, + "properties": { + "text": { + "type": "object", + "additionalProperties": false, + "properties": { + "path": { + "$ref": "#/definitions/formats-path", + "default": "stdout" + }, + "print-linter-name": { + "type": "boolean", + "default": true + }, + "print-issued-lines": { + "type": "boolean", + "default": true + }, + "colors": { + "type": "boolean", + "default": true + } + } + }, + "json": { + "$ref": "#/definitions/simple-format" + }, + "tab": { + "type": "object", + "additionalProperties": false, + "properties": { + "path": { + "$ref": "#/definitions/formats-path", + "default": "stdout" + }, + "print-linter-name": { + "type": "boolean", + "default": true + }, + "colors": { + "type": "boolean", + "default": true + } + } + }, + "html": { + "$ref": "#/definitions/simple-format" + }, + "checkstyle": { + "$ref": "#/definitions/simple-format" + }, + "code-climate": { + "$ref": "#/definitions/simple-format" + }, + "junit-xml": { + "type": "object", + "additionalProperties": false, + "properties": { + "path": { + "$ref": "#/definitions/formats-path", + "default": "stdout" + }, + "extended": { + "type": "boolean", + "default": true + } + } + }, + "teamcity": { + "$ref": "#/definitions/simple-format" + }, + "sarif": { + "$ref": "#/definitions/simple-format" + } + } + }, + "path-prefix": { + "description": "Add a prefix to the output file references.", + "type": "string", + "default": "" + }, + "show-stats": { + "description": "Show statistics per linter.", + "type": "boolean", + "default": false + }, + "sort-order": { + "type": "array", + "items": { + "enum": ["linter", "severity", "file"] + } + }, + "sort-results": { + "description": "Sort results by: filepath, line and column.", + "type": "boolean", + "default": true + } + } + }, + "linters-settings": { + "description": "All available settings of specific linters.", + "type": "object", + "additionalProperties": false, + "properties": { + "dupword": { + "$ref": "#/definitions/settings/definitions/dupwordSettings" + }, + "asasalint": { + "$ref": "#/definitions/settings/definitions/asasalintSettings" + }, + "bidichk": { + "$ref": "#/definitions/settings/definitions/bidichkSettings" + }, + "cyclop": { + "$ref": "#/definitions/settings/definitions/cyclopSettings" + }, + "decorder": { + "$ref": "#/definitions/settings/definitions/decorderSettings" + }, + "depguard":{ + "$ref": "#/definitions/settings/definitions/depguardSettings" + }, + "dogsled": { + "$ref": "#/definitions/settings/definitions/dogsledSettings" + }, + "dupl": { + "$ref": "#/definitions/settings/definitions/duplSettings" + }, + "errcheck": { + "$ref": "#/definitions/settings/definitions/errcheckSettings" + }, + "errchkjson": { + "$ref": "#/definitions/settings/definitions/errchkjsonSettings" + }, + "errorlint": { + "$ref": "#/definitions/settings/definitions/errorlintSettings" + }, + "exhaustive": { + "$ref": "#/definitions/settings/definitions/exhaustiveSettings" + }, + "exhaustruct": { + "$ref": "#/definitions/settings/definitions/exhaustructSettings" + }, + "fatcontext": { + "$ref": "#/definitions/settings/definitions/fatcontextSettings" + }, + "forbidigo": { + "$ref": "#/definitions/settings/definitions/forbidigoSettings" + }, + "funlen": { + "$ref": "#/definitions/settings/definitions/funlenSettings" + }, + "ginkgolinter": { + "$ref": "#/definitions/settings/definitions/ginkgolinterSettings" + }, + "gochecksumtype": { + "$ref": "#/definitions/settings/definitions/gochecksumtypeSettings" + }, + "gocognit": { + "$ref": "#/definitions/settings/definitions/gocognitSettings" + }, + "goconst": { + "$ref": "#/definitions/settings/definitions/goconstSettings" + }, + "gocritic": { + "$ref": "#/definitions/settings/definitions/gocriticSettings" + }, + "gocyclo": { + "$ref": "#/definitions/settings/definitions/gocycloSettings" + }, + "godot": { + "$ref": "#/definitions/settings/definitions/godotSettings" + }, + "godox": { + "$ref": "#/definitions/settings/definitions/godoxSettings" + }, + "interfacebloat":{ + "$ref": "#/definitions/settings/definitions/interfacebloatSettings" + }, + "goheader": { + "$ref": "#/definitions/settings/definitions/goheaderSettings" + }, + "gomoddirectives": { + "$ref": "#/definitions/settings/definitions/gomoddirectivesSettings" + }, + "gomodguard": { + "$ref": "#/definitions/settings/definitions/gomodguardSettings" + }, + "gosimple": { + "$ref": "#/definitions/settings/definitions/gosimpleSettings" + }, + "gosec": { + "$ref": "#/definitions/settings/definitions/gosecSettings" + }, + "gosmopolitan": { + "$ref": "#/definitions/settings/definitions/gosmopolitanSettings" + }, + "govet": { + "$ref": "#/definitions/settings/definitions/govetSettings" + }, + "grouper": { + "$ref": "#/definitions/settings/definitions/grouperSettings" + }, + "iface": { + "$ref": "#/definitions/settings/definitions/ifaceSettings" + }, + "importas": { + "$ref": "#/definitions/settings/definitions/importasSettings" + }, + "inamedparam": { + "$ref": "#/definitions/settings/definitions/inamedparamSettings" + }, + "ireturn": { + "$ref": "#/definitions/settings/definitions/ireturnSettings" + }, + "lll": { + "$ref": "#/definitions/settings/definitions/lllSettings" + }, + "maintidx": { + "$ref": "#/definitions/settings/definitions/maintidxSettings" + }, + "makezero":{ + "$ref": "#/definitions/settings/definitions/makezeroSettings" + }, + "loggercheck": { + "$ref": "#/definitions/settings/definitions/loggercheckSettings" + }, + "misspell": { + "$ref": "#/definitions/settings/definitions/misspellSettings" + }, + "musttag": { + "$ref": "#/definitions/settings/definitions/musttagSettings" + }, + "nakedret": { + "$ref": "#/definitions/settings/definitions/nakedretSettings" + }, + "nestif": { + "$ref": "#/definitions/settings/definitions/nestifSettings" + }, + "nilnil": { + "$ref": "#/definitions/settings/definitions/nilnilSettings" + }, + "nlreturn": { + "$ref": "#/definitions/settings/definitions/nlreturnSettings" + }, + "mnd": { + "$ref": "#/definitions/settings/definitions/mndSettings" + }, + "nolintlint":{ + "$ref": "#/definitions/settings/definitions/nolintlintSettings" + }, + "reassign": { + "$ref": "#/definitions/settings/definitions/reassignSettings" + }, + "recvcheck": { + "$ref": "#/definitions/settings/definitions/recvcheckSettings" + }, + "nonamedreturns": { + "$ref": "#/definitions/settings/definitions/nonamedreturnsSettings" + }, + "paralleltest": { + "$ref": "#/definitions/settings/definitions/paralleltestSettings" + }, + "perfsprint": { + "$ref": "#/definitions/settings/definitions/perfsprintSettings" + }, + "prealloc": { + "$ref": "#/definitions/settings/definitions/preallocSettings" + }, + "predeclared": { + "$ref": "#/definitions/settings/definitions/predeclaredSettings" + }, + "promlinter": { + "$ref": "#/definitions/settings/definitions/promlinterSettings" + }, + "protogetter": { + "$ref": "#/definitions/settings/definitions/protogetterSettings" + }, + "revive": { + "$ref": "#/definitions/settings/definitions/reviveSettings" + }, + "rowserrcheck": { + "$ref": "#/definitions/settings/definitions/rowserrcheckSettings" + }, + "sloglint": { + "$ref": "#/definitions/settings/definitions/sloglintSettings" + }, + "spancheck": { + "$ref": "#/definitions/settings/definitions/spancheckSettings" + }, + "staticcheck":{ + "$ref": "#/definitions/settings/definitions/staticcheckSettings" + }, + "stylecheck": { + "$ref": "#/definitions/settings/definitions/stylecheckSettings" + }, + "tagalign": { + "$ref": "#/definitions/settings/definitions/tagalignSettings" + }, + "tagliatelle": { + "$ref": "#/definitions/settings/definitions/tagliatelleSettings" + }, + "tenv": { + "$ref": "#/definitions/settings/definitions/tenvSettings" + }, + "testifylint": { + "$ref": "#/definitions/settings/definitions/testifylintSettings" + }, + "testpackage": { + "$ref": "#/definitions/settings/definitions/testpackageSettings" + }, + "thelper": { + "$ref": "#/definitions/settings/definitions/thelperSettings" + }, + "usestdlibvars": { + "$ref": "#/definitions/settings/definitions/usestdlibvarsSettings" + }, + "usetesting": { + "$ref": "#/definitions/settings/definitions/usetestingSettings" + }, + "unconvert": { + "$ref": "#/definitions/settings/definitions/unconvertSettings" + }, + "unparam": { + "$ref": "#/definitions/settings/definitions/unparamSettings" + }, + "unused": { + "$ref": "#/definitions/settings/definitions/unusedSettings" + }, + "varnamelen": { + "$ref": "#/definitions/settings/definitions/varnamelenSettings" + }, + "whitespace": { + "$ref": "#/definitions/settings/definitions/whitespaceSettings" + }, + "wrapcheck": { + "$ref": "#/definitions/settings/definitions/wrapcheckSettings" + }, + "wsl": { + "$ref": "#/definitions/settings/definitions/wslSettings" + }, + "copyloopvar": { + "$ref": "#/definitions/settings/definitions/copyloopvarSettings" + }, + "custom":{ + "$ref": "#/definitions/settings/definitions/customSettings" + } + } }, "linters": { "type": "object", @@ -3949,14 +4202,14 @@ "description": "List of enabled linters.", "type": "array", "items": { - "$ref": "#/definitions/linters" + "$ref": "#/definitions/linter-names" } }, "disable": { "description": "List of disabled linters.", "type": "array", "items": { - "$ref": "#/definitions/linters" + "$ref": "#/definitions/linter-names" } }, "enable-all": { @@ -4032,7 +4285,7 @@ "linters": { "type": "array", "items": { - "$ref": "#/definitions/linters" + "$ref": "#/definitions/linter-names" } }, "text": { @@ -4067,6 +4320,56 @@ } } }, + "formatters": { + "type": "object", + "additionalProperties": false, + "properties": { + "enable": { + "description": "List of enabled formatters.", + "type": "array", + "items": { + "$ref": "#/definitions/formatter-names" + } + }, + "settings": { + "type": "object", + "additionalProperties": false, + "properties": { + "gci": { + "$ref": "#/definitions/settings/definitions/gciSettings" + }, + "gofmt": { + "$ref": "#/definitions/settings/definitions/gofmtSettings" + }, + "gofumpt": { + "$ref": "#/definitions/settings/definitions/gofumptSettings" + }, + "goimports": { + "$ref": "#/definitions/settings/definitions/goimportsSettings" + }, + "golines": { + "$ref": "#/definitions/settings/definitions/golinesSettings" + } + } + }, + "exclusions": { + "type": "object", + "additionalProperties": false, + "properties": { + "generated": { + "type": "boolean", + "default": true + }, + "paths": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + }, "issues": { "type": "object", "additionalProperties": false, @@ -4094,7 +4397,7 @@ "linters": { "type": "array", "items": { - "$ref": "#/definitions/linters" + "$ref": "#/definitions/linter-names" } }, "text": { @@ -4252,7 +4555,7 @@ "linters": { "type": "array", "items": { - "$ref": "#/definitions/linters" + "$ref": "#/definitions/linter-names" } }, "text": { diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 7854e32fecbe..6e76ad200143 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -204,7 +204,7 @@ var defaultLintersSettings = LintersSettings{ } type LintersSettings struct { - FormatterSettings `mapstructure:",squash"` + FormatterSettings `mapstructure:"-"` Asasalint AsasalintSettings `mapstructure:"asasalint"` BiDiChk BiDiChkSettings `mapstructure:"bidichk"` diff --git a/pkg/golinters/gci/testdata/gci.yml b/pkg/golinters/gci/testdata/gci.yml index 4d259112001d..a7295168fa89 100644 --- a/pkg/golinters/gci/testdata/gci.yml +++ b/pkg/golinters/gci/testdata/gci.yml @@ -1,9 +1,12 @@ version: "2" -linters-settings: - gci: - sections: - - standard - - prefix(github.com/golangci/golangci-lint,github.com/daixiang0/gci) - - default - custom-order: true +formatters: + enable: + - gci + settings: + gci: + sections: + - standard + - prefix(github.com/golangci/golangci-lint,github.com/daixiang0/gci) + - default + custom-order: true diff --git a/pkg/golinters/gofmt/testdata/gofmt_no_simplify.yml b/pkg/golinters/gofmt/testdata/gofmt_no_simplify.yml index db4681a05d5f..399336a16bd2 100644 --- a/pkg/golinters/gofmt/testdata/gofmt_no_simplify.yml +++ b/pkg/golinters/gofmt/testdata/gofmt_no_simplify.yml @@ -1,5 +1,8 @@ version: "2" -linters-settings: - gofmt: - simplify: false +formatters: + enable: + - gofmt + settings: + gofmt: + simplify: false diff --git a/pkg/golinters/gofmt/testdata/gofmt_rewrite_rules.yml b/pkg/golinters/gofmt/testdata/gofmt_rewrite_rules.yml index 6ec30e153347..322f63f1716a 100644 --- a/pkg/golinters/gofmt/testdata/gofmt_rewrite_rules.yml +++ b/pkg/golinters/gofmt/testdata/gofmt_rewrite_rules.yml @@ -1,9 +1,12 @@ version: "2" -linters-settings: - gofmt: - rewrite-rules: - - pattern: 'interface{}' - replacement: 'any' - - pattern: 'a[b:len(a)]' - replacement: 'a[b:]' +formatters: + enable: + - gofmt + settings: + gofmt: + rewrite-rules: + - pattern: 'interface{}' + replacement: 'any' + - pattern: 'a[b:len(a)]' + replacement: 'a[b:]' diff --git a/pkg/golinters/gofumpt/testdata/gofumpt-fix.yml b/pkg/golinters/gofumpt/testdata/gofumpt-fix.yml index 79d89c916f40..2ea2120b8480 100644 --- a/pkg/golinters/gofumpt/testdata/gofumpt-fix.yml +++ b/pkg/golinters/gofumpt/testdata/gofumpt-fix.yml @@ -1,5 +1,8 @@ version: "2" -linters-settings: - gofumpt: - extra-rules: true +formatters: + enable: + - gofumpt + settings: + gofumpt: + extra-rules: true diff --git a/pkg/golinters/gofumpt/testdata/gofumpt_with_extra.yml b/pkg/golinters/gofumpt/testdata/gofumpt_with_extra.yml index 79d89c916f40..2ea2120b8480 100644 --- a/pkg/golinters/gofumpt/testdata/gofumpt_with_extra.yml +++ b/pkg/golinters/gofumpt/testdata/gofumpt_with_extra.yml @@ -1,5 +1,8 @@ version: "2" -linters-settings: - gofumpt: - extra-rules: true +formatters: + enable: + - gofumpt + settings: + gofumpt: + extra-rules: true diff --git a/pkg/golinters/goimports/testdata/goimports_local.yml b/pkg/golinters/goimports/testdata/goimports_local.yml index ab960708b0a9..b5704a8233c0 100644 --- a/pkg/golinters/goimports/testdata/goimports_local.yml +++ b/pkg/golinters/goimports/testdata/goimports_local.yml @@ -1,5 +1,8 @@ version: "2" -linters-settings: - goimports: - local-prefixes: github.com/golangci/golangci-lint +formatters: + enable: + - goimports + settings: + goimports: + local-prefixes: github.com/golangci/golangci-lint diff --git a/test/testdata/configs/multiple-issues-fix.yml b/test/testdata/configs/multiple-issues-fix.yml index a60a68235687..2ea2120b8480 100644 --- a/test/testdata/configs/multiple-issues-fix.yml +++ b/test/testdata/configs/multiple-issues-fix.yml @@ -1,6 +1,8 @@ version: "2" -linters-settings: - gofumpt: - extra-rules: true - +formatters: + enable: + - gofumpt + settings: + gofumpt: + extra-rules: true