class

Ameba::Rule::Style::LargeNumbers

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

A rule that disallows usage of large numbers without underscore. These do not affect the value of the number, but can help read large numbers more easily.

For example, these are considered invalid:

100000
141592654
5.123456

And has to be rewritten as the following:

100_000
141_592_654
5.123_456

YAML configuration example:

Style/LargeNumbers:
  Enabled: true
  IntMinDigits: 6 # i.e. integers higher than 99999

Constants

MSG = "Large numbers should be written with underscores: `%s`"

Constructors

new(config = nil)

A rule that disallows usage of large numbers without underscore. These do not affect the value of the number, but can help read large numbers more easily.

For example, these are considered invalid:

100000
141592654
5.123456

And has to be rewritten as the following:

100_000
141_592_654
5.123_456

YAML configuration example:

Style/LargeNumbers:
  Enabled: true
  IntMinDigits: 6 # i.e. integers higher than 99999
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

description
description=(description : String)
enabled=(enabled : Bool)
enabled?
excluded
excluded=(excluded : Set(String) | Nil)
int_min_digits
int_min_digits=(int_min_digits : Int32)
severity
severity=(severity : Ameba::Severity)
since_version
Source
since_version=(since_version : String)
test(source)
Source