{"record":{"id":"da81f2cf387ba40e","repo":"nodejs/node","slug":"every-filter-in-filters-must-start-with-or","errorCode":null,"errorMessage":"Every filter in --filters must start with + or - ({filt} does not)","messagePattern":"Every filter in --filters must start with \\+ or - \\((.+?) does not\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/cpplint.py","lineNumber":1509,"sourceCode":"        # Default filters always have less priority than the flag ones.\n        self.filters = _DEFAULT_FILTERS[:]\n        self.AddFilters(filters)\n\n    def AddFilters(self, filters):\n        \"\"\"Adds more filters to the existing list of error-message filters.\"\"\"\n        for filt in filters.split(\",\"):\n            clean_filt = filt.strip()\n            if clean_filt:\n                if len(clean_filt) > 1 and clean_filt[1:] in _FILTER_SHORTCUTS:\n                    starting_char = clean_filt[0]\n                    new_filters = [starting_char + x for x in _FILTER_SHORTCUTS[clean_filt[1:]]]\n                    self.filters.extend(new_filters)\n                else:\n                    self.filters.append(clean_filt)\n        for filt in self.filters:\n            if not filt.startswith((\"+\", \"-\")):\n                msg = f\"Every filter in --filters must start with + or - ({filt} does not)\"\n                raise ValueError(msg)\n\n    def BackupFilters(self):\n        \"\"\"Saves the current filter list to backup storage.\"\"\"\n        self._filters_backup = self.filters[:]\n\n    def RestoreFilters(self):\n        \"\"\"Restores filters previously backed up.\"\"\"\n        self.filters = self._filters_backup[:]\n\n    def ResetErrorCounts(self):\n        \"\"\"Sets the module's error statistic back to zero.\"\"\"\n        self.error_count = 0\n        self.errors_by_category = {}\n\n    def IncrementErrorCount(self, category):\n        \"\"\"Bumps the module's error statistic.\"\"\"\n        self.error_count += 1\n        if self.counting in (\"toplevel\", \"detailed\"):","sourceCodeStart":1491,"sourceCodeEnd":1527,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/cpplint.py#L1491-L1527","documentation":"Raised by the --filters parser in Node's tools/cpplint.py (a vendored cpplint clone): after expanding shortcuts and collecting filters, it validates that every filter starts with '+' (enable) or '-' (disable). Any filter lacking that sign prefix is a syntax error.","triggerScenarios":"Passing --filters=readability/runtime,build/namespaces (missing the leading +/- on each token), or a filter shortcut expansion that produced a sign-less entry, or whitespace-only entries after splitting on commas.","commonSituations":"Copy-pasting a cpplint filter list from a guide that omits the +/- convention; migrating from a different linter whose filter syntax is bare category names; a CI config that builds the --filters string dynamically and forgets the sign.","solutions":["Prefix every filter with + or - : use --filters=+readability/runtime,-build/namespaces.","Use the registered shortcuts (e.g. +readability) which expand to signed sub-filters, ensuring consistency.","Validate the filter string in your CI script before invoking cpplint."],"exampleFix":"# before\n--filters=readability/runtime,build/namespaces\n# after\n--filters=+readability/runtime,-build/namespaces","handlingStrategy":"validation","validationCode":"def validate_cpplint_filters(filters: str) -> None:\n    for filt in filters.split(','):\n        f = filt.strip()\n        if f and not f.startswith(('+', '-')):\n            raise ValueError(f'Filter {f!r} must start with + or -')","typeGuard":"def are_valid_filters(filters: str) -> bool:\n    return all(not f.strip() or f.strip().startswith(('+','-')) for f in filters.split(','))","tryCatchPattern":"null","preventionTips":["Always prefix each filter with + or -.","Build the --filters value programmatically and assert the prefix in CI.","Prefer registered shortcuts that expand to signed filters."],"tags":["node","cpplint","linting","filters","configuration"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}