carbonfive / raygun-rails

Rails 7 application template for Raygun, the Carbon Five Rails application generator.
https://github.com/carbonfive/raygun
52 stars 26 forks source link

Rubocop offense in fresh project #595

Closed spilth closed 2 years ago

spilth commented 2 years ago

I spun up a fresh Raygun application today and got the following error while running the bin/rake command:

$ bin/rake
Running via Spring preloader in process 2499
/Users/briankelly/.rbenv/versions/2.7.2/bin/ruby -I/Users/briankelly/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rspec-core-3.10.1/lib:/Users/briankelly/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rspec-support-3.10.2/lib /Users/briankelly/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rspec-core-3.10.1/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
...

Finished in 9.51 seconds (files took 5.6 seconds to load)
3 examples, 0 failures

Running RuboCop...
Inspecting 48 files
.........................................W.....

Offenses:

spec/rails_helper.rb:26:1: W: [Correctable] Lint/NonDeterministicRequireOrder: Sort files before requiring them.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

48 files inspected, 1 offense detected, 1 offense auto-correctable
RuboCop failed!
mattbrictson commented 2 years ago

Hmm... I can't reproduce.

Could you try clearing your raygun cache in $HOME/.raygun/? Maybe it is using an old version that has this issue.

Here's what I get:

[:~/Code/scratch] $ gem install raygun
Successfully installed raygun-1.2.0
1 gem installed
[:~/Code/scratch] $ raygun hello
     ____ 
    / __ \____ ___  ______ ___  ______ 
   / /_/ / __ `/ / / / __ `/ / / / __ \ 
  / _, _/ /_/ / /_/ / /_/ / /_/ / / / / 
 /_/ |_|\__,_/\__, /\__, /\__,_/_/ /_/ 
             /____//____/ 

Raygun will create new app in directory: hello...

- Application Name: Hello
- Project Template: carbonfive/raygun-rails
- Ruby Version:     3.0.2

Checking for the latest application prototype... carbonfive/raygun-rails. Downloading... done!

Zap! Your application is ready. Next steps...

# Install updated dependencies and prepare the database
$ cd hello
$ bin/setup

# Run the specs (they should all pass)
$ bin/rake

# Run the app and check things out
$ yarn start
$ open http://localhost:3000

# For next steps like adding Bootstrap or React, check out the raygun README
$ open https://github.com/carbonfive/raygun/#next-steps

Enjoy your Carbon Five flavored Rails application!
[:~/Code/scratch] $ cd hello
[:~/Code/scratch/hello] main ± bin/setup
== Installing dependencies ==
Resolving dependencies...
The Gemfile's dependencies are satisfied
yarn install v1.22.10
[1/5] 🔍  Validating package.json...
[2/5] 🔍  Resolving packages...
[3/5] 🚚  Fetching packages...
[4/5] 🔗  Linking dependencies...
warning " > webpack-dev-server@3.11.2" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
warning "webpack-dev-server > webpack-dev-middleware@3.7.3" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
[5/5] 🔨  Building fresh packages...
✨  Done in 8.76s.

== Copying sample files ==

== Preparing database ==
Created database 'hello_development'
Created database 'hello_test'

== Removing old logs and tempfiles ==
mkdir -p tmp/sockets
mkdir -p tmp/pids
mkdir -p tmp/cache/assets

== Restarting application server ==
[:~/Code/scratch/hello] main ± bin/rake
Running via Spring preloader in process 88287
/Users/mattb/.rbenv/versions/3.0.2/bin/ruby -I/Users/mattb/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib:/Users/mattb/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-support-3.10.2/lib /Users/mattb/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
...

Finished in 6.13 seconds (files took 2.94 seconds to load)
3 examples, 0 failures

Running RuboCop...
Inspecting 48 files
................................................

48 files inspected, no offenses detected
mattbrictson commented 2 years ago

Oh wait. I see you are running Ruby 2.7 and I have 3.0. Maybe this rubocop rule behaves differently depending on the version of Ruby… 🤔

mattbrictson commented 2 years ago

Yes, I can reproduce by switching to Ruby 2.7.2.

Running RuboCop...
Inspecting 48 files
.........................................W......

Offenses:

spec/rails_helper.rb:26:1: W: [Correctable] Lint/NonDeterministicRequireOrder: Sort files before requiring them.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

48 files inspected, 1 offense detected, 1 offense auto-correctable
christiannelson commented 2 years ago

With later Ruby versions, the sort is recommended to be removed because it's no longer necessary. I think we should prioritize 3.0 over < 3.0, personally.

spilth commented 2 years ago

I agree with prioritizing 3.0. I was just using the Ruby that was already installed on my client laptop to test something out.

christiannelson commented 2 years ago

Yeah, it's good to know for sure. And thankfully these situations don't come up very often with Rubocop.

mattbrictson commented 2 years ago

Closing this as "won't fix" for now.