+

+ + class Ameba::Rule::Lint::MissingBlockArgument + +

+ + + + + + + +

+ + + + Overview +

+ +

A rule that disallows yielding method definitions without block argument.

+

For example, this is considered invalid:

+
def foo
+  yield 42
+end
+

And has to be written as the following:

+
def foo(&)
+  yield 42
+end
+

YAML configuration example:

+
Lint/MissingBlockArgument:
+  Enabled: true
+ + + + + +

+ + + + Included Modules +

+ + + + + + + + + + + +

+ + + + Defined in: +

+ + + + ameba/rule/lint/missing_block_argument.cr + + +
+ + + + + +

+ + + + Constant Summary +

+ +
+ +
+ MSG = "Missing anonymous block argument. Use `&` as an argument name to indicate yielding method." +
+ + +
+ + + +

+ + + + Constructors +

+ + + + +

+ + + + Class Method Summary +

+ + + + +

+ + + + Instance Method Summary +

+ + + + + + + + + +

+ + + + Constructor Detail +

+ +
+
+ + def self.new(ctx : YAML::ParseContext, node : YAML::Nodes::Node) + + # +
+ +
+
+ +
+
+ +
+
+ + def self.new(config = nil) + + # +
+ +
+ +

A rule that disallows yielding method definitions without block argument.

+

For example, this is considered invalid:

+
def foo
+  yield 42
+end
+

And has to be written as the following:

+
def foo(&)
+  yield 42
+end
+

YAML configuration example:

+
Lint/MissingBlockArgument:
+  Enabled: true
+
+ +
+
+ + [View source] + +
+
+ + + + +

+ + + + Class Method Detail +

+ +
+
+ + def self.parsed_doc : String? + + # +
+ +
+ +

Returns documentation for this rule, if there is any.

+
module Ameba
+  # This is a test rule.
+  # Does nothing.
+  class MyRule < Ameba::Rule::Base
+    def test(source)
+    end
+  end
+end
+
+MyRule.parsed_doc # => "This is a test rule.\nDoes nothing."
+
+ +
+
+ +
+
+ + + + +

+ + + + Instance Method Detail +

+ +
+
+ + def description : String + + # +
+ +
+
+ +
+
+ +
+
+ + def description=(description : String) + + # +
+ +
+
+ +
+
+ +
+
+ + def enabled=(enabled : Bool) + + # +
+ +
+
+ +
+
+ +
+
+ + def enabled? : Bool + + # +
+ +
+
+ +
+
+ +
+
+ + def excluded : Array(String)? + + # +
+ +
+
+ +
+
+ +
+
+ + def excluded=(excluded : Array(String)?) + + # +
+ +
+
+ +
+
+ +
+
+ + def severity : Ameba::Severity + + # +
+ +
+
+ +
+
+ +
+
+ + def severity=(severity : Ameba::Severity) + + # +
+ +
+
+ +
+
+ +
+
+ + def test(source, node : Crystal::Def, scope : AST::Scope) + + # +
+ +
+
+ + [View source] + +
+
+ +
+
+ + def test(source) + + # +
+ +
+
+ + [View source] + +
+
+ + + + + +