Skip to content

Commit

Permalink
Merge pull request #438 from crystal-ameba/add-error-as-allowed-varia…
Browse files Browse the repository at this point in the history
…ble-name

Add `error` to the `RescuedExceptionsVariableName#allowed_names`
  • Loading branch information
Sija authored Dec 28, 2023
2 parents 9bb6c9a + 61afa5b commit 46a42ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit 46a42ee

Please sign in to comment.