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

Add Ruby 3.2 to CI and update RuboCop #107

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

petergoldstein
Copy link
Contributor

This PR adds Ruby 3.2 to the CI matrix and updates RuboCop to a version that can be run with that Ruby version.

Getting everything green required:

  1. Updating the .rubocop.yml to account for Cop name changes
  2. Adding rubocop-performance to the gemspec and config
  3. Some minor changes to address lints
  4. Disabling the Lint/MissingSuper for the Timezone::Lookup::Test class, because that missing super is a deliberate strategy for that class.

Everything runs green on my fork.

Copy link
Owner

@panthomakos panthomakos 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 contributing! Sorry for the delay in responding. I have a few suggestions and questions.

test/test_timezone.rb Outdated Show resolved Hide resolved
timezone.gemspec Outdated Show resolved Hide resolved
timezone.gemspec Outdated
s.add_development_dependency('minitest', '~> 5.8')
s.add_development_dependency('rake', '~> 12')
s.add_development_dependency('rubocop', '= 0.51')
s.add_development_dependency('rubocop', '>= 0.51')
s.add_development_dependency('rubocop-performance')
Copy link
Owner

Choose a reason for hiding this comment

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

This should have a version lock as well.

@petergoldstein
Copy link
Contributor Author

So I'm getting a bundler segfault on Ruby 2.2, but everything else is green with no warnings. Not sure if you want to maintain support for 2.2 at this point.

@petergoldstein
Copy link
Contributor Author

@panthomakos For what it's worth, rerunning the 2.2 job on my fork caused it to pass.

@@ -20,7 +20,12 @@ def test_get

def test_fetch
assert Timezone.fetch('Australia/Sydney').valid?

# Explicitly testing block syntax, so disable Cop
# rubocop:disable Style/RedundantFetchBlock
Copy link
Owner

Choose a reason for hiding this comment

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

👍

config = OpenStruct.new
config.username = 'timezone'
config.request_handler = HTTPTestClientFactory.new(body)
yield config if block_given?
yield config if block
Copy link
Owner

Choose a reason for hiding this comment

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

To keep consistency with the code should we use block_given? here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a Rubocop fix - https://msp-greg.github.io/rubocop-performance/RuboCop/Cop/Performance/BlockGivenWithExplicitBlock.html

I'm not sure why the previous version would be preferable.

config = OpenStruct.new
config.api_key = 'MTIzYWJj'
config.request_handler = HTTPTestClientFactory.new(body)
yield config if block_given?
yield config if block
Copy link
Owner

Choose a reason for hiding this comment

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

Ditto here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a Rubocop fix - https://msp-greg.github.io/rubocop-performance/RuboCop/Cop/Performance/BlockGivenWithExplicitBlock.html

I'm not sure why the previous version would be preferable.

def test_test_config
Timezone::Lookup.config(:test)

assert_equal Timezone::Lookup::Test,
Timezone::Lookup.lookup.class
Timezone::Lookup.lookup.class
Copy link
Owner

Choose a reason for hiding this comment

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

Is there a cop changing this behavior and can we revert to the previous behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a spacing lint.


s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
Copy link
Owner

Choose a reason for hiding this comment

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

How come this is removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

s.executables = `git ls-files -- bin/*`
.split("\n").map { |f| File.basename(f) }

s.extra_rdoc_files = ['README.markdown', 'License.txt']
s.rdoc_options = ['--charset=UTF-8']
s.require_paths = ['lib']

s.required_ruby_version = '>= 2.2'
Copy link
Owner

Choose a reason for hiding this comment

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

I am not objected to dropping 2.2 support, but it's unclear to me why it stopped working with these changes. If it's feasible to add 3.2 support independently of the RuboCop changes to see if everything still works, I would prefer not to drop 2.2 support unnecessarily.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given that Rubocop is being run in the CI pipeline (with a Ruby version of 3.0), I'm not sure if it's feasible. I'm not going to invest the time to determine that, but you should feel free to take whatever you want from this PR and explore that.

@petergoldstein
Copy link
Contributor Author

Also worth noting that it runs green on my fork, including for 2.2 - petergoldstein#1

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