From b3f1aba0f031ca17771110ceec8607c55074844d Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 3 Jun 2024 00:58:21 +0200 Subject: [PATCH 1/2] docs: order rules alphabetically and add missing rules --- .golangci.next.reference.yml | 111 +++++++++++++++++++---------------- .golangci.reference.yml | 111 +++++++++++++++++++---------------- 2 files changed, 124 insertions(+), 98 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 1875b4b6f428..c87aec032978 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -1561,8 +1561,8 @@ linters-settings: # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#atomic - name: atomic severity: warning - exclude: [""] disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#banned-characters - name: banned-characters severity: warning @@ -1572,23 +1572,23 @@ linters-settings: # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bare-return - name: bare-return severity: warning - exclude: [""] disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#blank-imports - name: blank-imports severity: warning - exclude: [""] disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr - name: bool-literal-in-expr severity: warning - exclude: [""] disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#call-to-gc - name: call-to-gc severity: warning - exclude: [""] disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#cognitive-complexity - name: cognitive-complexity severity: warning @@ -1658,6 +1658,7 @@ linters-settings: severity: warning disabled: false exclude: [""] + arguments: [ ] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#duplicated-imports - name: duplicated-imports severity: warning @@ -1742,18 +1743,18 @@ linters-settings: severity: warning disabled: false exclude: [""] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-result-limit - - name: function-result-limit - severity: warning - disabled: false - exclude: [""] - arguments: [ 2 ] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-length - name: function-length severity: warning disabled: false exclude: [""] arguments: [ 10, 0 ] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-result-limit + - name: function-result-limit + severity: warning + disabled: false + exclude: [""] + arguments: [ 3 ] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#get-return - name: get-return severity: warning @@ -1769,18 +1770,6 @@ linters-settings: severity: warning disabled: false exclude: [""] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#increment-decrement - - name: increment-decrement - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#indent-error-flow - - name: indent-error-flow - severity: warning - disabled: false - exclude: [""] - arguments: - - "preserveScope" # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-alias-naming - name: import-alias-naming severity: warning @@ -1788,6 +1777,11 @@ linters-settings: exclude: [""] arguments: - "^[a-z][a-z0-9]{0,}$" + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing + - name: import-shadowing + severity: warning + disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#imports-blocklist - name: imports-blocklist severity: warning @@ -1796,11 +1790,18 @@ linters-settings: arguments: - "crypto/md5" - "crypto/sha1" - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing - - name: import-shadowing + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#increment-decrement + - name: increment-decrement + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#indent-error-flow + - name: indent-error-flow severity: warning disabled: false exclude: [""] + arguments: + - "preserveScope" # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#line-length-limit - name: line-length-limit severity: warning @@ -1849,23 +1850,18 @@ linters-settings: severity: warning disabled: false exclude: [""] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-in-closure - - name: range-val-in-closure - severity: warning - disabled: false - exclude: [""] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-address - name: range-val-address severity: warning disabled: false exclude: [""] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#receiver-naming - - name: receiver-naming + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-in-closure + - name: range-val-in-closure severity: warning disabled: false exclude: [""] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redundant-import-alias - - name: redundant-import-alias + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#receiver-naming + - name: receiver-naming severity: warning disabled: false exclude: [""] @@ -1874,8 +1870,8 @@ linters-settings: severity: warning disabled: false exclude: [""] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-of-int - - name: string-of-int + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redundant-import-alias + - name: redundant-import-alias severity: warning disabled: false exclude: [""] @@ -1894,14 +1890,19 @@ linters-settings: - - panic - '/^[^\n]*$/' - must not contain line breaks + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-of-int + - name: string-of-int + severity: warning + disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag - name: struct-tag - arguments: - - "json,inline" - - "bson,outline,gnu" severity: warning disabled: false exclude: [""] + arguments: + - "json,inline" + - "bson,outline,gnu" # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#superfluous-else - name: superfluous-else severity: warning @@ -1919,20 +1920,13 @@ linters-settings: severity: warning disabled: false exclude: [""] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming - - name: var-naming + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unchecked-type-assertion + - name: unchecked-type-assertion severity: warning disabled: false exclude: [""] arguments: - - [ "ID" ] # AllowList - - [ "VM" ] # DenyList - - - upperCaseConst: true - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration - - name: var-declaration - severity: warning - disabled: false - exclude: [""] + - acceptIgnoredAssertionResult: true # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unconditional-recursion - name: unconditional-recursion severity: warning @@ -1980,11 +1974,30 @@ linters-settings: exclude: [""] arguments: - allowRegex: "^_" + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#use-any + - name: use-any + severity: warning + disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break - name: useless-break severity: warning disabled: false exclude: [""] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration + - name: var-declaration + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming + - name: var-naming + severity: warning + disabled: false + exclude: [""] + arguments: + - [ "ID" ] # AllowList + - [ "VM" ] # DenyList + - - upperCaseConst: true # Extra parameter (upperCaseConst|skipPackageNameChecks) # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#waitgroup-by-value - name: waitgroup-by-value severity: warning diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 1875b4b6f428..c87aec032978 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -1561,8 +1561,8 @@ linters-settings: # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#atomic - name: atomic severity: warning - exclude: [""] disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#banned-characters - name: banned-characters severity: warning @@ -1572,23 +1572,23 @@ linters-settings: # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bare-return - name: bare-return severity: warning - exclude: [""] disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#blank-imports - name: blank-imports severity: warning - exclude: [""] disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr - name: bool-literal-in-expr severity: warning - exclude: [""] disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#call-to-gc - name: call-to-gc severity: warning - exclude: [""] disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#cognitive-complexity - name: cognitive-complexity severity: warning @@ -1658,6 +1658,7 @@ linters-settings: severity: warning disabled: false exclude: [""] + arguments: [ ] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#duplicated-imports - name: duplicated-imports severity: warning @@ -1742,18 +1743,18 @@ linters-settings: severity: warning disabled: false exclude: [""] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-result-limit - - name: function-result-limit - severity: warning - disabled: false - exclude: [""] - arguments: [ 2 ] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-length - name: function-length severity: warning disabled: false exclude: [""] arguments: [ 10, 0 ] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-result-limit + - name: function-result-limit + severity: warning + disabled: false + exclude: [""] + arguments: [ 3 ] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#get-return - name: get-return severity: warning @@ -1769,18 +1770,6 @@ linters-settings: severity: warning disabled: false exclude: [""] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#increment-decrement - - name: increment-decrement - severity: warning - disabled: false - exclude: [""] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#indent-error-flow - - name: indent-error-flow - severity: warning - disabled: false - exclude: [""] - arguments: - - "preserveScope" # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-alias-naming - name: import-alias-naming severity: warning @@ -1788,6 +1777,11 @@ linters-settings: exclude: [""] arguments: - "^[a-z][a-z0-9]{0,}$" + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing + - name: import-shadowing + severity: warning + disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#imports-blocklist - name: imports-blocklist severity: warning @@ -1796,11 +1790,18 @@ linters-settings: arguments: - "crypto/md5" - "crypto/sha1" - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing - - name: import-shadowing + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#increment-decrement + - name: increment-decrement + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#indent-error-flow + - name: indent-error-flow severity: warning disabled: false exclude: [""] + arguments: + - "preserveScope" # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#line-length-limit - name: line-length-limit severity: warning @@ -1849,23 +1850,18 @@ linters-settings: severity: warning disabled: false exclude: [""] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-in-closure - - name: range-val-in-closure - severity: warning - disabled: false - exclude: [""] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-address - name: range-val-address severity: warning disabled: false exclude: [""] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#receiver-naming - - name: receiver-naming + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-in-closure + - name: range-val-in-closure severity: warning disabled: false exclude: [""] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redundant-import-alias - - name: redundant-import-alias + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#receiver-naming + - name: receiver-naming severity: warning disabled: false exclude: [""] @@ -1874,8 +1870,8 @@ linters-settings: severity: warning disabled: false exclude: [""] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-of-int - - name: string-of-int + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redundant-import-alias + - name: redundant-import-alias severity: warning disabled: false exclude: [""] @@ -1894,14 +1890,19 @@ linters-settings: - - panic - '/^[^\n]*$/' - must not contain line breaks + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-of-int + - name: string-of-int + severity: warning + disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag - name: struct-tag - arguments: - - "json,inline" - - "bson,outline,gnu" severity: warning disabled: false exclude: [""] + arguments: + - "json,inline" + - "bson,outline,gnu" # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#superfluous-else - name: superfluous-else severity: warning @@ -1919,20 +1920,13 @@ linters-settings: severity: warning disabled: false exclude: [""] - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming - - name: var-naming + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unchecked-type-assertion + - name: unchecked-type-assertion severity: warning disabled: false exclude: [""] arguments: - - [ "ID" ] # AllowList - - [ "VM" ] # DenyList - - - upperCaseConst: true - # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration - - name: var-declaration - severity: warning - disabled: false - exclude: [""] + - acceptIgnoredAssertionResult: true # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unconditional-recursion - name: unconditional-recursion severity: warning @@ -1980,11 +1974,30 @@ linters-settings: exclude: [""] arguments: - allowRegex: "^_" + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#use-any + - name: use-any + severity: warning + disabled: false + exclude: [""] # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break - name: useless-break severity: warning disabled: false exclude: [""] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration + - name: var-declaration + severity: warning + disabled: false + exclude: [""] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming + - name: var-naming + severity: warning + disabled: false + exclude: [""] + arguments: + - [ "ID" ] # AllowList + - [ "VM" ] # DenyList + - - upperCaseConst: true # Extra parameter (upperCaseConst|skipPackageNameChecks) # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#waitgroup-by-value - name: waitgroup-by-value severity: warning From afce090707b0386ea86dd16cfd91659ee42a3201 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 3 Jun 2024 00:58:46 +0200 Subject: [PATCH 2/2] docs: add rule names validation --- jsonschema/golangci.jsonschema.json | 84 +++++++++++++++++++++++- jsonschema/golangci.next.jsonschema.json | 84 +++++++++++++++++++++++- 2 files changed, 166 insertions(+), 2 deletions(-) diff --git a/jsonschema/golangci.jsonschema.json b/jsonschema/golangci.jsonschema.json index 7b658258ab0f..66b2cc742a6d 100644 --- a/jsonschema/golangci.jsonschema.json +++ b/jsonschema/golangci.jsonschema.json @@ -205,6 +205,88 @@ "unusedwrite" ] }, + "revive-rules": { + "enum": [ + "add-constant", + "argument-limit", + "atomic", + "banned-characters", + "bare-return", + "blank-imports", + "bool-literal-in-expr", + "call-to-gc", + "cognitive-complexity", + "comment-spacings", + "confusing-naming", + "confusing-results", + "constant-logical-expr", + "context-as-argument", + "context-keys-type", + "cyclomatic", + "datarace", + "deep-exit", + "defer", + "dot-imports", + "duplicated-imports", + "early-return", + "empty-block", + "empty-lines", + "enforce-map-style", + "enforce-repeated-arg-type-style", + "enforce-slice-style", + "error-naming", + "error-return", + "error-strings", + "errorf", + "exported", + "file-header", + "flag-parameter", + "function-length", + "function-result-limit", + "get-return", + "identical-branches", + "if-return", + "import-alias-naming", + "import-shadowing", + "imports-blocklist", + "increment-decrement", + "indent-error-flow", + "line-length-limit", + "max-control-nesting", + "max-public-structs", + "modifies-parameter", + "modifies-value-receiver", + "nested-structs", + "optimize-operands-order", + "package-comments", + "range", + "range-val-address", + "range-val-in-closure", + "receiver-naming", + "redefines-builtin-id", + "redundant-import-alias", + "string-format", + "string-of-int", + "struct-tag", + "superfluous-else", + "time-equal", + "time-naming", + "unchecked-type-assertion", + "unconditional-recursion", + "unexported-naming", + "unexported-return", + "unhandled-error", + "unnecessary-stmt", + "unreachable-code", + "unused-parameter", + "unused-receiver", + "use-any", + "useless-break", + "var-declaration", + "var-naming", + "waitgroup-by-value" + ] + }, "linters": { "$comment": "anyOf with enum is used to allow auto completion of non-custom linters", "description": "Linters usable.", @@ -2389,7 +2471,7 @@ "required": ["name"], "properties": { "name": { - "type": "string", + "$ref": "#/definitions/revive-rules", "title": "The rule name" }, "disabled": { diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 7b658258ab0f..66b2cc742a6d 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -205,6 +205,88 @@ "unusedwrite" ] }, + "revive-rules": { + "enum": [ + "add-constant", + "argument-limit", + "atomic", + "banned-characters", + "bare-return", + "blank-imports", + "bool-literal-in-expr", + "call-to-gc", + "cognitive-complexity", + "comment-spacings", + "confusing-naming", + "confusing-results", + "constant-logical-expr", + "context-as-argument", + "context-keys-type", + "cyclomatic", + "datarace", + "deep-exit", + "defer", + "dot-imports", + "duplicated-imports", + "early-return", + "empty-block", + "empty-lines", + "enforce-map-style", + "enforce-repeated-arg-type-style", + "enforce-slice-style", + "error-naming", + "error-return", + "error-strings", + "errorf", + "exported", + "file-header", + "flag-parameter", + "function-length", + "function-result-limit", + "get-return", + "identical-branches", + "if-return", + "import-alias-naming", + "import-shadowing", + "imports-blocklist", + "increment-decrement", + "indent-error-flow", + "line-length-limit", + "max-control-nesting", + "max-public-structs", + "modifies-parameter", + "modifies-value-receiver", + "nested-structs", + "optimize-operands-order", + "package-comments", + "range", + "range-val-address", + "range-val-in-closure", + "receiver-naming", + "redefines-builtin-id", + "redundant-import-alias", + "string-format", + "string-of-int", + "struct-tag", + "superfluous-else", + "time-equal", + "time-naming", + "unchecked-type-assertion", + "unconditional-recursion", + "unexported-naming", + "unexported-return", + "unhandled-error", + "unnecessary-stmt", + "unreachable-code", + "unused-parameter", + "unused-receiver", + "use-any", + "useless-break", + "var-declaration", + "var-naming", + "waitgroup-by-value" + ] + }, "linters": { "$comment": "anyOf with enum is used to allow auto completion of non-custom linters", "description": "Linters usable.", @@ -2389,7 +2471,7 @@ "required": ["name"], "properties": { "name": { - "type": "string", + "$ref": "#/definitions/revive-rules", "title": "The rule name" }, "disabled": {