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

Style/RescueEnsureAlignment cop fails when inspecting a file #2534

Closed
texpert opened this issue Dec 23, 2015 · 4 comments
Closed

Style/RescueEnsureAlignment cop fails when inspecting a file #2534

texpert opened this issue Dec 23, 2015 · 4 comments

Comments

@texpert
Copy link

texpert commented Dec 23, 2015

Hello!

Rubocop raises an error - this is the debug output:

undefined method `loc' for nil:NilClass
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/cop/style/rescue_ensure_alignment.rb:59:in `check'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/cop/style/rescue_ensure_alignment.rb:28:in `on_resbody'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/cop/commissioner.rb:37:in `block (2 levels) in on_resbody'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/cop/commissioner.rb:87:in `with_cop_error_handling'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/cop/commissioner.rb:36:in `block in on_resbody'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/cop/commissioner.rb:34:in `each'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/cop/commissioner.rb:34:in `on_resbody'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/ast-2.2.0/lib/ast/processor/mixin.rb:259:in `process'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/ast-2.2.0/lib/ast/processor/mixin.rb:276:in `block in process_all'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/ast-2.2.0/lib/ast/processor/mixin.rb:275:in `map'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/ast-2.2.0/lib/ast/processor/mixin.rb:275:in `process_all'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/parser-2.2.3.0/lib/parser/ast/processor.rb:9:in `process_regular_node'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/cop/commissioner.rb:41:in `on_rescue'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/ast-2.2.0/lib/ast/processor/mixin.rb:259:in `process'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/ast-2.2.0/lib/ast/processor/mixin.rb:276:in `block in process_all'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/ast-2.2.0/lib/ast/processor/mixin.rb:275:in `map'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/ast-2.2.0/lib/ast/processor/mixin.rb:275:in `process_all'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/parser-2.2.3.0/lib/parser/ast/processor.rb:9:in `process_regular_node'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/cop/commissioner.rb:41:in `on_module'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/ast-2.2.0/lib/ast/processor/mixin.rb:259:in `process'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/cop/commissioner.rb:53:in `investigate'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/cop/team.rb:34:in `inspect_file'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/runner.rb:190:in `inspect_file'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/runner.rb:157:in `block in do_inspection_loop'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/runner.rb:151:in `loop'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/runner.rb:151:in `do_inspection_loop'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/runner.rb:93:in `process_file'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/runner.rb:58:in `block in inspect_files'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/runner.rb:56:in `each'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/runner.rb:56:in `inspect_files'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/runner.rb:34:in `run'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/lib/rubocop/cli.rb:26:in `run'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/bin/rubocop:13:in `block in <top (required)>'
/home/thunder/.rvm/rubies/ruby-2.1.7/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
/home/thunder/.rvm/gems/ruby-2.1.7/gems/rubocop-0.35.1/bin/rubocop:12:in `<top (required)>'
/home/thunder/.rvm/gems/ruby-2.1.7/bin/rubocop:23:in `load'
/home/thunder/.rvm/gems/ruby-2.1.7/bin/rubocop:23:in `<main>'
/home/thunder/.rvm/gems/ruby-2.1.7/bin/ruby_executable_hooks:15:in `eval'
/home/thunder/.rvm/gems/ruby-2.1.7/bin/ruby_executable_hooks:15:in `<main>'
@alexdowad
Copy link
Contributor

Can you post a small excerpt of the code which causes this error?

It should be a rescue clause which is not associated with a begin..end or def..end block.

@texpert
Copy link
Author

texpert commented Dec 23, 2015

Yes, it's like this:

module SomeModule
  mattr_accessor :attr1, :attr2

... some code

rescue StandardError => e
  Rails.logger.info"'Error occured: #{e}"
end

@alexdowad
Copy link
Contributor

Aha, interesting.

On Wed, Dec 23, 2015 at 1:20 PM, Aurel Branzeanu notifications@github.com
wrote:

Yes, it's like this:

module SomeModule
mattr_accessor :attr1, :attr2

... some code

rescue StandardError => e
Rails.logger.info"'Error occured: #{e}"
end


Reply to this email directly or view it on GitHub
#2534 (comment).

@alexdowad
Copy link
Contributor

Just pushed a fix to my open PR.

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

No branches or pull requests

2 participants