Skip to content

Add error to the RescuedExceptionsVariableName#allowed_names #438

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

Merged
merged 1 commit into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module Ameba::Rule::Naming
def foo
raise "foo"
rescue wtf
# ^^^^^^^^ error: Disallowed variable name, use one of these instead: 'e', 'ex', 'exception'
# ^^^^^^^^ error: Disallowed variable name, use one of these instead: 'e', 'ex', 'exception', 'error'
nil
end
CRYSTAL
Expand All @@ -31,7 +31,7 @@ module Ameba::Rule::Naming
context "#allowed_names" do
it "returns sensible defaults" do
rule = RescuedExceptionsVariableName.new
rule.allowed_names.should eq %w[e ex exception]
rule.allowed_names.should eq %w[e ex exception error]
end

it "allows setting custom names" do
Expand Down
4 changes: 2 additions & 2 deletions src/ameba/rule/naming/rescued_exceptions_variable_name.cr
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ module Ameba::Rule::Naming
# ```
# Naming/RescuedExceptionsVariableName:
# Enabled: true
# AllowedNames: [e, ex, exception]
# AllowedNames: [e, ex, exception, error]
# ```
class RescuedExceptionsVariableName < Base
properties do
description "Makes sure that rescued exceptions variables are named as expected"
allowed_names %w[e ex exception]
allowed_names %w[e ex exception error]
end

MSG = "Disallowed variable name, use one of these instead: '%s'"
Expand Down