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

An error occurred while IfUnlessModifier... #213

Closed
masterkain opened this issue May 29, 2013 · 5 comments
Closed

An error occurred while IfUnlessModifier... #213

masterkain opened this issue May 29, 2013 · 5 comments
Milestone

Comments

@masterkain
Copy link

As mentioned in the blog post about the 0.8.0 release, here's what I'm getting.

In the project (rails) root I have the file .rubocop.yml, where I attempt to define some behaviors:

LineLength:
  Enabled: false

MethodLength:
  Enabled: false

LeadingCommentSpace:
  Enabled: false

However when this file is read by rubocop I get this stack trace on every file:

An error occurred while IfUnlessModifier cop was inspecting lib/artwork_engine.rb.
undefined method `[]' for nil:NilClass
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/rubocop-0.8.0/lib/rubocop/cop/line_length.rb:19:in `max'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/rubocop-0.8.0/lib/rubocop/cop/favor_modifier.rb:23:in `check'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/rubocop-0.8.0/lib/rubocop/cop/favor_modifier.rb:53:in `on_if'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/ast-1.0.2/lib/ast/processor.rb:237:in `process'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/parser-2.0.0.beta2/lib/parser/ast/processor.rb:172:in `on_if'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/rubocop-0.8.0/lib/rubocop/cop/favor_modifier.rb:55:in `on_if'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/ast-1.0.2/lib/ast/processor.rb:237:in `process'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/parser-2.0.0.beta2/lib/parser/ast/processor.rb:125:in `on_def'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/ast-1.0.2/lib/ast/processor.rb:237:in `process'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/ast-1.0.2/lib/ast/processor.rb:253:in `block in process_all'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/ast-1.0.2/lib/ast/processor.rb:252:in `map'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/ast-1.0.2/lib/ast/processor.rb:252:in `process_all'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/parser-2.0.0.beta2/lib/parser/ast/processor.rb:6:in `process_regular_node'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/ast-1.0.2/lib/ast/processor.rb:237:in `process'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/parser-2.0.0.beta2/lib/parser/ast/processor.rb:114:in `on_class'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/ast-1.0.2/lib/ast/processor.rb:237:in `process'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/ast-1.0.2/lib/ast/processor.rb:253:in `block in process_all'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/ast-1.0.2/lib/ast/processor.rb:252:in `map'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/ast-1.0.2/lib/ast/processor.rb:252:in `process_all'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/parser-2.0.0.beta2/lib/parser/ast/processor.rb:6:in `process_regular_node'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/ast-1.0.2/lib/ast/processor.rb:237:in `process'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/rubocop-0.8.0/lib/rubocop/cop/cop.rb:50:in `inspect'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/rubocop-0.8.0/lib/rubocop/cli.rb:100:in `block in inspect_file'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/rubocop-0.8.0/lib/rubocop/cli.rb:92:in `each'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/rubocop-0.8.0/lib/rubocop/cli.rb:92:in `inspect_file'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/rubocop-0.8.0/lib/rubocop/cli.rb:59:in `block in run'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/rubocop-0.8.0/lib/rubocop/cli.rb:41:in `each'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/rubocop-0.8.0/lib/rubocop/cli.rb:41:in `run'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/rubocop-0.8.0/bin/rubocop:14:in `block in <top (required)>'
/Users/kain/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/gems/rubocop-0.8.0/bin/rubocop:13:in `<top (required)>'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/bin/rubocop:23:in `load'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@global/bin/rubocop:23:in `<main>'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@mygemset/bin/ruby_noexec_wrapper:14:in `eval'
/Users/kain/.rvm/gems/ruby-2.0.0-p195@mygemset/bin/ruby_noexec_wrapper:14:in `<main>'

Removing the file and no errors are thrown.

@jatap
Copy link

jatap commented May 29, 2013

Same error result with this environment:

Configuration file: .rubocop.yml

AllCops:
  Includes:
    - Rakefile
    - config.ru
  Excludes:
    - db/**
    - config/**
    - script/**
    - tmp/**

MethodLength:
  Max: 30

Encoding:
  Enabled: false

LineLength:
  Enabled: false

File: app/models/ability.rb

    if user.has_role? :admin
      can :manage, :all
    elsif user.has_role? :moderator
      can :crud, User
      can :dashboard, :admin
    elsif user.has_role? :user
      can :read, User
      can :dashboard, :admin
    elsif user.has_role? :guest
      can :read, User
    end

EDIT
With 0.7.2 no errors found.

@bbatsov
Copy link
Collaborator

bbatsov commented May 29, 2013

@jonas054, seems to me there is some problem with the configuration defaults. Could you take a look at this?

@jonas054
Copy link
Collaborator

Yes.

@anthonyryan1
Copy link

Same issue with the following config:

LineLength:
  Enabled: false

Tab:
  Enabled: false

# Allow the ruby 1.8 hash syntax until we drop ruby 1.8 support
HashSyntax:
  Enabled: false

@bbatsov
Copy link
Collaborator

bbatsov commented May 29, 2013

Fixed by #217.

@bbatsov bbatsov closed this as completed May 29, 2013
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

5 participants