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

Various cops crash when .rubocop.yml is missing #637

Closed
mensfeld opened this issue Jun 12, 2018 · 14 comments
Closed

Various cops crash when .rubocop.yml is missing #637

mensfeld opened this issue Jun 12, 2018 · 14 comments
Labels

Comments

@mensfeld
Copy link

Steps to reproduce:

git clone https://github.com/mensfeld/broken-rubocop-rspec3
cd broken-rubocop-rspec3
./run.sh

Output:

Using ast 2.4.0
Using bundler 1.16.2
Using jaro_winkler 1.5.1
Using parallel 1.12.1
Using parser 2.5.1.0
Using powerpack 0.1.2
Using rainbow 3.0.0
Using ruby-progressbar 1.9.0
Using unicode-display_width 1.4.0
Using rubocop 0.57.2
Using rubocop-rspec 1.26.0
Bundle complete! 2 Gemfile dependencies, 11 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Inspecting 2 files
.An error occurred while RSpec/DescribedClass cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:1:0.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/ExpectChange cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:1:0.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/ExpectChange cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:1:0.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/ExpectChange cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:2:2.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/ExpectChange cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:2:2.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/ExpectChange cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:4:2.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/ExpectChange cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:4:2.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/OverwritingSetup cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:1:0.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/PredicateMatcher cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:1:0.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/PredicateMatcher cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:1:0.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/PredicateMatcher cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:2:2.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/PredicateMatcher cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:2:2.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/PredicateMatcher cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:4:2.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/PredicateMatcher cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:4:2.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/ItBehavesLike cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:1:0.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/ItBehavesLike cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:2:2.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/ItBehavesLike cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:4:2.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/NotToNot cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:1:0.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/NotToNot cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:2:2.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/NotToNot cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:4:2.
To see the complete backtrace run rubocop -d.
An error occurred while RSpec/ExampleLength cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:4:2.
To see the complete backtrace run rubocop -d.
C

Offenses:

spec/example_spec.rb:1:1: C: RSpec/FilePath: Spec path should end with anything*_spec.rb.
describe Anything do
^^^^^^^^^^^^^^^^^

2 files inspected, 1 offense detected

21 errors occurred:
An error occurred while RSpec/DescribedClass cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:1:0.
An error occurred while RSpec/ExpectChange cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:1:0.
An error occurred while RSpec/ExpectChange cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:1:0.
An error occurred while RSpec/ExpectChange cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:2:2.
An error occurred while RSpec/ExpectChange cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:2:2.
An error occurred while RSpec/ExpectChange cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:4:2.
An error occurred while RSpec/ExpectChange cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:4:2.
An error occurred while RSpec/OverwritingSetup cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:1:0.
An error occurred while RSpec/PredicateMatcher cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:1:0.
An error occurred while RSpec/PredicateMatcher cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:1:0.
An error occurred while RSpec/PredicateMatcher cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:2:2.
An error occurred while RSpec/PredicateMatcher cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:2:2.
An error occurred while RSpec/PredicateMatcher cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:4:2.
An error occurred while RSpec/PredicateMatcher cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:4:2.
An error occurred while RSpec/ItBehavesLike cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:1:0.
An error occurred while RSpec/ItBehavesLike cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:2:2.
An error occurred while RSpec/ItBehavesLike cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:4:2.
An error occurred while RSpec/NotToNot cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:1:0.
An error occurred while RSpec/NotToNot cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:2:2.
An error occurred while RSpec/NotToNot cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:4:2.
An error occurred while RSpec/ExampleLength cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:4:2.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop-hq/rubocop/issues

It crashes when executed following way:

bundle exec rubocop --only RSpec --require rubocop-rspec
@Darhazer Darhazer added the bug label Jun 12, 2018
@Darhazer
Copy link
Member

Seems the same issue as in #613

@mensfeld
Copy link
Author

mensfeld commented Jun 12, 2018

@Darhazer not really. I mean I don't have a rubocop config and all of it relies on the default once. In case no pattern is present, shouldn't it just ignore this file?

@mensfeld
Copy link
Author

mensfeld commented Jun 12, 2018

@Darhazer as an update. With following config still fails (although less drastically):

require: rubocop-rspec

AllCops:
  Include:
    - spec/**/*_spec.rb
An error occurred while RSpec/OverwritingSetup cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:1:0.
To see the complete backtrace run rubocop -d.
C

Offenses:

spec/example_spec.rb:1:1: C: RSpec/FilePath: Spec path should end with anything*_spec.rb.
describe Anything do
^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected

1 error occurred:
An error occurred while RSpec/OverwritingSetup cop was inspecting /home/mencio/Pulpit/broken-rubocop-rspec3/spec/example_spec.rb:1:0.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop-hq/rubocop/issues

Mention the following information in the issue report:
0.57.2 (using Parser 2.5.1.0, running on ruby 2.5.1 x86_64-linux)

@bquorning
Copy link
Collaborator

bquorning commented Jun 12, 2018

Ah, I think that is the “forgotten” issue from #613 (comment)

The “nothing works when there is no .rubocop.yml file” seems to have been present for a long, long time. Let’s leave that one for now.

Thanks for opening a new issue.

@mensfeld
Copy link
Author

@bquorning as I said - when I have a small rubocop.yml with the config as followed:

require: rubocop-rspec

AllCops:
  Include:
    - spec/**/*_spec.rb

it also fails. Just less drastically (but still). Probably due to a space between let and the name:

let (:a) { 1 }

@bquorning
Copy link
Collaborator

Again with reporting two bugs at the same time 😄

I’ll take a look at then both.

@bquorning
Copy link
Collaborator

That issue is actually a duplicate of #624, which has a proposed fix in #625.

@mensfeld
Copy link
Author

Again with reporting two bugs at the same time
Sorry ;) I run rubocop-rspec couple thousand of times for multiple projects automatically, so you can always ping me with a prerelease and we can give it a spin ;)

@dgollahon dgollahon changed the title Multiple RSpec cops crash when running rubocop-rspec for a certain simple example Various cops crash when running .rubocop.yml is missing Jun 15, 2018
@dgollahon
Copy link
Contributor

@mensfeld Looks like all the other issues have been fixed as of 1.27.0 (thanks for the great reproduction script!) but the missing .rubocop.yml issue persists, so I've updated the title.

@mensfeld
Copy link
Author

@dgollahon any time. As I said, I run this stuff a lot for many codebases (hundreds) so always after upgrades I see many errors ;)

@dgollahon
Copy link
Contributor

I run this stuff a lot for many codebases (hundreds)

Just curious, what causes you to run it for hundreds of codebases? Do you have that many projects that you oversee? Or is there some other supporting reason?

@mensfeld
Copy link
Author

@dgollahon I run self-hosted service for analyzing ruby repos: https://coditsu.io/
You can check it out here: https://app.coditsu.io/karafka/commit_builds and for example results from rubocop rspec: https://app.coditsu.io/karafka/builds/validations/6ea37309-98f8-4d46-ae31-0b537db06b6a/offenses

This allows me to bump single instance of rubocop-rspec (as well as other tools) and rerun many analysis for all the projects, so there is no need to have anything apart from business and specs within repositories. Makes management much easier. I've built it after years of building simple scripts and tools for exactly that job.

@dgollahon
Copy link
Contributor

@mensfeld neat 👍

@dgollahon dgollahon changed the title Various cops crash when running .rubocop.yml is missing Various cops crash when .rubocop.yml is missing Jun 16, 2018
@bquorning
Copy link
Collaborator

I tried to reproduce this issue in various versions of RuboCop today, and it looks like it was fixed by rubocop/rubocop#7632 in RuboCop v0.82.0.

Please re-open if you are still running into this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants