class

Ameba::Rule::Documentation::Admonition

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

A rule that reports documentation admonitions.

Optionally, these can fail at an appropriate time.

def get_user(id)
  # TODO(2024-04-24) Fix this hack when the database migration is complete
  if id < 1_000_000
    v1_api_call(id)
  else
    v2_api_call(id)
  end
end

TODO comments are used to remind yourself of source code related things.

The premise here is that TODO should be dealt with in the near future and are therefore reported by Ameba.

FIXME comments are used to indicate places where source code needs fixing.

The premise here is that FIXME should indeed be fixed as soon as possible and are therefore reported by Ameba.

YAML configuration example:

Documentation/Admonition:
  Enabled: true
  Admonitions: [TODO, FIXME, BUG]
  Timezone: UTC

Constants

MSG = "Found a %s admonition in a comment"
MSG_ERR = "%s admonition error: %s"
MSG_LATE = "Found a %s admonition in a comment (%s)"

Constructors

new(config = nil)

A rule that reports documentation admonitions.

Optionally, these can fail at an appropriate time.

def get_user(id)
  # TODO(2024-04-24) Fix this hack when the database migration is complete
  if id < 1_000_000
    v1_api_call(id)
  else
    v2_api_call(id)
  end
end

TODO comments are used to remind yourself of source code related things.

The premise here is that TODO should be dealt with in the near future and are therefore reported by Ameba.

FIXME comments are used to indicate places where source code needs fixing.

The premise here is that FIXME should indeed be fixed as soon as possible and are therefore reported by Ameba.

YAML configuration example:

Documentation/Admonition:
  Enabled: true
  Admonitions: [TODO, FIXME, BUG]
  Timezone: UTC
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

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