Skip to content

Use consistent ivar memoization naming style (LG-4866)#5761

Merged
zachmargolis merged 1 commit intomainfrom
margolis-consistent-ivar-naming-style
Dec 29, 2021
Merged

Use consistent ivar memoization naming style (LG-4866)#5761
zachmargolis merged 1 commit intomainfrom
margolis-consistent-ivar-naming-style

Conversation

@zachmargolis
Copy link
Contributor

  • Enforce it with rubocop

The ticket was just about the ivar names themselves, but the rubocop cop helps check that they match the method name too, which seemed worthwhile including

To pick between @variable and @_variable, I counted usages of each:

identity-idp:main> git grep "@[^_].*||=" -- 'app/*.rb' | wc -l
     190
identity-idp:main> git grep "@_.*||=" -- 'app/*.rb' | wc -l 
      35

so @variable was more prevalent, so I kept it

Comment on lines 194 to 196
def transform(algorithm)
@_transform ||= transforms_nodeset[0].xpath(
transforms_nodeset[0].xpath(
"//ds:Transform[@Algorithm='#{algorithm}']",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since there's an algorithm argument that changes the result, I decided it was safer not to memoize this one at all


# rubocop:disable Naming/MemoizedInstanceVariableName
def entry_for_current_phone
@entry ||= OtpRequestsTracker.find_or_create_with_phone_and_confirmed(phone, phone_confirmed)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could have renamed the ivar in #increment too but this seemed easier to leave as-is

end

def piv_cac_verfication_form
def piv_cac_verification_form
Copy link
Contributor

Choose a reason for hiding this comment

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

🙏🏼


def set_idv_form
@idv_form ||= Idv::PhoneForm.new(
@idv_form = Idv::PhoneForm.new(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed memoization because this is a before filter, so it's always called

@zachmargolis zachmargolis merged commit e74b849 into main Dec 29, 2021
@zachmargolis zachmargolis deleted the margolis-consistent-ivar-naming-style branch December 29, 2021 17:21
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.

2 participants