Ameba::Rule::Lint::ShadowedException
Inherits YAML::Serializable < Ameba::Rule::Base < Ameba::Config::RuleConfig < Reference < Object
A rule that disallows a rescued exception that gets shadowed by a less specific exception being rescued before a more specific exception is rescued.
For example, this is invalid:
begin
do_something
rescue Exception
handle_exception
rescue ArgumentError
handle_argument_error_exception
end
And it has to be written as follows:
begin
do_something
rescue ArgumentError
handle_argument_error_exception
rescue Exception
handle_exception
end
YAML configuration example:
Lint/ShadowedException:
Enabled: true
Constants
Constructors
A rule that disallows a rescued exception that gets shadowed by a less specific exception being rescued before a more specific exception is rescued.
For example, this is invalid:
begin
do_something
rescue Exception
handle_exception
rescue ArgumentError
handle_argument_error_exception
end
And it has to be written as follows:
begin
do_something
rescue ArgumentError
handle_argument_error_exception
rescue Exception
handle_exception
end
YAML configuration example:
Lint/ShadowedException:
Enabled: true
Class methods
Returns true if this rule is deprecated, false otherwise.
Returns the deprecation reason for this rule, if there is any.
Returns the documentation URL for this rule.
Ameba::Rule::Lint::Syntax.documentation_url
# => "https://crystal-ameba.org/api/master/Ameba/Rule/Lint/Syntax.html"
Returns the documentation for this rule, if there is any.
module Ameba
# This is a test rule.
# Does nothing.
class Rule::MyRule < Rule::Base
def test(source)
end
end
end
Ameba::Rule::MyRule.parsed_doc # => "This is a test rule.\nDoes nothing."