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

UncommunicativeVariableName rubocop recomendation oposite to rubycritic statment #1616

Closed
Pauloparakleto opened this issue Aug 31, 2021 · 4 comments

Comments

@Pauloparakleto
Copy link

def foo
      begin
        do_something_dangerous

      rescue StandardError => e
        @result = e
      end
      @result
 end

The rucbocop says to use the famous e variable representing the error while the rubycritic says to use a better variable description. The result is a UncommunicativeVariableName, detailing my class with GoodCents::ImportCsv#build has the variable name 'e'

rubocop --version 1.18.3
rubycritic --version 4.6.1

If this is the properly place to discuss it, someone needs to reproduce it as well. Thanks in advantage.

@Drenmi
Copy link
Contributor

Drenmi commented Jan 9, 2022

Hello! 👋

Ruby core team member here. Since RuboCop has moved away from enforcing the Ruby Style Guide and towards maximum configurability, the default configuration shouldn't be treated as an authoritative source on what is "good". In most cases the default is arbitrarily chosen by the author of the cop.

You can configure the desired variable name in your .rubocop.yml like so:

Naming/RescuedExceptionsVariableName:
  PreferredName: error

@chastell
Copy link
Collaborator

(FWIW, I have feelings about just that and much prefer an explicit exception, error, or at least ex / err rather than a sole e.)

@mvz
Copy link
Collaborator

mvz commented Apr 18, 2022

I agree. @Pauloparakleto please follow @Drenmi's advice to make RuboCop and Reek work well together.

@mvz mvz closed this as completed Apr 18, 2022
@Pauloparakleto
Copy link
Author

Thanks you all, @mvz , @chastell and @Drenmi

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

4 participants