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

Update rubocop-govuk to 4.0.0.pre.1 #1034

Merged
merged 11 commits into from
Mar 1, 2021
Merged

Update rubocop-govuk to 4.0.0.pre.1 #1034

merged 11 commits into from
Mar 1, 2021

Conversation

kevindew
Copy link
Member

Trello: https://trello.com/c/pqXbKZiC/215-test-rubocop-govuk-400pre1-prior-to-400-release

This bumps to the 4.0.0 pre release of rubocop-govuk which is part of trialling the new rubocop-govuk release. The gem pin to 4.0.0.pre.1 is intended to be removed once the final release of rubocop-govuk 4.0.0 is out.

Applying this revealed we were supporting a rather old Ruby version (2.4) so I've bumped our support to 2.6 and marked this as a breaking change.

This is to test the pre-release out of 4.0.0. Further details are in:
alphagov/rubocop-govuk#129
These can't be fixed without causing a backwards compatibility issue.
I've chose to disable these rules with inline comments as we want this
cop to apply for new code.

It is likely that the performance platform aspect of this code will be
removed soon (the platform is due for retirement) which will just leave
the one offence - if I remember I'll see if it can be removed on the
next major release.
This was used to shorten a class definition, I decided that this class
name wasn't too long so the simplest solution was to repeat it.
Alternative approaches seemed less idiomatic (for example defining a
variable like `cache_control_klass`).
We can't fix this violation and maintain the ability to do `require
"gds-api-adapters"` so I've updated this message to reflect that.
This updates the required ruby version of this gem to be 2.6 and sets
the .ruby-version to match. This has been done to reflect that this gem
is only tested with 2.6 and 2.7 [1].

To avoid complications in development and linting the same minor Ruby
version has been used for both, hence the regression from 2.7 to 2.6 in
the .ruby-version file.

[1]: https://github.com/alphagov/govuk-jenkinslib/blob/d5deab4438d803954ef13f94a2cfa528290932d2/vars/govuk.groovy#L617
This is a breaking change however from my brief research (searching my
machine) it doesn't seem that this is argument is used outside of this
utility. Therefore, this seems to be quite a benign breaking change.
This seems to be a widely spread convention we have that no-one seems to
know why. Removing it makes life a little simpler.
Copy link
Contributor

@leenagupte leenagupte left a comment

Choose a reason for hiding this comment

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

This is looking good 🎉. I have a couple of inline questions.

@@ -7,7 +7,7 @@ module TestHelpers
module ContentStore
include ContentItemHelpers

def content_store_endpoint(draft = false)
def content_store_endpoint(draft = false) # rubocop:disable Style/OptionalBooleanParameter
Copy link
Contributor

Choose a reason for hiding this comment

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

So the linter wants this changed to def content_store_endpoint(draft: false)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup that's correct. On the basis that method calls like content_store_endpoint(true) don't really mean anything but content_store_endpoint(draft: true) does.

I've fixed this as a breaking change in 4a7954c (though I don't think it's a breaking change that'll affect any apps as I can't find any apps - outside of this one - that use)

it "takes no args and initializes with an empty set of values" do
cache_control = CacheControl.new
cache_control = GdsApi::Response::CacheControl.new
Copy link
Contributor

Choose a reason for hiding this comment

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

Does described_class only work with RSpec?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, sadly so: minitest/minitest#526

@@ -395,7 +395,7 @@ def test_client_can_set_custom_headers_on_gets
)

assert_requested(:get, %r{/some.json}) do |request|
headers_with_uppercase_names = Hash[request.headers.collect { |key, value| [key.upcase, value] }]
headers_with_uppercase_names = request.headers.transform_keys(&:upcase)
Copy link
Contributor

Choose a reason for hiding this comment

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

Well this is much nicer!

Copy link
Contributor

@leenagupte leenagupte left a comment

Choose a reason for hiding this comment

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

Thanks for answering my questions. It all looks good to me! 👍 💯

@kevindew
Copy link
Member Author

kevindew commented Mar 1, 2021

Thanks @leenagupte 👍

@kevindew kevindew merged commit abb2f4c into master Mar 1, 2021
@kevindew kevindew deleted the rubocop-govuk-4 branch March 1, 2021 09:57
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