Ameba::Rule::Style::CallParentheses
Inherits Ameba::AST::Util < YAML::Serializable < Ameba::Rule::Base < Ameba::Config::RuleConfig < Reference < Object
A rule that enforces usage of parentheses in method or macro calls.
For example, this (and all of its variants) is considered invalid:
user.update name: "John", age: 30
And should be replaced by the following:
user.update(name: "John", age: 30)
Options
-
ExcludeMultilineCalls— controls whether multiline calls should be checked. -
ExcludeTypeDeclarations— controls whether calls with type declarations should be checked. -
ExcludeHeredocs— controls whether calls with heredoc arguments should be checked. -
ExcludedToplevelCallNames— contains a list of top-level method names that should not be checked. -
ExcludedCallNames— contains a list of non-top-level method names that should not be checked. -
ExcludedDslCallNames— contains a list of DSL method names that should not be checked.Each entry should contain a full call chain path, with method names separated by
>, e.g.properties > where, orbuilder > properties > query.Only calls with a block and no receiver are taken into account, e.g.:
class UserQuery builder do scope :default do where { deleted_at.nil? } # UserQuery > builder > scope > where end organizations.each do |org| scope "org_#{org.name.camelcase}" do where { id == org.id } # UserQuery > builder > scope > where end end end endYou can use
*as a wildcard to match any method name and**to match any method name at any depth, e.g.** > where, or** > where > *.
YAML configuration example:
Style/CallParentheses:
Enabled: true
ExcludeMultilineCalls: true
ExcludeTypeDeclarations: true
ExcludeHeredocs: true
ExcludedToplevelCallNames: [spawn, raise, super, previous_def, exit, abort, sleep, print, printf, puts, p, p!, pp, pp!, record, class_getter, class_getter?, class_getter!, class_property, class_property?, class_property!, class_setter, getter, getter?, getter!, property, property?, property!, setter, def_equals_and_hash, def_equals, def_hash, delegate, forward_missing_to, describe, context, it, pending, pending!, fail, eq, be, be_a, be_close, contain, start_with, end_with, match, use_json_discriminator]
ExcludedCallNames: [should, should_not]
ExcludedDslCallNames: []
Constants
Constructors
A rule that enforces usage of parentheses in method or macro calls.
For example, this (and all of its variants) is considered invalid:
user.update name: "John", age: 30
And should be replaced by the following:
user.update(name: "John", age: 30)
Options
-
ExcludeMultilineCalls— controls whether multiline calls should be checked. -
ExcludeTypeDeclarations— controls whether calls with type declarations should be checked. -
ExcludeHeredocs— controls whether calls with heredoc arguments should be checked. -
ExcludedToplevelCallNames— contains a list of top-level method names that should not be checked. -
ExcludedCallNames— contains a list of non-top-level method names that should not be checked. -
ExcludedDslCallNames— contains a list of DSL method names that should not be checked.Each entry should contain a full call chain path, with method names separated by
>, e.g.properties > where, orbuilder > properties > query.Only calls with a block and no receiver are taken into account, e.g.:
class UserQuery builder do scope :default do where { deleted_at.nil? } # UserQuery > builder > scope > where end organizations.each do |org| scope "org_#{org.name.camelcase}" do where { id == org.id } # UserQuery > builder > scope > where end end end endYou can use
*as a wildcard to match any method name and**to match any method name at any depth, e.g.** > where, or** > where > *.
YAML configuration example:
Style/CallParentheses:
Enabled: true
ExcludeMultilineCalls: true
ExcludeTypeDeclarations: true
ExcludeHeredocs: true
ExcludedToplevelCallNames: [spawn, raise, super, previous_def, exit, abort, sleep, print, printf, puts, p, p!, pp, pp!, record, class_getter, class_getter?, class_getter!, class_property, class_property?, class_property!, class_setter, getter, getter?, getter!, property, property?, property!, setter, def_equals_and_hash, def_equals, def_hash, delegate, forward_missing_to, describe, context, it, pending, pending!, fail, eq, be, be_a, be_close, contain, start_with, end_with, match, use_json_discriminator]
ExcludedCallNames: [should, should_not]
ExcludedDslCallNames: []
Class methods
Returns true if this rule is deprecated, false otherwise.
Returns the deprecation reason for this rule, if there is any.
Returns the documentation URL for this rule.
Ameba::Rule::Lint::Syntax.documentation_url
# => "https://crystal-ameba.org/api/master/Ameba/Rule/Lint/Syntax.html"
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."