Skip to content

✨ feat: Add rule name validation#1

Merged
heumsi merged 2 commits intomainfrom
feat/validate-rule-name
Mar 31, 2026
Merged

✨ feat: Add rule name validation#1
heumsi merged 2 commits intomainfrom
feat/validate-rule-name

Conversation

@heumsi
Copy link
Copy Markdown
Owner

@heumsi heumsi commented Mar 31, 2026

Summary

  • Raise ValueError when a rule name contains characters outside [a-zA-Z0-9_-] (e.g. spaces, special characters) during config loading.
  • This is a prerequisite for the upcoming inline ignore comment feature (# pnl: ignore=rule-name).

Changes

  • config.py: Add _validate_rule_name() function, called from _parse_rules()
  • test_config.py: Add parametrized tests for valid/invalid rule names

Test plan

  • Valid rule names pass (attribute-matches-type, bool_method, rule1, My-Rule_2)
  • Invalid rule names raise error (my rule, rule!name, rule name 123, rule.name, rule@name)
  • All 75 existing tests pass

🤖 Generated with Claude Code

heumsi and others added 2 commits March 31, 2026 11:49
…nderscore characters

Rule names must now match [a-zA-Z0-9_-]+. This restriction ensures
consistent naming and enables future inline ignore comments (# pnl: ignore=rule-name)
to be parsed unambiguously.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@heumsi heumsi changed the title ✨ feat: Validate rule names to allow only alphanumeric, hyphen, and underscore ✨ feat: Add rule name validation Mar 31, 2026
@heumsi heumsi merged commit 8d3bb6e into main Mar 31, 2026
5 checks passed
@heumsi heumsi deleted the feat/validate-rule-name branch March 31, 2026 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant