Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] kconfig-checker: duplicate and non-exempted rules in
  _find_issue_pattern()
--

commit 8f6e383a6cf382d507daf59d926387f2a7971370
Author: Ahmed S. Darwish <[email protected]>

kconfig-checker: Add the configuration checker code

This commit introduces a Python-based kernel configuration checker that
validates a .config file against YAML rule profiles and reports issues by
severity.

> diff --git a/tools/kconfig-checker/check.py b/tools/kconfig-checker/check.py
> new file mode 100755
> index 0000000000000..476cd13e59eb8
> --- /dev/null
> +++ b/tools/kconfig-checker/check.py
> @@ -0,0 +1,558 @@

[ ... ]

> +    def _find_issue_pattern(self, pattern_rule: PatternRule) -> 
> Optional[PatternIssue]:
> +        """Check the .config against a pattern rule. Return found issues, if 
> any."""
> +        if pattern_rule.expected == ExpectedValue.allowed:
> +            return None
> +
> +        violation_type = 'unset' if pattern_rule.expected == ExpectedValue.y 
> else 'set'
> +        docs_url = self.rules.get_docs_url_for(pattern_rule)
> +
> +        violating_symbols = []
> +
> +        for symbol in 
> self.kconfig.get_matching_symbols(pattern_rule.symbol_regex):
> +            symbol_value = self.kconfig.get_symbol_value(symbol)
> +
> +            if pattern_rule.expected == ExpectedValue.y and symbol_value == 
> 'n':
> +                # Exclude the config symbol if it's explicitly disabled 
> elsewhere
> +                symbol_rule = self.rules.get_symbol_rule(symbol)
> +                if symbol_rule and symbol_rule.expected == ExpectedValue.n:
> +                    continue
> +
> +                violating_symbols.append(symbol)
> +
> +            if pattern_rule.expected == ExpectedValue.n and symbol_value in 
> ('y', 'm'):
> +                # Exclude the config symbol if it's explicitly allowed 
> elsewhere
> +                symbol_rule = self.rules.get_symbol_rule(symbol)
> +                if symbol_rule and symbol_rule.expected in (ExpectedValue.y, 
> ExpectedValue.allowed):
> +                    continue
> +
> +                violating_symbols.append(symbol)

[Severity: Low]
Should _find_issue_pattern() skip any symbol that has an explicit
SymbolRule, regardless of symbol_rule.expected?

Only checking for opposing expected values causes two issues: when
pattern_rule.expected is ExpectedValue.y, a symbol with a SymbolRule of
ExpectedValue.allowed is not exempted and is falsely reported as unset, and
when a SymbolRule has the same expected value as the PatternRule (for
example, to give a specific symbol its own severity or rationale), the
violation is reported twice—once by _find_issue_symbol() and once by
_find_issue_pattern().

-- 
Sashiko AI review · 
https://sashiko.dev/#/patchset/[email protected]?part=3

Reply via email to