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

Error remove brackets #1109

Closed
qichunren opened this issue May 23, 2014 · 2 comments
Closed

Error remove brackets #1109

qichunren opened this issue May 23, 2014 · 2 comments
Assignees
Labels

Comments

@qichunren
Copy link

My ENV:

➜  controllers git:(master) ✗ rubocop -v
0.22.0
➜  controllers git:(master) ✗ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.2.0]

I have code(app/controllers/application_controller.rb) like this:

  # Set application local language by current logged user, else with :'zh-CN' as default locale
  def set_locale
    # [1] pry(#<HomeController>)> current_user
    # TypeError: [1] is not a symbol

    # Correct:
    # "warden.user.user.key"=>["User", [1], "$2a$10$O46IZlHkrI5SOv3r.Ftci."]

    # Error one:
    # "warden.user.user.key"=>[[1], "$2a$10$UjRcTEy8j4FYICBFvf2qyu"]

    if (current_user rescue (session['warden.user.user.key']=nil; false))
      I18n.locale = current_user.application_locale
    else
      I18n.locale = ServerProfile.current_profile.default_application_locale rescue :'zh-CN'
    end
  end

After I invoke rubocop -a, it changed my code like this:

  # Set application local language by current logged user, else with :'zh-CN' as default locale
  def set_locale
    # [1] pry(#<HomeController>)> current_user
    # TypeError: [1] is not a symbol

    # Correct:
    # "warden.user.user.key"=>["User", [1], "$2a$10$O46IZlHkrI5SOv3r.Ftci."]

    # Error one:
    # "warden.user.user.key"=>[[1], "$2a$10$UjRcTEy8j4FYICBFvf2qyu"]

    if current_user rescue (session['warden.user.user.key'] = nil; false)
      I18n.locale = current_user.application_locale
    else
      I18n.locale = ServerProfile.current_profile.default_application_locale rescue :'zh-CN'
    end
  end

Error log is:

/Users/qichunren/code/work/luna-server/app/controllers/application_controller.rb:147: syntax error, unexpected modifier_rescue, expecting keyword_then or ';' or '\n'
    if current_user rescue (session['warden.user.user.k...
                          ^
/Users/qichunren/code/work/luna-server/app/controllers/application_controller.rb:179: syntax error, unexpected keyword_end, expecting $end
@bbatsov bbatsov added the bug label May 26, 2014
@bbatsov bbatsov self-assigned this Jun 1, 2014
@bbatsov
Copy link
Collaborator

bbatsov commented Jun 1, 2014

Thanks for reporting this. I'll have it fixed.

@bbatsov bbatsov closed this as completed in 2538dce Jun 1, 2014
@qichunren
Copy link
Author

👍

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

2 participants