Ameba::Rule::Style::HeredocIndent
Inherits Ameba::AST::Util < YAML::Serializable < Ameba::Rule::Base < Ameba::Config::RuleConfig < Reference < Object
A rule that enforces heredoc bodies be indented one level above the indentation of the line they're used on.
For example, this is considered invalid:
<<-HEREDOC
hello world
HEREDOC
<<-HEREDOC
hello world
HEREDOC
And should be written as:
<<-HEREDOC
hello world
HEREDOC
<<-HEREDOC
hello world
HEREDOC
The IndentBy configuration option changes the enforced indentation level
of the heredoc.
If BodyAutoDedent is enabled (default), the body of the heredoc will be
automatically dedented to the minimum indentation level of the body lines.
For example:
<<-HEREDOC
<article>
...
</article>
HEREDOC
Will be automatically dedented to:
<<-HEREDOC
<article>
...
</article>
HEREDOC
YAML configuration example:
Style/HeredocIndent:
Enabled: true
IndentBy: 2
BodyAutoDedent: true
Constants
Constructors
A rule that enforces heredoc bodies be indented one level above the indentation of the line they're used on.
For example, this is considered invalid:
<<-HEREDOC
hello world
HEREDOC
<<-HEREDOC
hello world
HEREDOC
And should be written as:
<<-HEREDOC
hello world
HEREDOC
<<-HEREDOC
hello world
HEREDOC
The IndentBy configuration option changes the enforced indentation level
of the heredoc.
If BodyAutoDedent is enabled (default), the body of the heredoc will be
automatically dedented to the minimum indentation level of the body lines.
For example:
<<-HEREDOC
<article>
...
</article>
HEREDOC
Will be automatically dedented to:
<<-HEREDOC
<article>
...
</article>
HEREDOC
YAML configuration example:
Style/HeredocIndent:
Enabled: true
IndentBy: 2
BodyAutoDedent: 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."