-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: disable Lint/DuplicateBranch #228
Conversation
I'm not sure the convention to follow here -- should the rule just be removed? Or is explicitly disabling better?
Hey Rob! It's great to hear from you and I hope you're doing well. Yeah, this is a lights-out great reason to be against this rule, and I was already on the fence. |
@@ -363,7 +363,7 @@ Lint/DeprecatedClassMethods: | |||
Lint/DeprecatedOpenSSLConstant: | |||
Enabled: true | |||
|
|||
# Disabled because it can promote code that is overly DRY at the expense of readability -- see #TODO | |||
# Disabled because it can promote code that is overly DRY at the expense of readability -- see https://github.com/testdouble/standard/pull/228 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record we just delete things from the YAML file when we remove this (I'll fix this in master). Reason being that there are so many rules out there and having to visually parse enabled/disabled stuff or commented rules is just too much work. If someone wants to know the sordid history of a particular cop they can just git log -S DuplicateBranch
and find this commit!
Landed in 0.10.2 |
Thanks Justin! Nice to hear from you too. Cheers, and thanks for the work on the great gem. |
To pull in standardrb/standard#228
* Start spiking out Region backed reports * Fix duplicate districts and blocks getting spun up * Make region type creation idempotent * Ensure the slugs stay consistent w/ source slug Need to explicitly set them from the source, otherwise facility slugs are getting set to different hings. Which is oging to lead to problems and confusion. * find the correct region * Arel deprecation error for some reason... but the find is getting to the point where it should work * Delegate assigned patients to a region's source This works for now because the source is either a facility group or a facility. This wont work once we have proper block level reports * Check district region correctly * Define singlular 'foo_region?' methods for Region instances; remove plural methods this cleans up some confusion that is a result of the rails auto-generated enum methods * Get basic region reports working duck typing where possible * Get block level reports working Need to figure out the virtual vs ActiveRecord source piece on Region * Dont try to render blocks for FacilityDistrict I'm not sure if that is a valid thing to even show .../cc harimohanraj89 do you know? * linting * Less type checks * Avoid type checks * Fix logging * Add a test for block level control rates * explain this magic number * Simplify how we get assigned_patients for a Region * remove Block, dont need it anymore * Need to return a relation, not the single model treat everything as a collection of facilities so that calling code doesn't need to worry about it * Add a better error message for FG factories w/ regions Make it easier to track down dependancy issues here as we enable regions_prep more broadly * Add block spec; render views only CI * typo * back to debug in dev; info for test * linting * Update standard To pull in standardrb/standard#228 * Remove this not needed anymore, and I don't know if itw as even working * remove dead code * better local name Co-authored-by: prabhanshuguptagit <[email protected]>
FYI - you're welcome to raise such concerns upstream as well. We welcome all feedback and we realize that often the first versions of some new cops are flawed in one way or another. We'll address that particular concern that was raised here soon. |
This cop just started hollering for us. I think this is a step back for a pretty common usage of case statements w/ enums. Here is an example from a code base I work in everyday:
In our domain the four types of facility sizes are a well know attribute on our Facility model. So when getting something like this opd_load attribute for a Facility, having the value explicitly returned for each size makes sense, even tho community is duplicated with the else clause. The else clause is handling some legacy cases for facility size (I believe, it predates me joining Simple.org) where we could have a nil size or perhaps just old, bad values.
So while the refactoring Rubocop is proposing is more DRY in the technical sense, the logic here is not duplicated. Refactoring to handle the 450 case entirely in the else clause is a step backwards in terms of our readability in our codebase. To take a cue from Sandi Metz, this rule pushes us towards the wrong abstract - Facilities with size community are not the same thing as the legacy facilities that are captured by the else clause here.
While I can see cases where you may want this cop enabled, I think this an overly strict definition of correctness that isn't in the spirit of standardrb. This is also way more than I've written about a single lint rule, so maybe I should just figure out how to turn off the rule for our project and move on 😏 .
But I think this should be off for the default looser world of standardrb - what say y'all?