Skip to content

feat: support global excludes in rules.yaml config (feat #93)#94

Merged
DataDave-Dev merged 5 commits into
DataDave-Dev:mainfrom
YasserYG8:feat/global-excludes
Jul 8, 2026
Merged

feat: support global excludes in rules.yaml config (feat #93)#94
DataDave-Dev merged 5 commits into
DataDave-Dev:mainfrom
YasserYG8:feat/global-excludes

Conversation

@YasserYG8

@YasserYG8 YasserYG8 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Description

This PR introduces support for a top-level global_exclude block in .bec/rules.yaml. This enables developers to define global ignore patterns (e.g., ignoring vendor/**, build/**, or third-party dependencies) across all file-based rules in one place, avoiding configuration duplication.

Fixes #93

Key Changes

1. Global Exclude Configuration & Rules Parsing

  • src/becwright/rules.py:
    • Updated the rules loader (load_rules) to parse the top-level global_exclude list.
    • Modified the rule parser (_to_rule) to append the global excludes into each individual rule's exclude list during configuration loading.
  • schema/rules.schema.json:
    • Added the global_exclude property (type: array of strings) to the JSON Schema, ensuring editor autocompletion and structural validation.

2. Testing

  • tests/test_rules.py: Added unit tests verifying merge behavior and type-checking validations of the global_exclude array.
  • tests/test_cli_and_git.py: Added an integration test test_check_respects_global_exclude checking that files in folders defined in the global ignore patterns are successfully skipped during check runs.

Verification Results

The test suite runs fully green:

collected 297 items
======================= 297 passed in 118.98s (0:01:58) =======================

Summary by CodeRabbit

  • New Features
    • Added support for a global exclusion list in rule configuration, allowing matching files to be skipped across all file-based checks.
  • Bug Fixes
    • Excluded paths are now respected during checks, preventing files in ignored locations from triggering failures.
  • Tests
    • Added coverage for global exclusions, including successful merging with per-rule exclusions and validation for invalid configuration values.

@YasserYG8 YasserYG8 requested a review from DataDave-Dev as a code owner July 8, 2026 15:37
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a global_exclude top-level property to the rules JSON schema, updates _to_rule and load_rules in rules.py to merge global exclude patterns into each rule's per-rule exclude list, and adds unit and CLI tests validating merging behavior, type validation, and exclusion enforcement.

Changes

Global Exclude Feature

Layer / File(s) Summary
Schema definition
schema/rules.schema.json
Adds global_exclude as a top-level array of non-empty strings for glob patterns to exclude across all rules.
Rule loading and merge logic
src/becwright/rules.py
_to_rule accepts an optional global_exclude list and merges it into each rule's exclude list; load_rules extracts and validates global_exclude as a list of strings, raising RulesError otherwise, and passes it into _to_rule.
Tests for merge and validation behavior
tests/test_rules.py, tests/test_cli_and_git.py
Unit tests cover merging global_exclude with per-rule exclude and invalid-type/invalid-element error handling; a CLI test verifies becwright check skips files under excluded global patterns.

Estimated code review effort: 2 (Simple) | ~12 minutes

Possibly related PRs

  • DataDave-Dev/becwright#38: Modifies the same _to_rule/load_rules rule-construction logic in rules.py that this PR extends with global_exclude merging.
  • DataDave-Dev/becwright#41: Introduces the per-rule exclude plumbing through rule loading that this PR builds on by merging global_exclude into it.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding global excludes to rules.yaml.
Description check ✅ Passed The description covers what changed, why, and verification, but it does not follow the template headings or include a checklist.
Linked Issues check ✅ Passed The changes implement the requested root-level global_exclude config, schema validation, and rule exclusion behavior from #93.
Out of Scope Changes check ✅ Passed The diff stays focused on global_exclude support, with only a minor whitespace-only edit outside the feature work.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/becwright/rules.py`:
- Around line 91-96: The runtime validation in rules.py for global_exclude only
checks that each item is a string, so empty glob patterns can slip through
despite the schema’s minLength contract. Update the validation in the
rules-loading path that builds global_exclude to reject empty strings as well,
keeping the check aligned with _to_rule and the surrounding RulesError handling
so invalid patterns fail fast before returning the rule list.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a3bc34be-b93a-42f1-9255-1e4d6440b2d5

📥 Commits

Reviewing files that changed from the base of the PR and between 5e10f0f and 9c95341.

📒 Files selected for processing (4)
  • schema/rules.schema.json
  • src/becwright/rules.py
  • tests/test_cli_and_git.py
  • tests/test_rules.py

Comment thread src/becwright/rules.py
Comment on lines +91 to +96

global_exclude = data.get("global_exclude", [])
if not isinstance(global_exclude, list) or not all(isinstance(x, str) for x in global_exclude):
raise RulesError(f"{rules_path}: global_exclude must be a list of glob patterns.")

return [_to_rule(r, global_exclude) for r in data["rules"]] if data.get("rules") else []

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Runtime validation should reject empty strings in global_exclude.

The schema enforces "minLength": 1 on each item, but the runtime check at line 93 only validates isinstance(x, str). An empty string glob pattern in global_exclude would pass runtime validation and could match all files, silently disabling every file-based rule. Align the runtime check with the schema contract.

🛡️ Proposed fix
     global_exclude = data.get("global_exclude", [])
-    if not isinstance(global_exclude, list) or not all(isinstance(x, str) for x in global_exclude):
+    if not isinstance(global_exclude, list) or not all(isinstance(x, str) and x for x in global_exclude):
         raise RulesError(f"{rules_path}: global_exclude must be a list of glob patterns.")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
global_exclude = data.get("global_exclude", [])
if not isinstance(global_exclude, list) or not all(isinstance(x, str) for x in global_exclude):
raise RulesError(f"{rules_path}: global_exclude must be a list of glob patterns.")
return [_to_rule(r, global_exclude) for r in data["rules"]] if data.get("rules") else []
global_exclude = data.get("global_exclude", [])
if not isinstance(global_exclude, list) or not all(isinstance(x, str) and x for x in global_exclude):
raise RulesError(f"{rules_path}: global_exclude must be a list of glob patterns.")
return [_to_rule(r, global_exclude) for r in data["rules"]] if data.get("rules") else []
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/becwright/rules.py` around lines 91 - 96, The runtime validation in
rules.py for global_exclude only checks that each item is a string, so empty
glob patterns can slip through despite the schema’s minLength contract. Update
the validation in the rules-loading path that builds global_exclude to reject
empty strings as well, keeping the check aligned with _to_rule and the
surrounding RulesError handling so invalid patterns fail fast before returning
the rule list.

@DataDave-Dev DataDave-Dev merged commit 52abb7d into DataDave-Dev:main Jul 8, 2026
7 checks passed
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.

feat: support global excludes in .bec/rules.yaml

2 participants