class

Ameba::Rule::Naming::BlockParameterName

Inherits YAML::Serializable < Ameba::Rule::Base < Ameba::Config::RuleConfig < Reference < Object

A rule that reports non-descriptive block parameter names.

Favour this:

tokens.each { |token| token.last_accessed_at = Time.utc }

Over this:

tokens.each { |t| t.last_accessed_at = Time.utc }

YAML configuration example:

Naming/BlockParameterName:
  Enabled: true
  MinNameLength: 3
  AllowNamesEndingInNumbers: true
  AllowedNames: [a, b, e, i, j, k, v, x, y, k1, k2, v1, v2, db, ex, id, io, ip, op, tx, wg, ws]
  ForbiddenNames: []

Constants

MSG = "Disallowed block parameter name found"

Constructors

new(config = nil)

A rule that reports non-descriptive block parameter names.

Favour this:

tokens.each { |token| token.last_accessed_at = Time.utc }

Over this:

tokens.each { |t| t.last_accessed_at = Time.utc }

YAML configuration example:

Naming/BlockParameterName:
  Enabled: true
  MinNameLength: 3
  AllowNamesEndingInNumbers: true
  AllowedNames: [a, b, e, i, j, k, v, x, y, k1, k2, v1, v2, db, ex, id, io, ip, op, tx, wg, ws]
  ForbiddenNames: []
Source
new(*, __context_for_yaml_serializable ctx : YAML::ParseContext, __node_for_yaml_serializable node : YAML::Nodes::Node)

Class methods

deprecated?

Returns true if this rule is deprecated, false otherwise.

deprecation_reason

Returns the deprecation reason for this rule, if there is any.

documentation_url

Returns the documentation URL for this rule.

Ameba::Rule::Lint::Syntax.documentation_url
# => "https://crystal-ameba.org/api/master/Ameba/Rule/Lint/Syntax.html"
parsed_doc

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."
to_json_schema(builder : JSON::Builder) : Nil
Source

Instance methods

allow_names_ending_in_numbers=(allow_names_ending_in_numbers : Bool)
allow_names_ending_in_numbers?
allowed_names
allowed_names=(allowed_names : Array(String))
description
description=(description : String)
enabled=(enabled : Bool)
enabled?
excluded
excluded=(excluded : Set(String) | Nil)
forbidden_names
forbidden_names=(forbidden_names : Array(String))
min_name_length
min_name_length=(min_name_length : Int32)
severity
severity=(severity : Ameba::Severity)
since_version
Source
since_version=(since_version : String)
test(source, node : Crystal::Call)
Source