Skip to content

fix: warn when check has empty appliesTo array#698

Merged
stack72 merged 1 commit intomainfrom
fix/empty-applies-to-warning-619
Mar 12, 2026
Merged

fix: warn when check has empty appliesTo array#698
stack72 merged 1 commit intomainfrom
fix/empty-applies-to-warning-619

Conversation

@stack72
Copy link
Copy Markdown
Contributor

@stack72 stack72 commented Mar 12, 2026

Summary

  • Adds validation warning when a check has appliesTo: [] (empty array), which silently disables the check since no method name can match
  • The warning message tells the author to either remove appliesTo or populate it with method names

Addresses review feedback from #697.

Review comment #2 (execution order)

The second comment about non-deterministic check execution order across extension loads is acknowledged but not actioned. Checks are documented as stateless and independent — order should not matter. Object.entries preserves insertion order per spec, and extension merging via spread is deterministic for a given set of extensions.

Test plan

  • New test: validateModel warns when appliesTo is empty array
  • All 56 validation service tests pass

🤖 Generated with Claude Code

An empty appliesTo: [] silently disables a check since no method name
can match. The validation now catches this and warns the author to
either remove appliesTo (to run on all mutating methods) or populate it.

The second review comment about non-deterministic check execution order
across extension loads is acknowledged but not actioned — checks are
documented as stateless and independent, so order should not matter.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Review: Approved

This is a clean, focused fix that adds validation for empty appliesTo arrays in model checks.

Code Quality

  • No any types
  • AGPLv3 license headers present
  • TypeScript strict mode compliant

Domain-Driven Design

  • Appropriate enhancement to the DefaultModelValidationService domain service
  • Validation logic catches a configuration mistake that would silently disable checks
  • Error message provides actionable guidance ("Remove appliesTo to run on all mutating methods")

Test Coverage

  • New test properly validates the failure case and error message
  • Uses existing test fixtures consistently with other tests in the file

Logic Correctness

  • The check for check.appliesTo before checking length === 0 correctly handles both undefined and empty array cases
  • Error is added to the existing "Check selection" validation result, consistent with the nonexistent method validation

No blocking issues found.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Adversarial Review

I've systematically attempted to break this code across all critical dimensions. Here's my analysis:

Critical / High

None found.

Medium

None found.

Low

  1. Test assertion fragility (validation_service_test.ts:1471-1472): The test checks for substrings "empty appliesTo" and "will never run". If someone refactors the error message wording (e.g., adding quotes around appliesTo), the test would break. However, this pattern is consistent with other tests in this file, so this is accepted codebase convention rather than a defect.

Analysis Performed

Logic & Correctness:

  • Traced the check placement: correctly nested inside if (check.appliesTo) so undefined/null cases don't trigger
  • Verified against runtime behavior at method_execution_service.ts:296: if (check.appliesTo && !check.appliesTo.includes(methodName)) confirms empty arrays always filter out the check since [].includes(x) is always false
  • Error message accurately describes the behavior and suggests the correct fix

Edge Cases Tested:

  • appliesTo: undefined → outer guard prevents entry, no false positive
  • appliesTo: null → same, falsy check prevents entry
  • appliesTo: [] → correctly caught by length === 0
  • Multiple checks with one empty → each iterates independently, all are validated

Error Handling:

  • Errors properly accumulate in the errors array
  • Final result correctly uses ValidationResult.fail() when errors exist (lines 928-930)

API Contract:

  • No signature changes
  • New validation case within existing error path
  • Follows existing patterns for check validation errors

Verdict

PASS - This is a clean, minimal, and correct fix. The validation logic is sound, the test is adequate, and CI confirms all 56 validation tests pass.

@stack72 stack72 merged commit dfa7c4e into main Mar 12, 2026
7 checks passed
@stack72 stack72 deleted the fix/empty-applies-to-warning-619 branch March 12, 2026 23:24
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