Skip to content

Commit

Permalink
Disable Naming/VariableNumber
Browse files Browse the repository at this point in the history
This rule enforces whether numbers are prefixed with underscores in
variable names, for example normalcase is var1 and snake_case is var_1.
Applying this rule to GOV.UK projects has been challenging and has
presented concerns about reduced readability [1]

In Rubocop 1.2.0 this cop was extended to enforce method names and
symbols. This looked to present further readability concerns for GOV.UK
and a large amount of code that would need fixing, as GOV.UK has tended
to favour snake_case for these by precedence.

It would make sense to adopt snake_case, if we were forced to choose a
convention, over normalcase given the existing precedence in GOV.UK.
However as we have previously used the normalcase rule switching to this
would create further churn to be fixed. The simplest approach therefore
seems to be disabling this rule and accepting both normalcase and
snake_case as valid approaches in our naming.

[1]: alphagov/smart-answers@54c1295
  • Loading branch information
kevindew committed Feb 16, 2021
1 parent 9fac9f6 commit 7437126
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Downgrade local Ruby version to `2.6.6` to capture lowest supported
Ruby version
- Fix namespace change of `Capybara/FeatureMethods`
- Disable `Naming/VariableNumbers`

# 3.17.2

Expand Down
7 changes: 7 additions & 0 deletions config/naming.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ Naming/AccessorMethodName:
# repos, which would require manual intervention.
Naming/PredicateName:
Enabled: false

# This rule can cause readability issues when applied (for example
# `born_on_or_before_6_april_1935` becomes `born_on_or_before_6april1935`)
# and would require lots of amends to apply either `normalcase`
# or `snake_case` to projects. It is not auto-correctable.
Naming/VariableNumber:
Enabled: false

0 comments on commit 7437126

Please sign in to comment.