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

Extract RSpec Rails cops #1

Closed
wants to merge 20 commits into from
Closed

Extract RSpec Rails cops #1

wants to merge 20 commits into from

Conversation

ydah
Copy link
Owner

@ydah ydah commented Mar 4, 2024

No description provided.

@ydah ydah force-pushed the extract branch 2 times, most recently from 0da51f0 to 0d3abcb Compare March 4, 2024 17:56
Copy link
Contributor

@bquorning bquorning left a comment

Choose a reason for hiding this comment

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

I tried diff'ing this code against a checkout of rubocop-factory_bot and rubocop-capybara, and it looks mostly ok. There are a few differences that I’ve tried to comment on.

Rakefile Show resolved Hide resolved
config/default.yml Outdated Show resolved Hide resolved
rubocop-rspec-rails.gemspec Outdated Show resolved Hide resolved
spec/spec_helper.rb Outdated Show resolved Hide resolved
spec/spec_helper.rb Outdated Show resolved Hide resolved
tasks/cops_documentation.rake Outdated Show resolved Hide resolved
ydah and others added 2 commits March 6, 2024 23:24
Co-authored-by: Benjamin Quorning <22333+bquorning@users.noreply.github.com>
Copy link
Owner Author

@ydah ydah left a comment

Choose a reason for hiding this comment

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

I updated this PR.

Rakefile Show resolved Hide resolved
rubocop-rspec-rails.gemspec Outdated Show resolved Hide resolved
tasks/cops_documentation.rake Outdated Show resolved Hide resolved
spec/spec_helper.rb Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
rubocop-rspec-rails.gemspec Outdated Show resolved Hide resolved
@ydah ydah requested review from pirj and bquorning March 11, 2024 16:18
@ydah ydah requested a review from bquorning March 13, 2024 01:47
Co-authored-by: Benjamin Quorning <22333+bquorning@users.noreply.github.com>
@ydah ydah force-pushed the extract branch 2 times, most recently from 12a8416 to 195dbcf Compare March 13, 2024 01:54
@ydah
Copy link
Owner Author

ydah commented Mar 15, 2024

I updated this PR.

@ydah
Copy link
Owner Author

ydah commented Mar 21, 2024

@bquorning @pirj
As a result of the discussion at #1 (comment) , I've made the following changes, and I would appreciate your opinion.

  • Add rubocop-rspec to runtime dependencies
    • Remove redundant files
  • Add CI job to test rubocop-rspec edges

config/default.yml Outdated Show resolved Hide resolved
@pirj
Copy link
Contributor

pirj commented Mar 22, 2024

This is really close to readiness. Just one thing to reuse the config left. Thank you for the immense effort!

@ydah
Copy link
Owner Author

ydah commented Mar 22, 2024

@pirj Thank you for your review! I updated this PR.

@ydah ydah requested a review from pirj March 22, 2024 16:55
@bquorning
Copy link
Contributor

I’m sorry for not having had the capacity to review your PR again.

@ydah
Copy link
Owner Author

ydah commented Mar 22, 2024

@bquorning Don't worry about it. Thank you as always 😄 !

Copy link
Contributor

@pirj pirj left a comment

Choose a reason for hiding this comment

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

Thank you!

'rubygems_mfa_required' => 'true'
}

spec.add_runtime_dependency 'rubocop', '~> 1.40'
spec.add_runtime_dependency 'rubocop-capybara', '~> 2.17'
spec.add_runtime_dependency 'rubocop-factory_bot', '~> 2.22'
spec.add_runtime_dependency 'rubocop-rspec', '~> 2.27.1'
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we make it depend on 2.28.0 where all cops are extracted to prevent duplicates? I can’t recall how we did this in the past.
Point to github from Gemfile to ensure edge, release this gem first, then release rubocop-rspec 2.28.0, then change this gemfile to remove github source and point to rubygems.
I haven’t had my morning coffee yet, so please take this idea with a grain of salt.

Copy link
Owner Author

Choose a reason for hiding this comment

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

In the past we didn't need to worry about it, since rubocop-capybara and rubocop-factory_bot didn't rely on rubocop-rspec. Sorry. I want you to tell me, what kind of problem do I have if I don't depend on it after it's extracted?

Copy link
Contributor

Choose a reason for hiding this comment

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

In theory, it would be possible to install rubocop-rspec_rails 2.28.0 with rubocop-rapec 2.27.1, where the extraction didn’t happen yet.
It could happen, but seems unrealistic.
Other cases would be like the one we’ve had when we wanted to yank a certain version? In some circumstances, bundler can prefer to downgrade rubocop-rspec to this combination of versions.
rubocop/rubocop-rspec#1567

And, we should lick this to <3.0 here

Copy link
Owner Author

Choose a reason for hiding this comment

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

Thank you. Indeed it is. I update this PR 1f412fd

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see, the version in edge is 2.27.1, so it won’t work to point to it.

@bquorning @Darhazer do you foresee any issues with the current approach?

@ydah ydah requested a review from pirj March 24, 2024 15:52
@ydah
Copy link
Owner Author

ydah commented Mar 26, 2024

@bquorning @pirj @Darhazer Now that all the problems have been solved, I will proceed with the extraction if there are no other problems.

@ydah
Copy link
Owner Author

ydah commented Mar 27, 2024

Okay, I'm going to proceed with the extraction.

@ydah
Copy link
Owner Author

ydah commented Mar 27, 2024

Commands:

git clone --no-local rubocop-rspec rubocop-rspec_rails-hist
cd rubocop-rspec_rails-hist
git-filter-repo $( (cat ../rubocop-rspec_rails/rename | xargs -I_ echo '--path-rename _ ') )
git-filter-repo $( (cd ../rubocop-rspec_rails && git ls-files) | xargs -I_ echo '--path _ ')
git remote add origin git@github.com:rubocop/rubocop-rspec_rails.git
git push --set-upstream origin master
cd ../rubocop-rspec_rails
cp -r * ../rubocop-rspec_rails-hist
cp -r $( git ls-files | grep '^\.' | grep -v '\.github' ) ../rubocop-rspec_rails-hist
cp -r .github ../rubocop-rspec_rails-hist
cd -
git commit --all --message 'RSpec -> RSpecRails'
bundle install
bundle exec rake
git push origin master

rename:

docs/modules/ROOT/pages/cops_rspec_rails.adoc:docs/modules/ROOT/pages/cops_rspecrails.adoc
rubocop-rspec.gemspec:rubocop-rspec_rails.gemspec
spec/rubocop/cop/rspec/rails/avoid_setup_hook_spec.rb:spec/rubocop/cop/rspec_rails/avoid_setup_hook_spec.rb
spec/rubocop/cop/rspec/rails/have_http_status_spec.rb:spec/rubocop/cop/rspec_rails/have_http_status_spec.rb
spec/rubocop/cop/rspec/rails/http_status_spec.rb:spec/rubocop/cop/rspec_rails/http_status_spec.rb
spec/rubocop/cop/rspec/rails/inferred_spec_type_spec.rb:spec/rubocop/cop/rspec_rails/inferred_spec_type_spec.rb
spec/rubocop/cop/rspec/rails/minitest_assertions_spec.rb:spec/rubocop/cop/rspec_rails/minitest_assertions_spec.rb
spec/rubocop/cop/rspec/rails/negation_be_valid_spec.rb:spec/rubocop/cop/rspec_rails/negation_be_valid_spec.rb
spec/rubocop/cop/rspec/rails/travel_around_spec.rb:spec/rubocop/cop/rspec_rails/travel_around_spec.rb
lib/rubocop-rspec.rb:lib/rubocop-rspec_rails.rb
lib/rubocop/cop/rspec/rails/avoid_setup_hook.rb:lib/rubocop/cop/rspec_rails/avoid_setup_hook.rb
lib/rubocop/cop/rspec/rails/have_http_status.rb:lib/rubocop/cop/rspec_rails/have_http_status.rb
lib/rubocop/cop/rspec/rails/http_status.rb:lib/rubocop/cop/rspec_rails/http_status.rb
lib/rubocop/cop/rspec/rails/inferred_spec_type.rb:lib/rubocop/cop/rspec_rails/inferred_spec_type.rb
lib/rubocop/cop/rspec/rails/minitest_assertions.rb:lib/rubocop/cop/rspec_rails/minitest_assertions.rb
lib/rubocop/cop/rspec/rails/negation_be_valid.rb:lib/rubocop/cop/rspec_rails/negation_be_valid.rb
lib/rubocop/cop/rspec/rails/travel_around.rb:lib/rubocop/cop/rspec_rails/travel_around.rb
lib/rubocop/cop/rspec_cops.rb:lib/rubocop/cop/rspec_rails_cops.rb
lib/rubocop/rspec/config_formatter.rb:lib/rubocop/rspec_rails/config_formatter.rb
lib/rubocop/rspec/description_extractor.rb:lib/rubocop/rspec_rails/description_extractor.rb
lib/rubocop/rspec/version.rb:lib/rubocop/rspec_rails/version.rb

@ydah ydah closed this Mar 29, 2024
@ydah ydah deleted the extract branch March 29, 2024 11:52
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.

None yet

3 participants