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 an error for unrecognized cop or department RSpecRails/HttpStatus when also using rubocop-rails #14

Merged
merged 1 commit into from
Mar 30, 2024

Conversation

ydah
Copy link
Member

@ydah ydah commented Mar 30, 2024

Fix: #8


Before submitting the PR make sure the following are checked:

  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • [-] Added tests.
  • [-] Updated documentation.
  • Added an entry to the CHANGELOG.md if the new code introduces user-observable changes.
  • The build (bundle exec rake) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).

@ydah ydah changed the title [Wip] Fix an error for unrecognized cop or department `RSpecRails/Htt… [Wip] Fix an error for unrecognized cop or department RSpecRails/HttpStatus when also using rubocop-rails Mar 30, 2024
@ydah ydah force-pushed the fix-error4 branch 2 times, most recently from bc7b36e to 244652e Compare March 30, 2024 17:01
@ydah ydah changed the title [Wip] Fix an error for unrecognized cop or department RSpecRails/HttpStatus when also using rubocop-rails Fix an error for unrecognized cop or department RSpecRails/HttpStatus when also using rubocop-rails Mar 30, 2024
@ydah ydah marked this pull request as ready for review March 30, 2024 17:02
@ydah ydah requested a review from a team as a code owner March 30, 2024 17:02
module Cop
class AmbiguousCopName # rubocop:disable Style/Documentation
prepend(Module.new do
def qualified_cop_name(name, path, warn: true)
Copy link
Member Author

Choose a reason for hiding this comment

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

memo) There are two possibilities: Rails/HttpStatus or RSpecRails/HttpStatus, which causes an AmbiguousCopName Error. So, as a work around, if name is' RSpec/Rails/HttpStatus', it is rigged so that an AmbiguousCopName Error does not occur.

Error: Ambiguous cop name `RSpec/Rails/HttpStatus` used in /ydah/sandbox_capybara_with_rspec/.rubocop.yml needs department qualifier. Did you mean Rails/HttpStatus or RSpecRails/HttpStatus?

Refs: https://github.com/rubocop/rubocop/blob/97814aa1628789c338e66da7c201fe46dd6aa469/lib/rubocop/cop/registry.rb#L133-L145

@ydah
Copy link
Member Author

ydah commented Mar 30, 2024

Added workaround. This is probably caused by the fact that rubocop-rails also has a cop name named Rails/HttpStatus. How about this? @rubocop/rubocop-rspec

@ydah
Copy link
Member Author

ydah commented Mar 30, 2024

I updated this PR.

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.

This is another temporary fix, right? We should consider keeping a written TODO list of things to revert in the future.

@ydah
Copy link
Member Author

ydah commented Mar 30, 2024

This is another temporary fix, right? We should consider keeping a written TODO list of things to revert in the future.

@bquorning Yes. Indeed it is. Then I will list it in Issues later.

@ydah ydah merged commit 492a3ed into master Mar 30, 2024
27 checks passed
@ydah ydah deleted the fix-error4 branch March 30, 2024 23:45
koic added a commit to koic/rubocop that referenced this pull request Apr 12, 2024
This PR prevents the following build error:

```console
NoMethodError:
  undefined method `cop_name' for nil
# ./lib/rubocop/cop/badge.rb:52:in `match?'
# ./lib/rubocop/cop/registry.rb:300:in `resolve_badge'
# ./vendor/bundle/ruby/3.3.0/gems/rubocop-rspec_rails-2.28.3/lib/rubocop-rspec_rails.rb:30:in `qualified_cop_name'
```

https://github.com/rubocop/rubocop/actions/runs/8656558784/job/23737409762

This error is due to a monkey patch in rubocop-rails_rails:
rubocop/rubocop-rspec_rails#14

The monkey patch in rubocop-rspec_rails should also be fixed, but this patch prevents RuboCop from failing due to dependencies.
RuboCop does not depend on Rails, so the ideal solution would be to remove the dependency on rubocop-rspec_rails gem.
However, this is not possible currently because rubocop-rspec is still dependent on it.
@koic koic mentioned this pull request Apr 12, 2024
8 tasks
koic added a commit to koic/rubocop that referenced this pull request Apr 12, 2024
This PR prevents the following build error:

```console
NoMethodError:
  undefined method `cop_name' for nil
# ./lib/rubocop/cop/badge.rb:52:in `match?'
# ./lib/rubocop/cop/registry.rb:300:in `resolve_badge'
# ./vendor/bundle/ruby/3.3.0/gems/rubocop-rspec_rails-2.28.3/lib/rubocop-rspec_rails.rb:30:in `qualified_cop_name'
```

https://github.com/rubocop/rubocop/actions/runs/8656558784/job/23737409762

This build error is due to a monkey patch in rubocop-rails_rails:
rubocop/rubocop-rspec_rails#14

The monkey patch in rubocop-rspec_rails should also be fixed, but this patch prevents RuboCop from failing due to dependencies.
RuboCop does not depend on Rails, so the ideal solution would be to remove the dependency on rubocop-rspec_rails gem.
However, this is not possible currently because rubocop-rspec is still dependent on it.
koic added a commit to koic/rubocop that referenced this pull request Apr 12, 2024
This PR prevents the following build error:

```console
NoMethodError:
  undefined method `cop_name' for nil
# ./lib/rubocop/cop/badge.rb:52:in `match?'
# ./lib/rubocop/cop/registry.rb:300:in `resolve_badge'
# ./vendor/bundle/ruby/3.3.0/gems/rubocop-rspec_rails-2.28.3/lib/rubocop-rspec_rails.rb:30:in `qualified_cop_name'
```

https://github.com/rubocop/rubocop/actions/runs/8656558784/job/23737409762

This build error is due to a monkey patch in rubocop-rails_rails:
rubocop/rubocop-rspec_rails#14

The monkey patch in rubocop-rspec_rails should also be fixed, but this patch prevents RuboCop from failing due to dependencies.
RuboCop does not depend on Rails, so the ideal solution would be to remove the dependency on rubocop-rspec_rails gem.
However, this is not possible currently because rubocop-rspec is still dependent on it.
koic added a commit to koic/rubocop that referenced this pull request Apr 12, 2024
This PR prevents the following build error:

```console
NoMethodError:
  undefined method `cop_name' for nil
# ./lib/rubocop/cop/badge.rb:52:in `match?'
# ./lib/rubocop/cop/registry.rb:300:in `resolve_badge'
# ./vendor/bundle/ruby/3.3.0/gems/rubocop-rspec_rails-2.28.3/lib/rubocop-rspec_rails.rb:30:in `qualified_cop_name'
```

https://github.com/rubocop/rubocop/actions/runs/8656558784/job/23737409762

This build error is due to a monkey patch in rubocop-rails_rails:
rubocop/rubocop-rspec_rails#14

The monkey patch in rubocop-rspec_rails should also be fixed, but this patch prevents RuboCop from failing due to dependencies.
RuboCop does not depend on Rails, so the ideal solution would be to remove the dependency on rubocop-rspec_rails gem.
However, this is not possible currently because rubocop-rspec is still dependent on it.
koic added a commit to koic/rubocop that referenced this pull request Apr 12, 2024
This PR prevents the following build error:

```console
NoMethodError:
  undefined method `cop_name' for nil
# ./lib/rubocop/cop/badge.rb:52:in `match?'
# ./lib/rubocop/cop/registry.rb:300:in `resolve_badge'
# ./vendor/bundle/ruby/3.3.0/gems/rubocop-rspec_rails-2.28.3/lib/rubocop-rspec_rails.rb:30:in `qualified_cop_name'
```

https://github.com/rubocop/rubocop/actions/runs/8656558784/job/23737409762

This build error is due to a monkey patch in rubocop-rails_rails:
rubocop/rubocop-rspec_rails#14

The monkey patch in rubocop-rspec_rails should also be fixed, but this patch prevents RuboCop from failing due to dependencies.
RuboCop does not depend on Rails, so the ideal solution would be to remove the dependency on rubocop-rspec_rails gem.
However, this is not possible currently because rubocop-rspec is still dependent on it.
bbatsov pushed a commit to rubocop/rubocop that referenced this pull request Apr 12, 2024
This PR prevents the following build error:

```console
NoMethodError:
  undefined method `cop_name' for nil
# ./lib/rubocop/cop/badge.rb:52:in `match?'
# ./lib/rubocop/cop/registry.rb:300:in `resolve_badge'
# ./vendor/bundle/ruby/3.3.0/gems/rubocop-rspec_rails-2.28.3/lib/rubocop-rspec_rails.rb:30:in `qualified_cop_name'
```

https://github.com/rubocop/rubocop/actions/runs/8656558784/job/23737409762

This build error is due to a monkey patch in rubocop-rails_rails:
rubocop/rubocop-rspec_rails#14

The monkey patch in rubocop-rspec_rails should also be fixed, but this patch prevents RuboCop from failing due to dependencies.
RuboCop does not depend on Rails, so the ideal solution would be to remove the dependency on rubocop-rspec_rails gem.
However, this is not possible currently because rubocop-rspec is still dependent on it.
@koic
Copy link
Member

koic commented Apr 12, 2024

@ydah It seems there is an issue with the workaround monkey patch. For more details, please see rubocop/rubocop#12836.

ydah added a commit that referenced this pull request Jun 19, 2024
remove temporary hack by #14
@ydah ydah mentioned this pull request Jun 19, 2024
3 tasks
ydah added a commit that referenced this pull request Jun 19, 2024
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.

Unrecognized cop or department RSpecRails/HttpStatus
3 participants