-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
Description
Description
Style/ConstantVisibility doesn't recognize visibility declarations when multiple constants are specified together, causing false positives.
Current Behavior
These valid Ruby patterns incorrectly trigger offenses:
class Foo
BAR = 42
BAZ = 43
private_constant :BAR, :BAZ # Not recognized
endclass Foo
BAR = 42
BAZ = 43
public_constant [:BAR, :BAZ] # Not recognized
endBoth produce false positives:
Explicitly make `BAR` public or private using either `#public_constant` or `#private_constant`.
Explicitly make `BAZ` public or private using either `#public_constant` or `#private_constant`.
Expected Behavior
The cop should recognize these valid forms for both public_constant and private_constant:
- Single:
private_constant :FOO✅ (currently works) - Multiple arguments:
private_constant :FOO, :BAR❌ (doesn't work) - Array:
private_constant [:FOO, :BAR]❌ (doesn't work)
Proposed Solution
I'd like to submit a PR that:
- Enhances visibility_declaration_for? to handle multiple constant declarations
- Adds test cases for all scenarios
- Ensures all existing tests pass
Would this enhancement be welcome?