{"record":{"id":"078f67bce20e9f09","repo":"golangci/golangci-lint","slug":"a-rule-cannot-be-enabled-and-disabled-at-the-same","errorCode":null,"errorMessage":"a rule cannot be enabled and disabled at the same time: '%s'","messagePattern":"a rule cannot be enabled and disabled at the same time: '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/golinters/godoclint/godoclint.go","lineNumber":96,"sourceCode":"\t\tWithLoadMode(goanalysis.LoadModeSyntax)\n}\n\nfunc checkSettings(settings *config.GodoclintSettings) error {\n\tswitch deref(settings.Default) {\n\tcase string(model.DefaultSetAll):\n\t\tif len(settings.Enable) > 0 {\n\t\t\treturn errors.New(\"cannot use 'enable' with 'default=all'\")\n\t\t}\n\n\tcase string(model.DefaultSetNone):\n\t\tif len(settings.Disable) > 0 {\n\t\t\treturn errors.New(\"cannot use 'disable' with 'default=none'\")\n\t\t}\n\n\tdefault:\n\t\tfor _, rule := range settings.Enable {\n\t\t\tif slices.Contains(settings.Disable, rule) {\n\t\t\t\treturn fmt.Errorf(\"a rule cannot be enabled and disabled at the same time: '%s'\", rule)\n\t\t\t}\n\t\t}\n\n\t\tfor _, rule := range settings.Disable {\n\t\t\tif slices.Contains(settings.Enable, rule) {\n\t\t\t\treturn fmt.Errorf(\"a rule cannot be enabled and disabled at the same time: '%s'\", rule)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc deref[T any](v *T) T {\n\tif v == nil {\n\t\tvar zero T\n\t\treturn zero\n\t}","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/golinters/godoclint/godoclint.go#L78-L114","documentation":"godoclint's settings check rejects rules that appear in both settings.Enable and settings.Disable (outside the special enable/disable/default modes). Since configuration is validated at linter construction (New), golangci-lint fails before analysis.","triggerScenarios":"In the godoclint settings block, the same rule ID is present in both 'enable' and 'disable' lists and the mode is not 'enable-only'/'disable-only' with default=none; checkSettings's first loop finds Disable containing the enabled rule.","commonSituations":"Merging a shared config that enables rules with a project config disabling them, adding a rule to enable while forgetting it's already in disable, copy-paste between the two lists.","solutions":["Remove the rule from one of the two lists (enable or disable) per your intent","If you intended to override a base config, use godoclint's mode options (e.g. 'disable' or 'default=none') consistently instead of mixing both lists","Grep your merged .golangci.yml for the rule ID to see both occurrences"],"exampleFix":"// before (.golangci.yml)\nsettings:\n  godoclint:\n    enable: [wrl]\n    disable: [wrl]\n// after\nsettings:\n  godoclint:\n    enable: [wrl]","handlingStrategy":"validation","validationCode":"const { enable = [], disable = [] } = cfg.settings.godoclint\nconst clash = enable.filter(r => disable.includes(r))\nif (clash.length) throw new Error(`godoclint rule(s) both enabled and disabled: ${clash.join(', ')}`)","typeGuard":"const noRuleConflict = (s) => !(s.enable ?? []).some(r => (s.disable ?? []).includes(r))","tryCatchPattern":null,"preventionTips":["Keep godoclint rule selection in either enable or disable, not both","When overriding a base config, remove inherited entries rather than adding the opposite list","Validate merged config before running golangci-lint"],"tags":["golangci-lint","godoclint","configuration"],"backgroundTag":"conflicting-linter-config","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}