Skip to content

Commit 398eaae

Browse files
authored
Enable Style/RedundantSelf RuboCop cop (#144)
Enables the `Style/RedundantSelf` cop in `RuboCop` configuration and removes redundant self references in `UswdsFormBuilder#initialize`. This cop helps maintain cleaner, more idiomatic Ruby code by flagging unnecessary uses of `self.` In Ruby, explicit self is only required when calling setter methods or disambiguating in specific contexts. Removing redundant self references reduces visual noise and aligns with Ruby community style conventions. **References:** https://docs.rubocop.org/rubocop/cops_style.html#styleredundantself https://rubystyle.guide/#no-self-unless-required
1 parent a793c29 commit 398eaae

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

template/{{app_name}}/.rubocop.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ RSpecRails/HttpStatusNameConsistency:
2222

2323
Style/FrozenStringLiteralComment:
2424
Enabled: true
25+
Style/RedundantSelf:
26+
Enabled: true

template/{{app_name}}/app/helpers/uswds_form_builder.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class UswdsFormBuilder < ActionView::Helpers::FormBuilder
1010

1111
def initialize(*args)
1212
super
13-
self.options[:html] ||= {}
14-
self.options[:html][:class] ||= "usa-form usa-form--large"
13+
options[:html] ||= {}
14+
options[:html][:class] ||= "usa-form usa-form--large"
1515
end
1616

1717
########################################

0 commit comments

Comments
 (0)