Ameba::Rule::Style::HeredocEscape
Inherits Ameba::AST::Util < YAML::Serializable < Ameba::Rule::Base < Ameba::Config::RuleConfig < Reference < Object
A rule that enforces heredoc variant that escapes interpolation or control chars in a heredoc body. The opposite is enforced too - i.e. regular heredoc variant that doesn't escape interpolation or control chars in a heredoc body, when there is no need to escape it.
For example, this is considered invalid:
<<-DOC
This is an escaped \#{:interpolated} string \\n
DOC
And should be written as:
<<-'DOC'
This is an escaped #{:interpolated} string \n
DOC
YAML configuration example:
Style/HeredocEscape:
Enabled: true
Constants
Constructors
A rule that enforces heredoc variant that escapes interpolation or control chars in a heredoc body. The opposite is enforced too - i.e. regular heredoc variant that doesn't escape interpolation or control chars in a heredoc body, when there is no need to escape it.
For example, this is considered invalid:
<<-DOC
This is an escaped \#{:interpolated} string \\n
DOC
And should be written as:
<<-'DOC'
This is an escaped #{:interpolated} string \n
DOC
YAML configuration example:
Style/HeredocEscape:
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."