Skip to content
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

Fix auto-correctable Rubocop violations (feedback addressed) #2474

Merged
merged 43 commits into from
Apr 19, 2016

Conversation

floehopper
Copy link
Contributor

Description

Supersedes #2469.

Trello card: https://trello.com/c/BqZ8i1b6

This PR fixes all the violations of cops which are supposedly auto-correctable. There are still quite a few disabled cops, but hopefully this is a good step forward.

All the commits up to and including the one fixing the Style/AndOr violations were generated using only Rubocop's auto-correct functionality by running govuk-lint-ruby --auto-correct.

The next batch of commits up to and including the one fixing the Lint/UnusedBlockArgument violations were done manually. In the middle of this batch, the commit fixing the Style/TrivialAccessors violation was done manually, because the auto-correct option didn't seem to do anything.

The commit fixing the Lint/UnusedMethodArgument violations was generated using only Rubocop's auto-correct functionality, but then the subsequent 7 commits attempt to make improvements to those auto-corrections.

Finally I've updated all the affected regression checksums in a single commit - no regression test artefacts needed to be changed to make the regression tests pass.

External changes

None. This is just an internal refactoring.

All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
It looks as if these were fixed by the previously applied fixes for the
violations of the `Style/BarePercentLiterals` cop.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
All these fixes were generated using Rubocop's auto-correct option.
I chose to fix these violations manually, because I wasn't happy with the
changes generated by Rubocop's auto-correct mechanism.
I chose to fix these violations manually, because I wasn't happy with the
changes generated by Rubocop's auto-correct mechanism.
I chose to fix some of these violations manually, because I wasn't happy with
the changes generated by Rubocop's auto-correct mechanism.

I also chose to disable the cop for a couple of the violations, because I
couldn't see a way to satisfy the cop without making the code much less
readable. The code in question is pretty horrible and will hopefully go away
when we get round to refactoring these flows. I feel that disabling the cops in
these cases just serves to highlight the problem code and should encourage us
to fix it!
I fixed these violations manually, because Rubocop's auto-correct mechanism
didn't actually do anything.
I chose to fix these violations manually, because I wasn't happy with the
changes generated by Rubocop's auto-correct mechanism.
I chose to fix these violations manually, because I wasn't happy with the
changes generated by Rubocop's auto-correct mechanism.
All these fixes were generated using Rubocop's auto-correct option.

I think the generated fixes can be improved upon, but I plan to do that in
separate commits to make the manual changes more obvious.
This method is only ever invoked from within the `show` action of this
controller and it is always invoked with a block.

This change makes explicit use of the `block` argument to make the code more
readable while continuing to avoid violating the `Lint/UnusedMethodArgument`
cop.
Instances of `HolidayEntitlement` should respond to existing methods as well as
the special formatting methods.

Note that this has allowed me to remove the leading underscore on the
`include_all` argument while still avoiding violating the
`Lint/UnusedMethodArgument` cop.
I want to supply different numbers of arguments to each of the sub-classes of
`SmartAnswer::Node` and this seems like the simplest way.
This removes the unused `_options` or `options` argument from the constructor of
`SmartAnswer::Node` and its subclasses.

This makes the arguments expected for each constructor more explicit.
I don't think this method is serving much purpose. If the `transition` method is
called on an instance of `Outcome`, a `NoMethodError` exception will be raised
which should give just as much (if not more) information than this `InvalidNode`
exception.
This means we can avoid the underscore prefix in the `_blk` argument just to
avoid the `Lint/UnusedMethodArgument` cop violation.
All these flows have been changed in the fixes for Rubocop violations. None of
them have resulted in changes to the externally-observable behaviour and all the
regression tests passed without any updates to their artefacts. Thus I'm happy
to update these checksums.
@floehopper floehopper merged commit 7d32cf8 into master Apr 19, 2016
@floehopper floehopper deleted the fix-auto-correctable-rubocop-violations branch April 19, 2016 10:26
floehopper added a commit that referenced this pull request Apr 29, 2016
I hope this might help avoid a repeat of #2474 in which the implementation of
`Outcome#transition` was accidentally removed [1].

I've also added test coverage for the rescuing of `FlowRegistry::NotFound` while
I was at it.

[1]: 0929036
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.

1 participant