diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 5a2c65c14ec6..c73eb8da2b4d 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -502,18 +502,42 @@ linters: default-case-required: true exhaustruct: - # List of regular expressions to match struct packages and their names. - # Regular expressions must match complete canonical struct package/name/structname. - # If this list is empty, all structs are tested. + # List of regular expressions to match type names that should be processed. + # Anonymous structs can be matched by '' alias. + # + # Each regular expression must match the full type name, including package path. + # For example, to match type `net/http.Cookie` regular expression should be `.*/http\.Cookie`, + # but not `http\.Cookie`. # Default: [] include: - '.+\.Test' - 'example\.com/package\.ExampleStruct[\d]{1,2}' - # List of regular expressions to exclude struct packages and their names from checks. - # Regular expressions must match complete canonical struct package/name/structname. + # List of regular expressions to match type names that should be excluded from processing. + # Anonymous structs can be matched by '' alias. + # Has precedence over `include`. + # Each regular expression must match the full type name, including package path. + # For example, to match type `net/http.Cookie` regular expression should be `.*/http\.Cookie`, + # but not `http\.Cookie`. # Default: [] exclude: - '.+/cobra\.Command$' + # Allows empty structures, effectively excluding them from the check. + # Default: false + allow-empty: true + # List of regular expressions to match type names that should be allowed to be empty. + # Anonymous structs can be matched by '' alias. + # Each regular expression must match the full type name, including package path. + # For example, to match type `net/http.Cookie` regular expression should be `.*/http\.Cookie`, + # but not `http\.Cookie`. + # Default: [] + allow-empty-rx: + - '.*/http\.Cookie' + # Allows empty structures in return statements. + # Default: false + allow-empty-returns: true + # Allows empty structures in variable declarations. + # Default: false + allow-empty-declarations: true fatcontext: # Check for potential fat contexts in struct pointers. diff --git a/docs/data/linters_info.json b/docs/data/linters_info.json index cca964d3cb8f..6f2da9810049 100644 --- a/docs/data/linters_info.json +++ b/docs/data/linters_info.json @@ -202,7 +202,7 @@ "originalURL": "https://github.com/nishanths/exhaustive", "internal": false, "isSlow": true, - "since": " v1.28.0" + "since": "v1.28.0" }, { "name": "exhaustruct", diff --git a/jsonschema/golangci.jsonschema.json b/jsonschema/golangci.jsonschema.json index 7c4840521f4a..67cd80a55e98 100644 --- a/jsonschema/golangci.jsonschema.json +++ b/jsonschema/golangci.jsonschema.json @@ -1305,6 +1305,28 @@ "items": { "type": "string" } + }, + "allow-empty": { + "description": "Allows empty structures, effectively excluding them from the check.", + "type": "boolean", + "default": false + }, + "allow-empty-rx": { + "description": "List of regular expressions to match type names that should be allowed to be empty.", + "type": "array", + "items": { + "type": "string" + } + }, + "allow-empty-returns": { + "description": "Allows empty structures in return statements.", + "type": "boolean", + "default": false + }, + "allow-empty-declarations": { + "description": "Allows empty structures in variable declarations.", + "type": "boolean", + "default": false } } },