flyerhzm / rails_best_practices

a code metric tool for rails projects
http://rails-bestpractices.com
MIT License
4.17k stars 276 forks source link

Using %i() For an Empty Array Causes Freeze in config/routes.rb #270

Closed ksylvest closed 7 years ago

ksylvest commented 8 years ago

Freezes:

# config/routes.rb
Rails.application.routes.draw do
  resource :users, only: %i() do
    # ...
  end
end

Runs:

# config/routes.rb
Rails.application.routes.draw do
  resource :users, only: [] do
    # ...
  end
end
eignerchris commented 8 years ago

Also seeing this but with %w[]

eignerchris commented 8 years ago

Did a little digging. Looks like the analyzer gets stuck in a loop. I stepped through the code using pry and got the analyzer to hang. When I ctrl + c'd the process, it produced the following backtrace: https://gist.github.com/eignerchris/dfe2602f5dd039c4543b43dc5f03a97d

wata727 commented 8 years ago

This problem is caused by code_analyzer gem. I fixed this bug. https://github.com/flyerhzm/code_analyzer/pull/8 Please wait code_analyzer v0.4.7 releases, then you can fix this problem.

flyerhzm commented 8 years ago

I have released code_analyzer 0.4.7, please try again

yskkin commented 7 years ago

I encountered this problem with resources :articles, only: %I[index show] using code_analyzer 0.4.7 and rail_best_practices 1.18.1.