From 61afa5bb2b4eff1b0cd863999c405f1abcdb6d20 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Wed, 27 Dec 2023 22:31:16 +0100 Subject: [PATCH] Add `error` to the `RescuedExceptionsVariableName#allowed_names` --- .../rule/naming/rescued_exceptions_variable_name_spec.cr | 4 ++-- src/ameba/rule/naming/rescued_exceptions_variable_name.cr | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/ameba/rule/naming/rescued_exceptions_variable_name_spec.cr b/spec/ameba/rule/naming/rescued_exceptions_variable_name_spec.cr index 4d0c3087..53a58e34 100644 --- a/spec/ameba/rule/naming/rescued_exceptions_variable_name_spec.cr +++ b/spec/ameba/rule/naming/rescued_exceptions_variable_name_spec.cr @@ -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 @@ -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 diff --git a/src/ameba/rule/naming/rescued_exceptions_variable_name.cr b/src/ameba/rule/naming/rescued_exceptions_variable_name.cr index 8dcfd1aa..f1230c51 100644 --- a/src/ameba/rule/naming/rescued_exceptions_variable_name.cr +++ b/src/ameba/rule/naming/rescued_exceptions_variable_name.cr @@ -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'"