class

Ameba::Rule::Lint::SpecFocus

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

Checks if specs are focused.

In specs focus: true is mainly used to focus on a spec item locally during development. However, if such change is committed, it silently runs only focused spec on all other environment, which is undesired.

This is considered bad:

describe MyClass, focus: true do
end

describe ".new", focus: true do
end

context "my context", focus: true do
end

it "works", focus: true do
end

And it should be written as the following:

describe MyClass do
end

describe ".new" do
end

context "my context" do
end

it "works" do
end

YAML configuration example:

Lint/SpecFocus:
  Enabled: true

Constants

MSG = "Focused spec item detected"
SPEC_ITEM_NAMES = ["describe", "context", "it", "pending"] of ::String

Constructors

new(config = nil)

Checks if specs are focused.

In specs focus: true is mainly used to focus on a spec item locally during development. However, if such change is committed, it silently runs only focused spec on all other environment, which is undesired.

This is considered bad:

describe MyClass, focus: true do
end

describe ".new", focus: true do
end

context "my context", focus: true do
end

it "works", focus: true do
end

And it should be written as the following:

describe MyClass do
end

describe ".new" do
end

context "my context" do
end

it "works" do
end

YAML configuration example:

Lint/SpecFocus:
  Enabled: true
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)
severity
severity=(severity : Ameba::Severity)
since_version
Source
since_version=(since_version : String)
test(source, node : Crystal::Call)
Source
test(source)
Source