Deploying to gh-pages from @ 48b15b9bf8 🚀

This commit is contained in:
Sija 2021-10-19 09:45:33 +00:00
parent 42809c9681
commit f760465482
106 changed files with 5612 additions and 4623 deletions

View file

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Crystal Docs 0.36.1">
<meta name="generator" content="Crystal Docs 1.1.1">
<meta name="crystal_docs.project_version" content="master">
<meta name="crystal_docs.project_name" content="ameba">
@ -286,6 +286,11 @@
<ul>
<li class=" " data-id="ameba/Ameba/Rule/Lint/AmbiguousAssignment" data-name="ameba::rule::lint::ambiguousassignment">
<a href="../../../Ameba/Rule/Lint/AmbiguousAssignment.html">AmbiguousAssignment</a>
</li>
<li class=" " data-id="ameba/Ameba/Rule/Lint/BadDirective" data-name="ameba::rule::lint::baddirective">
<a href="../../../Ameba/Rule/Lint/BadDirective.html">BadDirective</a>
@ -640,19 +645,13 @@
</h2>
<p>This rule is used to identify usage of <code>any?</code> calls that follow filters.</p>
<p>For example, this is considered invalid:</p>
<pre><code class="language-crystal">[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].<span class="k">select</span> { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">2</span> }.any?
[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].reject { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;=</span> <span class="n">2</span> }.any?</code></pre>
<p>And it should be written as this:</p>
<pre><code class="language-crystal">[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].any? { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">2</span> }
[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].any? { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&lt;</span> <span class="n">2</span> }</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/AnyAfterFilter:
Enabled: true
FilterNames:
@ -698,7 +697,7 @@
</h2>
<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/any_after_filter.cr#L29" target="_blank">
<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/any_after_filter.cr#L29" target="_blank">
ameba/rule/performance/any_after_filter.cr
</a>
@ -744,14 +743,14 @@
<ul class="list-summary">
<li class="entry-summary">
<a href="#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method" class="signature"><strong>.new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)</a>
<a href="#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method" class="signature"><strong>.new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)</a>
<div class="summary"><p>This rule is used to identify usage of <code>any?</code> calls that follow filters.</p></div>
</li>
<li class="entry-summary">
<a href="#new(config=nil)-class-method" class="signature"><strong>.new</strong>(config = <span class="n">nil</span>)</a>
<a href="#new%28config%3Dnil%29-class-method" class="signature"><strong>.new</strong>(config = <span class="n">nil</span>)</a>
<div class="summary"><p>This rule is used to identify usage of <code>any?</code> calls that follow filters.</p></div>
@ -774,57 +773,57 @@
<ul class="list-summary">
<li class="entry-summary">
<a href="#description:String-instance-method" class="signature"><strong>#description</strong> : String</a>
<a href="#description%3AString-instance-method" class="signature"><strong>#description</strong> : String</a>
</li>
<li class="entry-summary">
<a href="#description=(description:String)-instance-method" class="signature"><strong>#description=</strong>(description : String)</a>
<a href="#description%3D%28description%3AString%29-instance-method" class="signature"><strong>#description=</strong>(description : String)</a>
</li>
<li class="entry-summary">
<a href="#enabled:Bool-instance-method" class="signature"><strong>#enabled</strong> : Bool</a>
<a href="#enabled%3ABool-instance-method" class="signature"><strong>#enabled</strong> : Bool</a>
</li>
<li class="entry-summary">
<a href="#enabled=(enabled)-instance-method" class="signature"><strong>#enabled=</strong>(enabled)</a>
<a href="#enabled%3D%28enabled%29-instance-method" class="signature"><strong>#enabled=</strong>(enabled)</a>
</li>
<li class="entry-summary">
<a href="#excluded:Array(String)?-instance-method" class="signature"><strong>#excluded</strong> : Array(String)?</a>
<a href="#excluded%3AArray%28String%29%3F-instance-method" class="signature"><strong>#excluded</strong> : Array(String)?</a>
</li>
<li class="entry-summary">
<a href="#excluded=(excluded:Array(String)?)-instance-method" class="signature"><strong>#excluded=</strong>(excluded : Array(String)?)</a>
<a href="#excluded%3D%28excluded%3AArray%28String%29%3F%29-instance-method" class="signature"><strong>#excluded=</strong>(excluded : Array(String)?)</a>
</li>
<li class="entry-summary">
<a href="#filter_names:Array(String)-instance-method" class="signature"><strong>#filter_names</strong> : Array(String)</a>
<a href="#filter_names%3AArray%28String%29-instance-method" class="signature"><strong>#filter_names</strong> : Array(String)</a>
</li>
<li class="entry-summary">
<a href="#filter_names=(filter_names:Array(String))-instance-method" class="signature"><strong>#filter_names=</strong>(filter_names : Array(String))</a>
<a href="#filter_names%3D%28filter_names%3AArray%28String%29%29-instance-method" class="signature"><strong>#filter_names=</strong>(filter_names : Array(String))</a>
</li>
<li class="entry-summary">
<a href="#severity:Ameba::Severity-instance-method" class="signature"><strong>#severity</strong> : Ameba::Severity</a>
<a href="#severity%3AAmeba%3A%3ASeverity-instance-method" class="signature"><strong>#severity</strong> : Ameba::Severity</a>
</li>
<li class="entry-summary">
<a href="#severity=(severity)-instance-method" class="signature"><strong>#severity=</strong>(severity)</a>
<a href="#severity%3D%28severity%29-instance-method" class="signature"><strong>#severity=</strong>(severity)</a>
</li>
<li class="entry-summary">
<a href="#test(source,node:Crystal::Call)-instance-method" class="signature"><strong>#test</strong>(source, node : Crystal::Call)</a>
<a href="#test%28source%2Cnode%3ACrystal%3A%3ACall%29-instance-method" class="signature"><strong>#test</strong>(source, node : Crystal::Call)</a>
</li>
@ -861,7 +860,7 @@
<h3>Instance methods inherited from class <code><a href="../../../Ameba/Rule/Performance/Base.html">Ameba::Rule::Performance::Base</a></code></h3>
<a href="../../../Ameba/Rule/Performance/Base.html#catch(source:Source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Performance/Base.html#catch%28source%3ASource%29-instance-method" class="tooltip">
<span>catch(source : Source)</span>
catch</a>
@ -873,7 +872,7 @@
<h3>Constructor methods inherited from class <code><a href="../../../Ameba/Rule/Performance/Base.html">Ameba::Rule::Performance::Base</a></code></h3>
<a href="../../../Ameba/Rule/Performance/Base.html#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method" class="tooltip">
<a href="../../../Ameba/Rule/Performance/Base.html#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method" class="tooltip">
<span>new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)<br/>new(config = <span class="n">nil</span>)</span>
new</a>
@ -909,17 +908,17 @@
<h3>Instance methods inherited from class <code><a href="../../../Ameba/Rule/Base.html">Ameba::Rule::Base</a></code></h3>
<a href="../../../Ameba/Rule/Base.html#==(other)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#%3D%3D%28other%29-instance-method" class="tooltip">
<span>==(other)</span>
==</a>,
<a href="../../../Ameba/Rule/Base.html#catch(source:Source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#catch%28source%3ASource%29-instance-method" class="tooltip">
<span>catch(source : Source)</span>
catch</a>,
<a href="../../../Ameba/Rule/Base.html#excluded?(source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#excluded%3F%28source%29-instance-method" class="tooltip">
<span>excluded?(source)</span>
excluded?</a>,
@ -939,12 +938,12 @@
name</a>,
<a href="../../../Ameba/Rule/Base.html#special?-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#special%3F-instance-method" class="tooltip">
<span>special?</span>
special?</a>,
<a href="../../../Ameba/Rule/Base.html#test(source:Source,node:Crystal::ASTNode,*opts)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#test%28source%3ASource%2Cnode%3ACrystal%3A%3AASTNode%2C%2Aopts%29-instance-method" class="tooltip">
<span>test(source : Source, node : Crystal::ASTNode, *opts)<br/>test(source : Source)</span>
test</a>
@ -1014,25 +1013,19 @@
def self.<strong>new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
<a class="method-permalink" href="#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method">#</a>
<a class="method-permalink" href="#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method">#</a>
</div>
<div class="doc">
<p>This rule is used to identify usage of <code>any?</code> calls that follow filters.</p>
<p>For example, this is considered invalid:</p>
<pre><code class="language-crystal">[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].<span class="k">select</span> { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">2</span> }.any?
[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].reject { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;=</span> <span class="n">2</span> }.any?</code></pre>
<p>And it should be written as this:</p>
<pre><code class="language-crystal">[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].any? { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">2</span> }
[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].any? { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&lt;</span> <span class="n">2</span> }</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/AnyAfterFilter:
Enabled: true
FilterNames:
@ -1051,25 +1044,19 @@
def self.<strong>new</strong>(config = <span class="n">nil</span>)
<a class="method-permalink" href="#new(config=nil)-class-method">#</a>
<a class="method-permalink" href="#new%28config%3Dnil%29-class-method">#</a>
</div>
<div class="doc">
<p>This rule is used to identify usage of <code>any?</code> calls that follow filters.</p>
<p>For example, this is considered invalid:</p>
<pre><code class="language-crystal">[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].<span class="k">select</span> { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">2</span> }.any?
[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].reject { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;=</span> <span class="n">2</span> }.any?</code></pre>
<p>And it should be written as this:</p>
<pre><code class="language-crystal">[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].any? { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">2</span> }
[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].any? { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&lt;</span> <span class="n">2</span> }</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/AnyAfterFilter:
Enabled: true
FilterNames:
@ -1080,7 +1067,7 @@
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/any_after_filter.cr#L29" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/any_after_filter.cr#L29" target="_blank">View source</a>]
</div>
</div>
@ -1104,7 +1091,7 @@
def <strong>description</strong> : String
<a class="method-permalink" href="#description:String-instance-method">#</a>
<a class="method-permalink" href="#description%3AString-instance-method">#</a>
</div>
<br/>
@ -1118,7 +1105,7 @@
def <strong>description=</strong>(description : String)
<a class="method-permalink" href="#description=(description:String)-instance-method">#</a>
<a class="method-permalink" href="#description%3D%28description%3AString%29-instance-method">#</a>
</div>
<br/>
@ -1132,7 +1119,7 @@
def <strong>enabled</strong> : Bool
<a class="method-permalink" href="#enabled:Bool-instance-method">#</a>
<a class="method-permalink" href="#enabled%3ABool-instance-method">#</a>
</div>
<br/>
@ -1146,7 +1133,7 @@
def <strong>enabled=</strong>(enabled)
<a class="method-permalink" href="#enabled=(enabled)-instance-method">#</a>
<a class="method-permalink" href="#enabled%3D%28enabled%29-instance-method">#</a>
</div>
<br/>
@ -1160,7 +1147,7 @@
def <strong>excluded</strong> : Array(String)?
<a class="method-permalink" href="#excluded:Array(String)?-instance-method">#</a>
<a class="method-permalink" href="#excluded%3AArray%28String%29%3F-instance-method">#</a>
</div>
<br/>
@ -1174,7 +1161,7 @@
def <strong>excluded=</strong>(excluded : Array(String)?)
<a class="method-permalink" href="#excluded=(excluded:Array(String)?)-instance-method">#</a>
<a class="method-permalink" href="#excluded%3D%28excluded%3AArray%28String%29%3F%29-instance-method">#</a>
</div>
<br/>
@ -1188,7 +1175,7 @@
def <strong>filter_names</strong> : Array(String)
<a class="method-permalink" href="#filter_names:Array(String)-instance-method">#</a>
<a class="method-permalink" href="#filter_names%3AArray%28String%29-instance-method">#</a>
</div>
<br/>
@ -1202,7 +1189,7 @@
def <strong>filter_names=</strong>(filter_names : Array(String))
<a class="method-permalink" href="#filter_names=(filter_names:Array(String))-instance-method">#</a>
<a class="method-permalink" href="#filter_names%3D%28filter_names%3AArray%28String%29%29-instance-method">#</a>
</div>
<br/>
@ -1216,7 +1203,7 @@
def <strong>severity</strong> : <a href="../../../Ameba/Severity.html">Ameba::Severity</a>
<a class="method-permalink" href="#severity:Ameba::Severity-instance-method">#</a>
<a class="method-permalink" href="#severity%3AAmeba%3A%3ASeverity-instance-method">#</a>
</div>
<br/>
@ -1230,7 +1217,7 @@
def <strong>severity=</strong>(severity)
<a class="method-permalink" href="#severity=(severity)-instance-method">#</a>
<a class="method-permalink" href="#severity%3D%28severity%29-instance-method">#</a>
</div>
<br/>
@ -1244,13 +1231,13 @@
def <strong>test</strong>(source, node : Crystal::Call)
<a class="method-permalink" href="#test(source,node:Crystal::Call)-instance-method">#</a>
<a class="method-permalink" href="#test%28source%2Cnode%3ACrystal%3A%3ACall%29-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/any_after_filter.cr#L38" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/any_after_filter.cr#L38" target="_blank">View source</a>]
</div>
</div>

View file

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Crystal Docs 0.36.1">
<meta name="generator" content="Crystal Docs 1.1.1">
<meta name="crystal_docs.project_version" content="master">
<meta name="crystal_docs.project_name" content="ameba">
@ -286,6 +286,11 @@
<ul>
<li class=" " data-id="ameba/Ameba/Rule/Lint/AmbiguousAssignment" data-name="ameba::rule::lint::ambiguousassignment">
<a href="../../../Ameba/Rule/Lint/AmbiguousAssignment.html">AmbiguousAssignment</a>
</li>
<li class=" " data-id="ameba/Ameba/Rule/Lint/BadDirective" data-name="ameba::rule::lint::baddirective">
<a href="../../../Ameba/Rule/Lint/BadDirective.html">BadDirective</a>
@ -640,23 +645,16 @@
</h2>
<p>This rule is used to identify usage of arg-less <code>Enumerable#any?</code> calls.</p>
<p>Using <code>Enumerable#any?</code> instead of <code>Enumerable#empty?</code> might lead to an
unexpected results (like <code>[nil, false].any? # => false</code>). In some cases
it also might be less efficient, since it iterates until the block will
return a <em>truthy</em> value, instead of just checking if there's at least
one value present.</p>
<p>For example, this is considered invalid:</p>
<pre><code class="language-crystal">[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].any?</code></pre>
<p>And it should be written as this:</p>
<pre><code class="language-crystal"><span class="o">!</span>[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].empty?</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/AnyInsteadOfEmpty:
Enabled: true</code></pre>
@ -699,7 +697,7 @@ one value present.</p>
</h2>
<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/any_instead_of_empty.cr#L30" target="_blank">
<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/any_instead_of_empty.cr#L30" target="_blank">
ameba/rule/performance/any_instead_of_empty.cr
</a>
@ -745,14 +743,14 @@ one value present.</p>
<ul class="list-summary">
<li class="entry-summary">
<a href="#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method" class="signature"><strong>.new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)</a>
<a href="#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method" class="signature"><strong>.new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)</a>
<div class="summary"><p>This rule is used to identify usage of arg-less <code>Enumerable#any?</code> calls.</p></div>
</li>
<li class="entry-summary">
<a href="#new(config=nil)-class-method" class="signature"><strong>.new</strong>(config = <span class="n">nil</span>)</a>
<a href="#new%28config%3Dnil%29-class-method" class="signature"><strong>.new</strong>(config = <span class="n">nil</span>)</a>
<div class="summary"><p>This rule is used to identify usage of arg-less <code>Enumerable#any?</code> calls.</p></div>
@ -775,47 +773,47 @@ one value present.</p>
<ul class="list-summary">
<li class="entry-summary">
<a href="#description:String-instance-method" class="signature"><strong>#description</strong> : String</a>
<a href="#description%3AString-instance-method" class="signature"><strong>#description</strong> : String</a>
</li>
<li class="entry-summary">
<a href="#description=(description:String)-instance-method" class="signature"><strong>#description=</strong>(description : String)</a>
<a href="#description%3D%28description%3AString%29-instance-method" class="signature"><strong>#description=</strong>(description : String)</a>
</li>
<li class="entry-summary">
<a href="#enabled:Bool-instance-method" class="signature"><strong>#enabled</strong> : Bool</a>
<a href="#enabled%3ABool-instance-method" class="signature"><strong>#enabled</strong> : Bool</a>
</li>
<li class="entry-summary">
<a href="#enabled=(enabled)-instance-method" class="signature"><strong>#enabled=</strong>(enabled)</a>
<a href="#enabled%3D%28enabled%29-instance-method" class="signature"><strong>#enabled=</strong>(enabled)</a>
</li>
<li class="entry-summary">
<a href="#excluded:Array(String)?-instance-method" class="signature"><strong>#excluded</strong> : Array(String)?</a>
<a href="#excluded%3AArray%28String%29%3F-instance-method" class="signature"><strong>#excluded</strong> : Array(String)?</a>
</li>
<li class="entry-summary">
<a href="#excluded=(excluded:Array(String)?)-instance-method" class="signature"><strong>#excluded=</strong>(excluded : Array(String)?)</a>
<a href="#excluded%3D%28excluded%3AArray%28String%29%3F%29-instance-method" class="signature"><strong>#excluded=</strong>(excluded : Array(String)?)</a>
</li>
<li class="entry-summary">
<a href="#severity:Ameba::Severity-instance-method" class="signature"><strong>#severity</strong> : Ameba::Severity</a>
<a href="#severity%3AAmeba%3A%3ASeverity-instance-method" class="signature"><strong>#severity</strong> : Ameba::Severity</a>
</li>
<li class="entry-summary">
<a href="#severity=(severity)-instance-method" class="signature"><strong>#severity=</strong>(severity)</a>
<a href="#severity%3D%28severity%29-instance-method" class="signature"><strong>#severity=</strong>(severity)</a>
</li>
<li class="entry-summary">
<a href="#test(source,node:Crystal::Call)-instance-method" class="signature"><strong>#test</strong>(source, node : Crystal::Call)</a>
<a href="#test%28source%2Cnode%3ACrystal%3A%3ACall%29-instance-method" class="signature"><strong>#test</strong>(source, node : Crystal::Call)</a>
</li>
@ -852,7 +850,7 @@ one value present.</p>
<h3>Instance methods inherited from class <code><a href="../../../Ameba/Rule/Performance/Base.html">Ameba::Rule::Performance::Base</a></code></h3>
<a href="../../../Ameba/Rule/Performance/Base.html#catch(source:Source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Performance/Base.html#catch%28source%3ASource%29-instance-method" class="tooltip">
<span>catch(source : Source)</span>
catch</a>
@ -864,7 +862,7 @@ one value present.</p>
<h3>Constructor methods inherited from class <code><a href="../../../Ameba/Rule/Performance/Base.html">Ameba::Rule::Performance::Base</a></code></h3>
<a href="../../../Ameba/Rule/Performance/Base.html#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method" class="tooltip">
<a href="../../../Ameba/Rule/Performance/Base.html#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method" class="tooltip">
<span>new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)<br/>new(config = <span class="n">nil</span>)</span>
new</a>
@ -900,17 +898,17 @@ one value present.</p>
<h3>Instance methods inherited from class <code><a href="../../../Ameba/Rule/Base.html">Ameba::Rule::Base</a></code></h3>
<a href="../../../Ameba/Rule/Base.html#==(other)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#%3D%3D%28other%29-instance-method" class="tooltip">
<span>==(other)</span>
==</a>,
<a href="../../../Ameba/Rule/Base.html#catch(source:Source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#catch%28source%3ASource%29-instance-method" class="tooltip">
<span>catch(source : Source)</span>
catch</a>,
<a href="../../../Ameba/Rule/Base.html#excluded?(source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#excluded%3F%28source%29-instance-method" class="tooltip">
<span>excluded?(source)</span>
excluded?</a>,
@ -930,12 +928,12 @@ one value present.</p>
name</a>,
<a href="../../../Ameba/Rule/Base.html#special?-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#special%3F-instance-method" class="tooltip">
<span>special?</span>
special?</a>,
<a href="../../../Ameba/Rule/Base.html#test(source:Source,node:Crystal::ASTNode,*opts)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#test%28source%3ASource%2Cnode%3ACrystal%3A%3AASTNode%2C%2Aopts%29-instance-method" class="tooltip">
<span>test(source : Source, node : Crystal::ASTNode, *opts)<br/>test(source : Source)</span>
test</a>
@ -1005,29 +1003,22 @@ one value present.</p>
def self.<strong>new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
<a class="method-permalink" href="#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method">#</a>
<a class="method-permalink" href="#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method">#</a>
</div>
<div class="doc">
<p>This rule is used to identify usage of arg-less <code>Enumerable#any?</code> calls.</p>
<p>Using <code>Enumerable#any?</code> instead of <code>Enumerable#empty?</code> might lead to an
unexpected results (like <code>[nil, false].any? # => false</code>). In some cases
it also might be less efficient, since it iterates until the block will
return a <em>truthy</em> value, instead of just checking if there's at least
one value present.</p>
<p>For example, this is considered invalid:</p>
<pre><code class="language-crystal">[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].any?</code></pre>
<p>And it should be written as this:</p>
<pre><code class="language-crystal"><span class="o">!</span>[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].empty?</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/AnyInsteadOfEmpty:
Enabled: true</code></pre>
</div>
@ -1043,29 +1034,22 @@ one value present.</p>
def self.<strong>new</strong>(config = <span class="n">nil</span>)
<a class="method-permalink" href="#new(config=nil)-class-method">#</a>
<a class="method-permalink" href="#new%28config%3Dnil%29-class-method">#</a>
</div>
<div class="doc">
<p>This rule is used to identify usage of arg-less <code>Enumerable#any?</code> calls.</p>
<p>Using <code>Enumerable#any?</code> instead of <code>Enumerable#empty?</code> might lead to an
unexpected results (like <code>[nil, false].any? # => false</code>). In some cases
it also might be less efficient, since it iterates until the block will
return a <em>truthy</em> value, instead of just checking if there's at least
one value present.</p>
<p>For example, this is considered invalid:</p>
<pre><code class="language-crystal">[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].any?</code></pre>
<p>And it should be written as this:</p>
<pre><code class="language-crystal"><span class="o">!</span>[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].empty?</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/AnyInsteadOfEmpty:
Enabled: true</code></pre>
</div>
@ -1073,7 +1057,7 @@ one value present.</p>
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/any_instead_of_empty.cr#L30" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/any_instead_of_empty.cr#L30" target="_blank">View source</a>]
</div>
</div>
@ -1097,7 +1081,7 @@ one value present.</p>
def <strong>description</strong> : String
<a class="method-permalink" href="#description:String-instance-method">#</a>
<a class="method-permalink" href="#description%3AString-instance-method">#</a>
</div>
<br/>
@ -1111,7 +1095,7 @@ one value present.</p>
def <strong>description=</strong>(description : String)
<a class="method-permalink" href="#description=(description:String)-instance-method">#</a>
<a class="method-permalink" href="#description%3D%28description%3AString%29-instance-method">#</a>
</div>
<br/>
@ -1125,7 +1109,7 @@ one value present.</p>
def <strong>enabled</strong> : Bool
<a class="method-permalink" href="#enabled:Bool-instance-method">#</a>
<a class="method-permalink" href="#enabled%3ABool-instance-method">#</a>
</div>
<br/>
@ -1139,7 +1123,7 @@ one value present.</p>
def <strong>enabled=</strong>(enabled)
<a class="method-permalink" href="#enabled=(enabled)-instance-method">#</a>
<a class="method-permalink" href="#enabled%3D%28enabled%29-instance-method">#</a>
</div>
<br/>
@ -1153,7 +1137,7 @@ one value present.</p>
def <strong>excluded</strong> : Array(String)?
<a class="method-permalink" href="#excluded:Array(String)?-instance-method">#</a>
<a class="method-permalink" href="#excluded%3AArray%28String%29%3F-instance-method">#</a>
</div>
<br/>
@ -1167,7 +1151,7 @@ one value present.</p>
def <strong>excluded=</strong>(excluded : Array(String)?)
<a class="method-permalink" href="#excluded=(excluded:Array(String)?)-instance-method">#</a>
<a class="method-permalink" href="#excluded%3D%28excluded%3AArray%28String%29%3F%29-instance-method">#</a>
</div>
<br/>
@ -1181,7 +1165,7 @@ one value present.</p>
def <strong>severity</strong> : <a href="../../../Ameba/Severity.html">Ameba::Severity</a>
<a class="method-permalink" href="#severity:Ameba::Severity-instance-method">#</a>
<a class="method-permalink" href="#severity%3AAmeba%3A%3ASeverity-instance-method">#</a>
</div>
<br/>
@ -1195,7 +1179,7 @@ one value present.</p>
def <strong>severity=</strong>(severity)
<a class="method-permalink" href="#severity=(severity)-instance-method">#</a>
<a class="method-permalink" href="#severity%3D%28severity%29-instance-method">#</a>
</div>
<br/>
@ -1209,13 +1193,13 @@ one value present.</p>
def <strong>test</strong>(source, node : Crystal::Call)
<a class="method-permalink" href="#test(source,node:Crystal::Call)-instance-method">#</a>
<a class="method-permalink" href="#test%28source%2Cnode%3ACrystal%3A%3ACall%29-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/any_instead_of_empty.cr#L38" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/any_instead_of_empty.cr#L38" target="_blank">View source</a>]
</div>
</div>

View file

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Crystal Docs 0.36.1">
<meta name="generator" content="Crystal Docs 1.1.1">
<meta name="crystal_docs.project_version" content="master">
<meta name="crystal_docs.project_name" content="ameba">
@ -286,6 +286,11 @@
<ul>
<li class=" " data-id="ameba/Ameba/Rule/Lint/AmbiguousAssignment" data-name="ameba::rule::lint::ambiguousassignment">
<a href="../../../Ameba/Rule/Lint/AmbiguousAssignment.html">AmbiguousAssignment</a>
</li>
<li class=" " data-id="ameba/Ameba/Rule/Lint/BadDirective" data-name="ameba::rule::lint::baddirective">
<a href="../../../Ameba/Rule/Lint/BadDirective.html">BadDirective</a>
@ -708,7 +713,7 @@
</h2>
<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/base.cr#L5" target="_blank">
<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/base.cr#L5" target="_blank">
ameba/rule/performance/base.cr
</a>
@ -730,12 +735,12 @@
<ul class="list-summary">
<li class="entry-summary">
<a href="#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method" class="signature"><strong>.new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)</a>
<a href="#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method" class="signature"><strong>.new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)</a>
</li>
<li class="entry-summary">
<a href="#new(config=nil)-class-method" class="signature"><strong>.new</strong>(config = <span class="n">nil</span>)</a>
<a href="#new%28config%3Dnil%29-class-method" class="signature"><strong>.new</strong>(config = <span class="n">nil</span>)</a>
<div class="summary"><p>A general base class for performance rules.</p></div>
@ -758,7 +763,7 @@
<ul class="list-summary">
<li class="entry-summary">
<a href="#catch(source:Source)-instance-method" class="signature"><strong>#catch</strong>(source : Source)</a>
<a href="#catch%28source%3ASource%29-instance-method" class="signature"><strong>#catch</strong>(source : Source)</a>
<div class="summary"><p>A convenient addition to <code>#test</code> method that does the same but returns a passed in <code>source</code> as an addition.</p></div>
@ -797,17 +802,17 @@
<h3>Instance methods inherited from class <code><a href="../../../Ameba/Rule/Base.html">Ameba::Rule::Base</a></code></h3>
<a href="../../../Ameba/Rule/Base.html#==(other)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#%3D%3D%28other%29-instance-method" class="tooltip">
<span>==(other)</span>
==</a>,
<a href="../../../Ameba/Rule/Base.html#catch(source:Source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#catch%28source%3ASource%29-instance-method" class="tooltip">
<span>catch(source : Source)</span>
catch</a>,
<a href="../../../Ameba/Rule/Base.html#excluded?(source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#excluded%3F%28source%29-instance-method" class="tooltip">
<span>excluded?(source)</span>
excluded?</a>,
@ -827,12 +832,12 @@
name</a>,
<a href="../../../Ameba/Rule/Base.html#special?-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#special%3F-instance-method" class="tooltip">
<span>special?</span>
special?</a>,
<a href="../../../Ameba/Rule/Base.html#test(source:Source,node:Crystal::ASTNode,*opts)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#test%28source%3ASource%2Cnode%3ACrystal%3A%3AASTNode%2C%2Aopts%29-instance-method" class="tooltip">
<span>test(source : Source, node : Crystal::ASTNode, *opts)<br/>test(source : Source)</span>
test</a>
@ -902,7 +907,7 @@
def self.<strong>new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
<a class="method-permalink" href="#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method">#</a>
<a class="method-permalink" href="#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method">#</a>
</div>
<br/>
@ -916,7 +921,7 @@
def self.<strong>new</strong>(config = <span class="n">nil</span>)
<a class="method-permalink" href="#new(config=nil)-class-method">#</a>
<a class="method-permalink" href="#new%28config%3Dnil%29-class-method">#</a>
</div>
<div class="doc">
@ -927,7 +932,7 @@
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/base.cr#L5" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/base.cr#L5" target="_blank">View source</a>]
</div>
</div>
@ -951,7 +956,7 @@
def <strong>catch</strong>(source : <a href="../../../Ameba/Source.html">Source</a>)
<a class="method-permalink" href="#catch(source:Source)-instance-method">#</a>
<a class="method-permalink" href="#catch%28source%3ASource%29-instance-method">#</a>
</div>
<div class="doc">
@ -962,7 +967,6 @@
<p>A convenient addition to <code>#test</code> method that does the same
but returns a passed in <code>source</code> as an addition.</p>
<pre><code class="language-crystal">source <span class="o">=</span> <span class="t">MyRule</span>.<span class="k">new</span>.catch(source)
source.valid?</code></pre>
</div>
@ -970,7 +974,7 @@ source.valid?</code></pre>
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/base.cr#L6" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/base.cr#L6" target="_blank">View source</a>]
</div>
</div>

View file

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Crystal Docs 0.36.1">
<meta name="generator" content="Crystal Docs 1.1.1">
<meta name="crystal_docs.project_version" content="master">
<meta name="crystal_docs.project_name" content="ameba">
@ -286,6 +286,11 @@
<ul>
<li class=" " data-id="ameba/Ameba/Rule/Lint/AmbiguousAssignment" data-name="ameba::rule::lint::ambiguousassignment">
<a href="../../../Ameba/Rule/Lint/AmbiguousAssignment.html">AmbiguousAssignment</a>
</li>
<li class=" " data-id="ameba/Ameba/Rule/Lint/BadDirective" data-name="ameba::rule::lint::baddirective">
<a href="../../../Ameba/Rule/Lint/BadDirective.html">BadDirective</a>
@ -641,25 +646,19 @@
<p>This rule is used to identify usage of chained calls not utilizing
the bang method variants.</p>
<p>For example, this is considered inefficient:</p>
<pre><code class="language-crystal">names <span class="o">=</span> <span class="s">%w[Alice Bob]</span>
chars <span class="o">=</span> names
.flat_map(<span class="o">&amp;</span>.chars)
.uniq
.sort</code></pre>
<p>And can be written as this:</p>
<pre><code class="language-crystal">names <span class="o">=</span> <span class="s">%w[Alice Bob]</span>
chars <span class="o">=</span> names
.flat_map(<span class="o">&amp;</span>.chars)
.uniq!
.sort!</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/ChainedCallWithNoBang:
Enabled: true
CallNames:
@ -708,7 +707,7 @@ chars <span class="o">=</span> names
</h2>
<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/chained_call_with_no_bang.cr#L39" target="_blank">
<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/chained_call_with_no_bang.cr#L39" target="_blank">
ameba/rule/performance/chained_call_with_no_bang.cr
</a>
@ -758,14 +757,14 @@ chars <span class="o">=</span> names
<ul class="list-summary">
<li class="entry-summary">
<a href="#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method" class="signature"><strong>.new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)</a>
<a href="#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method" class="signature"><strong>.new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)</a>
<div class="summary"><p>This rule is used to identify usage of chained calls not utilizing the bang method variants.</p></div>
</li>
<li class="entry-summary">
<a href="#new(config=nil)-class-method" class="signature"><strong>.new</strong>(config = <span class="n">nil</span>)</a>
<a href="#new%28config%3Dnil%29-class-method" class="signature"><strong>.new</strong>(config = <span class="n">nil</span>)</a>
<div class="summary"><p>This rule is used to identify usage of chained calls not utilizing the bang method variants.</p></div>
@ -788,62 +787,62 @@ chars <span class="o">=</span> names
<ul class="list-summary">
<li class="entry-summary">
<a href="#call_names:Array(String)-instance-method" class="signature"><strong>#call_names</strong> : Array(String)</a>
<a href="#call_names%3AArray%28String%29-instance-method" class="signature"><strong>#call_names</strong> : Array(String)</a>
</li>
<li class="entry-summary">
<a href="#call_names=(call_names:Array(String))-instance-method" class="signature"><strong>#call_names=</strong>(call_names : Array(String))</a>
<a href="#call_names%3D%28call_names%3AArray%28String%29%29-instance-method" class="signature"><strong>#call_names=</strong>(call_names : Array(String))</a>
</li>
<li class="entry-summary">
<a href="#description:String-instance-method" class="signature"><strong>#description</strong> : String</a>
<a href="#description%3AString-instance-method" class="signature"><strong>#description</strong> : String</a>
</li>
<li class="entry-summary">
<a href="#description=(description:String)-instance-method" class="signature"><strong>#description=</strong>(description : String)</a>
<a href="#description%3D%28description%3AString%29-instance-method" class="signature"><strong>#description=</strong>(description : String)</a>
</li>
<li class="entry-summary">
<a href="#enabled:Bool-instance-method" class="signature"><strong>#enabled</strong> : Bool</a>
<a href="#enabled%3ABool-instance-method" class="signature"><strong>#enabled</strong> : Bool</a>
</li>
<li class="entry-summary">
<a href="#enabled=(enabled)-instance-method" class="signature"><strong>#enabled=</strong>(enabled)</a>
<a href="#enabled%3D%28enabled%29-instance-method" class="signature"><strong>#enabled=</strong>(enabled)</a>
</li>
<li class="entry-summary">
<a href="#excluded:Array(String)?-instance-method" class="signature"><strong>#excluded</strong> : Array(String)?</a>
<a href="#excluded%3AArray%28String%29%3F-instance-method" class="signature"><strong>#excluded</strong> : Array(String)?</a>
</li>
<li class="entry-summary">
<a href="#excluded=(excluded:Array(String)?)-instance-method" class="signature"><strong>#excluded=</strong>(excluded : Array(String)?)</a>
<a href="#excluded%3D%28excluded%3AArray%28String%29%3F%29-instance-method" class="signature"><strong>#excluded=</strong>(excluded : Array(String)?)</a>
</li>
<li class="entry-summary">
<a href="#severity:Ameba::Severity-instance-method" class="signature"><strong>#severity</strong> : Ameba::Severity</a>
<a href="#severity%3AAmeba%3A%3ASeverity-instance-method" class="signature"><strong>#severity</strong> : Ameba::Severity</a>
</li>
<li class="entry-summary">
<a href="#severity=(severity)-instance-method" class="signature"><strong>#severity=</strong>(severity)</a>
<a href="#severity%3D%28severity%29-instance-method" class="signature"><strong>#severity=</strong>(severity)</a>
</li>
<li class="entry-summary">
<a href="#test(source,node:Crystal::Call)-instance-method" class="signature"><strong>#test</strong>(source, node : Crystal::Call)</a>
<a href="#test%28source%2Cnode%3ACrystal%3A%3ACall%29-instance-method" class="signature"><strong>#test</strong>(source, node : Crystal::Call)</a>
</li>
<li class="entry-summary">
<a href="#test(source)-instance-method" class="signature"><strong>#test</strong>(source)</a>
<a href="#test%28source%29-instance-method" class="signature"><strong>#test</strong>(source)</a>
</li>
@ -880,7 +879,7 @@ chars <span class="o">=</span> names
<h3>Instance methods inherited from class <code><a href="../../../Ameba/Rule/Performance/Base.html">Ameba::Rule::Performance::Base</a></code></h3>
<a href="../../../Ameba/Rule/Performance/Base.html#catch(source:Source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Performance/Base.html#catch%28source%3ASource%29-instance-method" class="tooltip">
<span>catch(source : Source)</span>
catch</a>
@ -892,7 +891,7 @@ chars <span class="o">=</span> names
<h3>Constructor methods inherited from class <code><a href="../../../Ameba/Rule/Performance/Base.html">Ameba::Rule::Performance::Base</a></code></h3>
<a href="../../../Ameba/Rule/Performance/Base.html#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method" class="tooltip">
<a href="../../../Ameba/Rule/Performance/Base.html#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method" class="tooltip">
<span>new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)<br/>new(config = <span class="n">nil</span>)</span>
new</a>
@ -928,17 +927,17 @@ chars <span class="o">=</span> names
<h3>Instance methods inherited from class <code><a href="../../../Ameba/Rule/Base.html">Ameba::Rule::Base</a></code></h3>
<a href="../../../Ameba/Rule/Base.html#==(other)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#%3D%3D%28other%29-instance-method" class="tooltip">
<span>==(other)</span>
==</a>,
<a href="../../../Ameba/Rule/Base.html#catch(source:Source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#catch%28source%3ASource%29-instance-method" class="tooltip">
<span>catch(source : Source)</span>
catch</a>,
<a href="../../../Ameba/Rule/Base.html#excluded?(source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#excluded%3F%28source%29-instance-method" class="tooltip">
<span>excluded?(source)</span>
excluded?</a>,
@ -958,12 +957,12 @@ chars <span class="o">=</span> names
name</a>,
<a href="../../../Ameba/Rule/Base.html#special?-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#special%3F-instance-method" class="tooltip">
<span>special?</span>
special?</a>,
<a href="../../../Ameba/Rule/Base.html#test(source:Source,node:Crystal::ASTNode,*opts)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#test%28source%3ASource%2Cnode%3ACrystal%3A%3AASTNode%2C%2Aopts%29-instance-method" class="tooltip">
<span>test(source : Source, node : Crystal::ASTNode, *opts)<br/>test(source : Source)</span>
test</a>
@ -1033,32 +1032,26 @@ chars <span class="o">=</span> names
def self.<strong>new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
<a class="method-permalink" href="#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method">#</a>
<a class="method-permalink" href="#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method">#</a>
</div>
<div class="doc">
<p>This rule is used to identify usage of chained calls not utilizing
the bang method variants.</p>
<p>For example, this is considered inefficient:</p>
<pre><code class="language-crystal">names <span class="o">=</span> <span class="s">%w[Alice Bob]</span>
chars <span class="o">=</span> names
.flat_map(<span class="o">&amp;</span>.chars)
.uniq
.sort</code></pre>
<p>And can be written as this:</p>
<pre><code class="language-crystal">names <span class="o">=</span> <span class="s">%w[Alice Bob]</span>
chars <span class="o">=</span> names
.flat_map(<span class="o">&amp;</span>.chars)
.uniq!
.sort!</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/ChainedCallWithNoBang:
Enabled: true
CallNames:
@ -1080,32 +1073,26 @@ chars <span class="o">=</span> names
def self.<strong>new</strong>(config = <span class="n">nil</span>)
<a class="method-permalink" href="#new(config=nil)-class-method">#</a>
<a class="method-permalink" href="#new%28config%3Dnil%29-class-method">#</a>
</div>
<div class="doc">
<p>This rule is used to identify usage of chained calls not utilizing
the bang method variants.</p>
<p>For example, this is considered inefficient:</p>
<pre><code class="language-crystal">names <span class="o">=</span> <span class="s">%w[Alice Bob]</span>
chars <span class="o">=</span> names
.flat_map(<span class="o">&amp;</span>.chars)
.uniq
.sort</code></pre>
<p>And can be written as this:</p>
<pre><code class="language-crystal">names <span class="o">=</span> <span class="s">%w[Alice Bob]</span>
chars <span class="o">=</span> names
.flat_map(<span class="o">&amp;</span>.chars)
.uniq!
.sort!</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/ChainedCallWithNoBang:
Enabled: true
CallNames:
@ -1119,7 +1106,7 @@ chars <span class="o">=</span> names
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/chained_call_with_no_bang.cr#L39" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/chained_call_with_no_bang.cr#L39" target="_blank">View source</a>]
</div>
</div>
@ -1143,7 +1130,7 @@ chars <span class="o">=</span> names
def <strong>call_names</strong> : Array(String)
<a class="method-permalink" href="#call_names:Array(String)-instance-method">#</a>
<a class="method-permalink" href="#call_names%3AArray%28String%29-instance-method">#</a>
</div>
<br/>
@ -1157,7 +1144,7 @@ chars <span class="o">=</span> names
def <strong>call_names=</strong>(call_names : Array(String))
<a class="method-permalink" href="#call_names=(call_names:Array(String))-instance-method">#</a>
<a class="method-permalink" href="#call_names%3D%28call_names%3AArray%28String%29%29-instance-method">#</a>
</div>
<br/>
@ -1171,7 +1158,7 @@ chars <span class="o">=</span> names
def <strong>description</strong> : String
<a class="method-permalink" href="#description:String-instance-method">#</a>
<a class="method-permalink" href="#description%3AString-instance-method">#</a>
</div>
<br/>
@ -1185,7 +1172,7 @@ chars <span class="o">=</span> names
def <strong>description=</strong>(description : String)
<a class="method-permalink" href="#description=(description:String)-instance-method">#</a>
<a class="method-permalink" href="#description%3D%28description%3AString%29-instance-method">#</a>
</div>
<br/>
@ -1199,7 +1186,7 @@ chars <span class="o">=</span> names
def <strong>enabled</strong> : Bool
<a class="method-permalink" href="#enabled:Bool-instance-method">#</a>
<a class="method-permalink" href="#enabled%3ABool-instance-method">#</a>
</div>
<br/>
@ -1213,7 +1200,7 @@ chars <span class="o">=</span> names
def <strong>enabled=</strong>(enabled)
<a class="method-permalink" href="#enabled=(enabled)-instance-method">#</a>
<a class="method-permalink" href="#enabled%3D%28enabled%29-instance-method">#</a>
</div>
<br/>
@ -1227,7 +1214,7 @@ chars <span class="o">=</span> names
def <strong>excluded</strong> : Array(String)?
<a class="method-permalink" href="#excluded:Array(String)?-instance-method">#</a>
<a class="method-permalink" href="#excluded%3AArray%28String%29%3F-instance-method">#</a>
</div>
<br/>
@ -1241,7 +1228,7 @@ chars <span class="o">=</span> names
def <strong>excluded=</strong>(excluded : Array(String)?)
<a class="method-permalink" href="#excluded=(excluded:Array(String)?)-instance-method">#</a>
<a class="method-permalink" href="#excluded%3D%28excluded%3AArray%28String%29%3F%29-instance-method">#</a>
</div>
<br/>
@ -1255,7 +1242,7 @@ chars <span class="o">=</span> names
def <strong>severity</strong> : <a href="../../../Ameba/Severity.html">Ameba::Severity</a>
<a class="method-permalink" href="#severity:Ameba::Severity-instance-method">#</a>
<a class="method-permalink" href="#severity%3AAmeba%3A%3ASeverity-instance-method">#</a>
</div>
<br/>
@ -1269,7 +1256,7 @@ chars <span class="o">=</span> names
def <strong>severity=</strong>(severity)
<a class="method-permalink" href="#severity=(severity)-instance-method">#</a>
<a class="method-permalink" href="#severity%3D%28severity%29-instance-method">#</a>
</div>
<br/>
@ -1283,13 +1270,13 @@ chars <span class="o">=</span> names
def <strong>test</strong>(source, node : Crystal::Call)
<a class="method-permalink" href="#test(source,node:Crystal::Call)-instance-method">#</a>
<a class="method-permalink" href="#test%28source%2Cnode%3ACrystal%3A%3ACall%29-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/chained_call_with_no_bang.cr#L68" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/chained_call_with_no_bang.cr#L68" target="_blank">View source</a>]
</div>
</div>
@ -1299,13 +1286,13 @@ chars <span class="o">=</span> names
def <strong>test</strong>(source)
<a class="method-permalink" href="#test(source)-instance-method">#</a>
<a class="method-permalink" href="#test%28source%29-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/chained_call_with_no_bang.cr#L59" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/chained_call_with_no_bang.cr#L59" target="_blank">View source</a>]
</div>
</div>

View file

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Crystal Docs 0.36.1">
<meta name="generator" content="Crystal Docs 1.1.1">
<meta name="crystal_docs.project_version" content="master">
<meta name="crystal_docs.project_name" content="ameba">
@ -286,6 +286,11 @@
<ul>
<li class=" " data-id="ameba/Ameba/Rule/Lint/AmbiguousAssignment" data-name="ameba::rule::lint::ambiguousassignment">
<a href="../../../Ameba/Rule/Lint/AmbiguousAssignment.html">AmbiguousAssignment</a>
</li>
<li class=" " data-id="ameba/Ameba/Rule/Lint/BadDirective" data-name="ameba::rule::lint::baddirective">
<a href="../../../Ameba/Rule/Lint/BadDirective.html">BadDirective</a>
@ -640,17 +645,11 @@
</h2>
<p>This rule is used to identify usage of <code>compact</code> calls that follow <code>map</code>.</p>
<p>For example, this is considered inefficient:</p>
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.map(<span class="o">&amp;</span>.match(<span class="s">/^A./</span>)).compact</code></pre>
<p>And can be written as this:</p>
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.compact_map(<span class="o">&amp;</span>.match(<span class="s">/^A./</span>))</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/CompactAfterMap:
Enabled: true</code></pre>
@ -693,7 +692,7 @@
</h2>
<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/compact_after_map.cr#L24" target="_blank">
<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/compact_after_map.cr#L24" target="_blank">
ameba/rule/performance/compact_after_map.cr
</a>
@ -744,14 +743,14 @@
<ul class="list-summary">
<li class="entry-summary">
<a href="#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method" class="signature"><strong>.new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)</a>
<a href="#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method" class="signature"><strong>.new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)</a>
<div class="summary"><p>This rule is used to identify usage of <code>compact</code> calls that follow <code>map</code>.</p></div>
</li>
<li class="entry-summary">
<a href="#new(config=nil)-class-method" class="signature"><strong>.new</strong>(config = <span class="n">nil</span>)</a>
<a href="#new%28config%3Dnil%29-class-method" class="signature"><strong>.new</strong>(config = <span class="n">nil</span>)</a>
<div class="summary"><p>This rule is used to identify usage of <code>compact</code> calls that follow <code>map</code>.</p></div>
@ -774,52 +773,52 @@
<ul class="list-summary">
<li class="entry-summary">
<a href="#description:String-instance-method" class="signature"><strong>#description</strong> : String</a>
<a href="#description%3AString-instance-method" class="signature"><strong>#description</strong> : String</a>
</li>
<li class="entry-summary">
<a href="#description=(description:String)-instance-method" class="signature"><strong>#description=</strong>(description : String)</a>
<a href="#description%3D%28description%3AString%29-instance-method" class="signature"><strong>#description=</strong>(description : String)</a>
</li>
<li class="entry-summary">
<a href="#enabled:Bool-instance-method" class="signature"><strong>#enabled</strong> : Bool</a>
<a href="#enabled%3ABool-instance-method" class="signature"><strong>#enabled</strong> : Bool</a>
</li>
<li class="entry-summary">
<a href="#enabled=(enabled)-instance-method" class="signature"><strong>#enabled=</strong>(enabled)</a>
<a href="#enabled%3D%28enabled%29-instance-method" class="signature"><strong>#enabled=</strong>(enabled)</a>
</li>
<li class="entry-summary">
<a href="#excluded:Array(String)?-instance-method" class="signature"><strong>#excluded</strong> : Array(String)?</a>
<a href="#excluded%3AArray%28String%29%3F-instance-method" class="signature"><strong>#excluded</strong> : Array(String)?</a>
</li>
<li class="entry-summary">
<a href="#excluded=(excluded:Array(String)?)-instance-method" class="signature"><strong>#excluded=</strong>(excluded : Array(String)?)</a>
<a href="#excluded%3D%28excluded%3AArray%28String%29%3F%29-instance-method" class="signature"><strong>#excluded=</strong>(excluded : Array(String)?)</a>
</li>
<li class="entry-summary">
<a href="#severity:Ameba::Severity-instance-method" class="signature"><strong>#severity</strong> : Ameba::Severity</a>
<a href="#severity%3AAmeba%3A%3ASeverity-instance-method" class="signature"><strong>#severity</strong> : Ameba::Severity</a>
</li>
<li class="entry-summary">
<a href="#severity=(severity)-instance-method" class="signature"><strong>#severity=</strong>(severity)</a>
<a href="#severity%3D%28severity%29-instance-method" class="signature"><strong>#severity=</strong>(severity)</a>
</li>
<li class="entry-summary">
<a href="#test(source,node:Crystal::Call)-instance-method" class="signature"><strong>#test</strong>(source, node : Crystal::Call)</a>
<a href="#test%28source%2Cnode%3ACrystal%3A%3ACall%29-instance-method" class="signature"><strong>#test</strong>(source, node : Crystal::Call)</a>
</li>
<li class="entry-summary">
<a href="#test(source)-instance-method" class="signature"><strong>#test</strong>(source)</a>
<a href="#test%28source%29-instance-method" class="signature"><strong>#test</strong>(source)</a>
</li>
@ -856,7 +855,7 @@
<h3>Instance methods inherited from class <code><a href="../../../Ameba/Rule/Performance/Base.html">Ameba::Rule::Performance::Base</a></code></h3>
<a href="../../../Ameba/Rule/Performance/Base.html#catch(source:Source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Performance/Base.html#catch%28source%3ASource%29-instance-method" class="tooltip">
<span>catch(source : Source)</span>
catch</a>
@ -868,7 +867,7 @@
<h3>Constructor methods inherited from class <code><a href="../../../Ameba/Rule/Performance/Base.html">Ameba::Rule::Performance::Base</a></code></h3>
<a href="../../../Ameba/Rule/Performance/Base.html#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method" class="tooltip">
<a href="../../../Ameba/Rule/Performance/Base.html#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method" class="tooltip">
<span>new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)<br/>new(config = <span class="n">nil</span>)</span>
new</a>
@ -904,17 +903,17 @@
<h3>Instance methods inherited from class <code><a href="../../../Ameba/Rule/Base.html">Ameba::Rule::Base</a></code></h3>
<a href="../../../Ameba/Rule/Base.html#==(other)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#%3D%3D%28other%29-instance-method" class="tooltip">
<span>==(other)</span>
==</a>,
<a href="../../../Ameba/Rule/Base.html#catch(source:Source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#catch%28source%3ASource%29-instance-method" class="tooltip">
<span>catch(source : Source)</span>
catch</a>,
<a href="../../../Ameba/Rule/Base.html#excluded?(source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#excluded%3F%28source%29-instance-method" class="tooltip">
<span>excluded?(source)</span>
excluded?</a>,
@ -934,12 +933,12 @@
name</a>,
<a href="../../../Ameba/Rule/Base.html#special?-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#special%3F-instance-method" class="tooltip">
<span>special?</span>
special?</a>,
<a href="../../../Ameba/Rule/Base.html#test(source:Source,node:Crystal::ASTNode,*opts)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#test%28source%3ASource%2Cnode%3ACrystal%3A%3AASTNode%2C%2Aopts%29-instance-method" class="tooltip">
<span>test(source : Source, node : Crystal::ASTNode, *opts)<br/>test(source : Source)</span>
test</a>
@ -1009,23 +1008,17 @@
def self.<strong>new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
<a class="method-permalink" href="#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method">#</a>
<a class="method-permalink" href="#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method">#</a>
</div>
<div class="doc">
<p>This rule is used to identify usage of <code>compact</code> calls that follow <code>map</code>.</p>
<p>For example, this is considered inefficient:</p>
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.map(<span class="o">&amp;</span>.match(<span class="s">/^A./</span>)).compact</code></pre>
<p>And can be written as this:</p>
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.compact_map(<span class="o">&amp;</span>.match(<span class="s">/^A./</span>))</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/CompactAfterMap:
Enabled: true</code></pre>
</div>
@ -1041,23 +1034,17 @@
def self.<strong>new</strong>(config = <span class="n">nil</span>)
<a class="method-permalink" href="#new(config=nil)-class-method">#</a>
<a class="method-permalink" href="#new%28config%3Dnil%29-class-method">#</a>
</div>
<div class="doc">
<p>This rule is used to identify usage of <code>compact</code> calls that follow <code>map</code>.</p>
<p>For example, this is considered inefficient:</p>
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.map(<span class="o">&amp;</span>.match(<span class="s">/^A./</span>)).compact</code></pre>
<p>And can be written as this:</p>
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.compact_map(<span class="o">&amp;</span>.match(<span class="s">/^A./</span>))</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/CompactAfterMap:
Enabled: true</code></pre>
</div>
@ -1065,7 +1052,7 @@
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/compact_after_map.cr#L24" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/compact_after_map.cr#L24" target="_blank">View source</a>]
</div>
</div>
@ -1089,7 +1076,7 @@
def <strong>description</strong> : String
<a class="method-permalink" href="#description:String-instance-method">#</a>
<a class="method-permalink" href="#description%3AString-instance-method">#</a>
</div>
<br/>
@ -1103,7 +1090,7 @@
def <strong>description=</strong>(description : String)
<a class="method-permalink" href="#description=(description:String)-instance-method">#</a>
<a class="method-permalink" href="#description%3D%28description%3AString%29-instance-method">#</a>
</div>
<br/>
@ -1117,7 +1104,7 @@
def <strong>enabled</strong> : Bool
<a class="method-permalink" href="#enabled:Bool-instance-method">#</a>
<a class="method-permalink" href="#enabled%3ABool-instance-method">#</a>
</div>
<br/>
@ -1131,7 +1118,7 @@
def <strong>enabled=</strong>(enabled)
<a class="method-permalink" href="#enabled=(enabled)-instance-method">#</a>
<a class="method-permalink" href="#enabled%3D%28enabled%29-instance-method">#</a>
</div>
<br/>
@ -1145,7 +1132,7 @@
def <strong>excluded</strong> : Array(String)?
<a class="method-permalink" href="#excluded:Array(String)?-instance-method">#</a>
<a class="method-permalink" href="#excluded%3AArray%28String%29%3F-instance-method">#</a>
</div>
<br/>
@ -1159,7 +1146,7 @@
def <strong>excluded=</strong>(excluded : Array(String)?)
<a class="method-permalink" href="#excluded=(excluded:Array(String)?)-instance-method">#</a>
<a class="method-permalink" href="#excluded%3D%28excluded%3AArray%28String%29%3F%29-instance-method">#</a>
</div>
<br/>
@ -1173,7 +1160,7 @@
def <strong>severity</strong> : <a href="../../../Ameba/Severity.html">Ameba::Severity</a>
<a class="method-permalink" href="#severity:Ameba::Severity-instance-method">#</a>
<a class="method-permalink" href="#severity%3AAmeba%3A%3ASeverity-instance-method">#</a>
</div>
<br/>
@ -1187,7 +1174,7 @@
def <strong>severity=</strong>(severity)
<a class="method-permalink" href="#severity=(severity)-instance-method">#</a>
<a class="method-permalink" href="#severity%3D%28severity%29-instance-method">#</a>
</div>
<br/>
@ -1201,13 +1188,13 @@
def <strong>test</strong>(source, node : Crystal::Call)
<a class="method-permalink" href="#test(source,node:Crystal::Call)-instance-method">#</a>
<a class="method-permalink" href="#test%28source%2Cnode%3ACrystal%3A%3ACall%29-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/compact_after_map.cr#L42" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/compact_after_map.cr#L42" target="_blank">View source</a>]
</div>
</div>
@ -1217,13 +1204,13 @@
def <strong>test</strong>(source)
<a class="method-permalink" href="#test(source)-instance-method">#</a>
<a class="method-permalink" href="#test%28source%29-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/compact_after_map.cr#L33" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/compact_after_map.cr#L33" target="_blank">View source</a>]
</div>
</div>

View file

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Crystal Docs 0.36.1">
<meta name="generator" content="Crystal Docs 1.1.1">
<meta name="crystal_docs.project_version" content="master">
<meta name="crystal_docs.project_name" content="ameba">
@ -286,6 +286,11 @@
<ul>
<li class=" " data-id="ameba/Ameba/Rule/Lint/AmbiguousAssignment" data-name="ameba::rule::lint::ambiguousassignment">
<a href="../../../Ameba/Rule/Lint/AmbiguousAssignment.html">AmbiguousAssignment</a>
</li>
<li class=" " data-id="ameba/Ameba/Rule/Lint/BadDirective" data-name="ameba::rule::lint::baddirective">
<a href="../../../Ameba/Rule/Lint/BadDirective.html">BadDirective</a>
@ -640,19 +645,13 @@
</h2>
<p>This rule is used to identify usage of <code>first/last/first?/last?</code> calls that follow filters.</p>
<p>For example, this is considered inefficient:</p>
<pre><code class="language-crystal">[<span class="n">-1</span>, <span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].<span class="k">select</span> { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">0</span> }.first?
[<span class="n">-1</span>, <span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].<span class="k">select</span> { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">0</span> }.last?</code></pre>
<p>And can be written as this:</p>
<pre><code class="language-crystal">[<span class="n">-1</span>, <span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].find { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">0</span> }
[<span class="n">-1</span>, <span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].reverse_each.find { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">0</span> }</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/FirstLastAfterFilter
Enabled: true
FilterNames:
@ -697,7 +696,7 @@
</h2>
<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/first_last_after_filter.cr#L28" target="_blank">
<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/first_last_after_filter.cr#L28" target="_blank">
ameba/rule/performance/first_last_after_filter.cr
</a>
@ -748,14 +747,14 @@
<ul class="list-summary">
<li class="entry-summary">
<a href="#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method" class="signature"><strong>.new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)</a>
<a href="#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method" class="signature"><strong>.new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)</a>
<div class="summary"><p>This rule is used to identify usage of <code>first/last/first?/last?</code> calls that follow filters.</p></div>
</li>
<li class="entry-summary">
<a href="#new(config=nil)-class-method" class="signature"><strong>.new</strong>(config = <span class="n">nil</span>)</a>
<a href="#new%28config%3Dnil%29-class-method" class="signature"><strong>.new</strong>(config = <span class="n">nil</span>)</a>
<div class="summary"><p>This rule is used to identify usage of <code>first/last/first?/last?</code> calls that follow filters.</p></div>
@ -778,62 +777,62 @@
<ul class="list-summary">
<li class="entry-summary">
<a href="#description:String-instance-method" class="signature"><strong>#description</strong> : String</a>
<a href="#description%3AString-instance-method" class="signature"><strong>#description</strong> : String</a>
</li>
<li class="entry-summary">
<a href="#description=(description:String)-instance-method" class="signature"><strong>#description=</strong>(description : String)</a>
<a href="#description%3D%28description%3AString%29-instance-method" class="signature"><strong>#description=</strong>(description : String)</a>
</li>
<li class="entry-summary">
<a href="#enabled:Bool-instance-method" class="signature"><strong>#enabled</strong> : Bool</a>
<a href="#enabled%3ABool-instance-method" class="signature"><strong>#enabled</strong> : Bool</a>
</li>
<li class="entry-summary">
<a href="#enabled=(enabled)-instance-method" class="signature"><strong>#enabled=</strong>(enabled)</a>
<a href="#enabled%3D%28enabled%29-instance-method" class="signature"><strong>#enabled=</strong>(enabled)</a>
</li>
<li class="entry-summary">
<a href="#excluded:Array(String)?-instance-method" class="signature"><strong>#excluded</strong> : Array(String)?</a>
<a href="#excluded%3AArray%28String%29%3F-instance-method" class="signature"><strong>#excluded</strong> : Array(String)?</a>
</li>
<li class="entry-summary">
<a href="#excluded=(excluded:Array(String)?)-instance-method" class="signature"><strong>#excluded=</strong>(excluded : Array(String)?)</a>
<a href="#excluded%3D%28excluded%3AArray%28String%29%3F%29-instance-method" class="signature"><strong>#excluded=</strong>(excluded : Array(String)?)</a>
</li>
<li class="entry-summary">
<a href="#filter_names:Array(String)-instance-method" class="signature"><strong>#filter_names</strong> : Array(String)</a>
<a href="#filter_names%3AArray%28String%29-instance-method" class="signature"><strong>#filter_names</strong> : Array(String)</a>
</li>
<li class="entry-summary">
<a href="#filter_names=(filter_names:Array(String))-instance-method" class="signature"><strong>#filter_names=</strong>(filter_names : Array(String))</a>
<a href="#filter_names%3D%28filter_names%3AArray%28String%29%29-instance-method" class="signature"><strong>#filter_names=</strong>(filter_names : Array(String))</a>
</li>
<li class="entry-summary">
<a href="#severity:Ameba::Severity-instance-method" class="signature"><strong>#severity</strong> : Ameba::Severity</a>
<a href="#severity%3AAmeba%3A%3ASeverity-instance-method" class="signature"><strong>#severity</strong> : Ameba::Severity</a>
</li>
<li class="entry-summary">
<a href="#severity=(severity)-instance-method" class="signature"><strong>#severity=</strong>(severity)</a>
<a href="#severity%3D%28severity%29-instance-method" class="signature"><strong>#severity=</strong>(severity)</a>
</li>
<li class="entry-summary">
<a href="#test(source,node:Crystal::Call)-instance-method" class="signature"><strong>#test</strong>(source, node : Crystal::Call)</a>
<a href="#test%28source%2Cnode%3ACrystal%3A%3ACall%29-instance-method" class="signature"><strong>#test</strong>(source, node : Crystal::Call)</a>
</li>
<li class="entry-summary">
<a href="#test(source)-instance-method" class="signature"><strong>#test</strong>(source)</a>
<a href="#test%28source%29-instance-method" class="signature"><strong>#test</strong>(source)</a>
</li>
@ -870,7 +869,7 @@
<h3>Instance methods inherited from class <code><a href="../../../Ameba/Rule/Performance/Base.html">Ameba::Rule::Performance::Base</a></code></h3>
<a href="../../../Ameba/Rule/Performance/Base.html#catch(source:Source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Performance/Base.html#catch%28source%3ASource%29-instance-method" class="tooltip">
<span>catch(source : Source)</span>
catch</a>
@ -882,7 +881,7 @@
<h3>Constructor methods inherited from class <code><a href="../../../Ameba/Rule/Performance/Base.html">Ameba::Rule::Performance::Base</a></code></h3>
<a href="../../../Ameba/Rule/Performance/Base.html#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method" class="tooltip">
<a href="../../../Ameba/Rule/Performance/Base.html#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method" class="tooltip">
<span>new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)<br/>new(config = <span class="n">nil</span>)</span>
new</a>
@ -918,17 +917,17 @@
<h3>Instance methods inherited from class <code><a href="../../../Ameba/Rule/Base.html">Ameba::Rule::Base</a></code></h3>
<a href="../../../Ameba/Rule/Base.html#==(other)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#%3D%3D%28other%29-instance-method" class="tooltip">
<span>==(other)</span>
==</a>,
<a href="../../../Ameba/Rule/Base.html#catch(source:Source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#catch%28source%3ASource%29-instance-method" class="tooltip">
<span>catch(source : Source)</span>
catch</a>,
<a href="../../../Ameba/Rule/Base.html#excluded?(source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#excluded%3F%28source%29-instance-method" class="tooltip">
<span>excluded?(source)</span>
excluded?</a>,
@ -948,12 +947,12 @@
name</a>,
<a href="../../../Ameba/Rule/Base.html#special?-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#special%3F-instance-method" class="tooltip">
<span>special?</span>
special?</a>,
<a href="../../../Ameba/Rule/Base.html#test(source:Source,node:Crystal::ASTNode,*opts)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#test%28source%3ASource%2Cnode%3ACrystal%3A%3AASTNode%2C%2Aopts%29-instance-method" class="tooltip">
<span>test(source : Source, node : Crystal::ASTNode, *opts)<br/>test(source : Source)</span>
test</a>
@ -1023,25 +1022,19 @@
def self.<strong>new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
<a class="method-permalink" href="#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method">#</a>
<a class="method-permalink" href="#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method">#</a>
</div>
<div class="doc">
<p>This rule is used to identify usage of <code>first/last/first?/last?</code> calls that follow filters.</p>
<p>For example, this is considered inefficient:</p>
<pre><code class="language-crystal">[<span class="n">-1</span>, <span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].<span class="k">select</span> { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">0</span> }.first?
[<span class="n">-1</span>, <span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].<span class="k">select</span> { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">0</span> }.last?</code></pre>
<p>And can be written as this:</p>
<pre><code class="language-crystal">[<span class="n">-1</span>, <span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].find { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">0</span> }
[<span class="n">-1</span>, <span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].reverse_each.find { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">0</span> }</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/FirstLastAfterFilter
Enabled: true
FilterNames:
@ -1059,25 +1052,19 @@
def self.<strong>new</strong>(config = <span class="n">nil</span>)
<a class="method-permalink" href="#new(config=nil)-class-method">#</a>
<a class="method-permalink" href="#new%28config%3Dnil%29-class-method">#</a>
</div>
<div class="doc">
<p>This rule is used to identify usage of <code>first/last/first?/last?</code> calls that follow filters.</p>
<p>For example, this is considered inefficient:</p>
<pre><code class="language-crystal">[<span class="n">-1</span>, <span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].<span class="k">select</span> { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">0</span> }.first?
[<span class="n">-1</span>, <span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].<span class="k">select</span> { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">0</span> }.last?</code></pre>
<p>And can be written as this:</p>
<pre><code class="language-crystal">[<span class="n">-1</span>, <span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].find { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">0</span> }
[<span class="n">-1</span>, <span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].reverse_each.find { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">0</span> }</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/FirstLastAfterFilter
Enabled: true
FilterNames:
@ -1087,7 +1074,7 @@
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/first_last_after_filter.cr#L28" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/first_last_after_filter.cr#L28" target="_blank">View source</a>]
</div>
</div>
@ -1111,7 +1098,7 @@
def <strong>description</strong> : String
<a class="method-permalink" href="#description:String-instance-method">#</a>
<a class="method-permalink" href="#description%3AString-instance-method">#</a>
</div>
<br/>
@ -1125,7 +1112,7 @@
def <strong>description=</strong>(description : String)
<a class="method-permalink" href="#description=(description:String)-instance-method">#</a>
<a class="method-permalink" href="#description%3D%28description%3AString%29-instance-method">#</a>
</div>
<br/>
@ -1139,7 +1126,7 @@
def <strong>enabled</strong> : Bool
<a class="method-permalink" href="#enabled:Bool-instance-method">#</a>
<a class="method-permalink" href="#enabled%3ABool-instance-method">#</a>
</div>
<br/>
@ -1153,7 +1140,7 @@
def <strong>enabled=</strong>(enabled)
<a class="method-permalink" href="#enabled=(enabled)-instance-method">#</a>
<a class="method-permalink" href="#enabled%3D%28enabled%29-instance-method">#</a>
</div>
<br/>
@ -1167,7 +1154,7 @@
def <strong>excluded</strong> : Array(String)?
<a class="method-permalink" href="#excluded:Array(String)?-instance-method">#</a>
<a class="method-permalink" href="#excluded%3AArray%28String%29%3F-instance-method">#</a>
</div>
<br/>
@ -1181,7 +1168,7 @@
def <strong>excluded=</strong>(excluded : Array(String)?)
<a class="method-permalink" href="#excluded=(excluded:Array(String)?)-instance-method">#</a>
<a class="method-permalink" href="#excluded%3D%28excluded%3AArray%28String%29%3F%29-instance-method">#</a>
</div>
<br/>
@ -1195,7 +1182,7 @@
def <strong>filter_names</strong> : Array(String)
<a class="method-permalink" href="#filter_names:Array(String)-instance-method">#</a>
<a class="method-permalink" href="#filter_names%3AArray%28String%29-instance-method">#</a>
</div>
<br/>
@ -1209,7 +1196,7 @@
def <strong>filter_names=</strong>(filter_names : Array(String))
<a class="method-permalink" href="#filter_names=(filter_names:Array(String))-instance-method">#</a>
<a class="method-permalink" href="#filter_names%3D%28filter_names%3AArray%28String%29%29-instance-method">#</a>
</div>
<br/>
@ -1223,7 +1210,7 @@
def <strong>severity</strong> : <a href="../../../Ameba/Severity.html">Ameba::Severity</a>
<a class="method-permalink" href="#severity:Ameba::Severity-instance-method">#</a>
<a class="method-permalink" href="#severity%3AAmeba%3A%3ASeverity-instance-method">#</a>
</div>
<br/>
@ -1237,7 +1224,7 @@
def <strong>severity=</strong>(severity)
<a class="method-permalink" href="#severity=(severity)-instance-method">#</a>
<a class="method-permalink" href="#severity%3D%28severity%29-instance-method">#</a>
</div>
<br/>
@ -1251,13 +1238,13 @@
def <strong>test</strong>(source, node : Crystal::Call)
<a class="method-permalink" href="#test(source,node:Crystal::Call)-instance-method">#</a>
<a class="method-permalink" href="#test%28source%2Cnode%3ACrystal%3A%3ACall%29-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/first_last_after_filter.cr#L47" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/first_last_after_filter.cr#L47" target="_blank">View source</a>]
</div>
</div>
@ -1267,13 +1254,13 @@
def <strong>test</strong>(source)
<a class="method-permalink" href="#test(source)-instance-method">#</a>
<a class="method-permalink" href="#test%28source%29-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/first_last_after_filter.cr#L38" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/first_last_after_filter.cr#L38" target="_blank">View source</a>]
</div>
</div>

View file

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Crystal Docs 0.36.1">
<meta name="generator" content="Crystal Docs 1.1.1">
<meta name="crystal_docs.project_version" content="master">
<meta name="crystal_docs.project_name" content="ameba">
@ -286,6 +286,11 @@
<ul>
<li class=" " data-id="ameba/Ameba/Rule/Lint/AmbiguousAssignment" data-name="ameba::rule::lint::ambiguousassignment">
<a href="../../../Ameba/Rule/Lint/AmbiguousAssignment.html">AmbiguousAssignment</a>
</li>
<li class=" " data-id="ameba/Ameba/Rule/Lint/BadDirective" data-name="ameba::rule::lint::baddirective">
<a href="../../../Ameba/Rule/Lint/BadDirective.html">BadDirective</a>
@ -640,17 +645,11 @@
</h2>
<p>This rule is used to identify usage of <code>flatten</code> calls that follow <code>map</code>.</p>
<p>For example, this is considered inefficient:</p>
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.map(<span class="o">&amp;</span>.chars).flatten</code></pre>
<p>And can be written as this:</p>
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.flat_map(<span class="o">&amp;</span>.chars)</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/FlattenAfterMap:
Enabled: true</code></pre>
@ -693,7 +692,7 @@
</h2>
<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/flatten_after_map.cr#L24" target="_blank">
<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/flatten_after_map.cr#L24" target="_blank">
ameba/rule/performance/flatten_after_map.cr
</a>
@ -744,14 +743,14 @@
<ul class="list-summary">
<li class="entry-summary">
<a href="#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method" class="signature"><strong>.new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)</a>
<a href="#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method" class="signature"><strong>.new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)</a>
<div class="summary"><p>This rule is used to identify usage of <code>flatten</code> calls that follow <code>map</code>.</p></div>
</li>
<li class="entry-summary">
<a href="#new(config=nil)-class-method" class="signature"><strong>.new</strong>(config = <span class="n">nil</span>)</a>
<a href="#new%28config%3Dnil%29-class-method" class="signature"><strong>.new</strong>(config = <span class="n">nil</span>)</a>
<div class="summary"><p>This rule is used to identify usage of <code>flatten</code> calls that follow <code>map</code>.</p></div>
@ -774,52 +773,52 @@
<ul class="list-summary">
<li class="entry-summary">
<a href="#description:String-instance-method" class="signature"><strong>#description</strong> : String</a>
<a href="#description%3AString-instance-method" class="signature"><strong>#description</strong> : String</a>
</li>
<li class="entry-summary">
<a href="#description=(description:String)-instance-method" class="signature"><strong>#description=</strong>(description : String)</a>
<a href="#description%3D%28description%3AString%29-instance-method" class="signature"><strong>#description=</strong>(description : String)</a>
</li>
<li class="entry-summary">
<a href="#enabled:Bool-instance-method" class="signature"><strong>#enabled</strong> : Bool</a>
<a href="#enabled%3ABool-instance-method" class="signature"><strong>#enabled</strong> : Bool</a>
</li>
<li class="entry-summary">
<a href="#enabled=(enabled)-instance-method" class="signature"><strong>#enabled=</strong>(enabled)</a>
<a href="#enabled%3D%28enabled%29-instance-method" class="signature"><strong>#enabled=</strong>(enabled)</a>
</li>
<li class="entry-summary">
<a href="#excluded:Array(String)?-instance-method" class="signature"><strong>#excluded</strong> : Array(String)?</a>
<a href="#excluded%3AArray%28String%29%3F-instance-method" class="signature"><strong>#excluded</strong> : Array(String)?</a>
</li>
<li class="entry-summary">
<a href="#excluded=(excluded:Array(String)?)-instance-method" class="signature"><strong>#excluded=</strong>(excluded : Array(String)?)</a>
<a href="#excluded%3D%28excluded%3AArray%28String%29%3F%29-instance-method" class="signature"><strong>#excluded=</strong>(excluded : Array(String)?)</a>
</li>
<li class="entry-summary">
<a href="#severity:Ameba::Severity-instance-method" class="signature"><strong>#severity</strong> : Ameba::Severity</a>
<a href="#severity%3AAmeba%3A%3ASeverity-instance-method" class="signature"><strong>#severity</strong> : Ameba::Severity</a>
</li>
<li class="entry-summary">
<a href="#severity=(severity)-instance-method" class="signature"><strong>#severity=</strong>(severity)</a>
<a href="#severity%3D%28severity%29-instance-method" class="signature"><strong>#severity=</strong>(severity)</a>
</li>
<li class="entry-summary">
<a href="#test(source,node:Crystal::Call)-instance-method" class="signature"><strong>#test</strong>(source, node : Crystal::Call)</a>
<a href="#test%28source%2Cnode%3ACrystal%3A%3ACall%29-instance-method" class="signature"><strong>#test</strong>(source, node : Crystal::Call)</a>
</li>
<li class="entry-summary">
<a href="#test(source)-instance-method" class="signature"><strong>#test</strong>(source)</a>
<a href="#test%28source%29-instance-method" class="signature"><strong>#test</strong>(source)</a>
</li>
@ -856,7 +855,7 @@
<h3>Instance methods inherited from class <code><a href="../../../Ameba/Rule/Performance/Base.html">Ameba::Rule::Performance::Base</a></code></h3>
<a href="../../../Ameba/Rule/Performance/Base.html#catch(source:Source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Performance/Base.html#catch%28source%3ASource%29-instance-method" class="tooltip">
<span>catch(source : Source)</span>
catch</a>
@ -868,7 +867,7 @@
<h3>Constructor methods inherited from class <code><a href="../../../Ameba/Rule/Performance/Base.html">Ameba::Rule::Performance::Base</a></code></h3>
<a href="../../../Ameba/Rule/Performance/Base.html#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method" class="tooltip">
<a href="../../../Ameba/Rule/Performance/Base.html#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method" class="tooltip">
<span>new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)<br/>new(config = <span class="n">nil</span>)</span>
new</a>
@ -904,17 +903,17 @@
<h3>Instance methods inherited from class <code><a href="../../../Ameba/Rule/Base.html">Ameba::Rule::Base</a></code></h3>
<a href="../../../Ameba/Rule/Base.html#==(other)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#%3D%3D%28other%29-instance-method" class="tooltip">
<span>==(other)</span>
==</a>,
<a href="../../../Ameba/Rule/Base.html#catch(source:Source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#catch%28source%3ASource%29-instance-method" class="tooltip">
<span>catch(source : Source)</span>
catch</a>,
<a href="../../../Ameba/Rule/Base.html#excluded?(source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#excluded%3F%28source%29-instance-method" class="tooltip">
<span>excluded?(source)</span>
excluded?</a>,
@ -934,12 +933,12 @@
name</a>,
<a href="../../../Ameba/Rule/Base.html#special?-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#special%3F-instance-method" class="tooltip">
<span>special?</span>
special?</a>,
<a href="../../../Ameba/Rule/Base.html#test(source:Source,node:Crystal::ASTNode,*opts)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#test%28source%3ASource%2Cnode%3ACrystal%3A%3AASTNode%2C%2Aopts%29-instance-method" class="tooltip">
<span>test(source : Source, node : Crystal::ASTNode, *opts)<br/>test(source : Source)</span>
test</a>
@ -1009,23 +1008,17 @@
def self.<strong>new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
<a class="method-permalink" href="#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method">#</a>
<a class="method-permalink" href="#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method">#</a>
</div>
<div class="doc">
<p>This rule is used to identify usage of <code>flatten</code> calls that follow <code>map</code>.</p>
<p>For example, this is considered inefficient:</p>
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.map(<span class="o">&amp;</span>.chars).flatten</code></pre>
<p>And can be written as this:</p>
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.flat_map(<span class="o">&amp;</span>.chars)</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/FlattenAfterMap:
Enabled: true</code></pre>
</div>
@ -1041,23 +1034,17 @@
def self.<strong>new</strong>(config = <span class="n">nil</span>)
<a class="method-permalink" href="#new(config=nil)-class-method">#</a>
<a class="method-permalink" href="#new%28config%3Dnil%29-class-method">#</a>
</div>
<div class="doc">
<p>This rule is used to identify usage of <code>flatten</code> calls that follow <code>map</code>.</p>
<p>For example, this is considered inefficient:</p>
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.map(<span class="o">&amp;</span>.chars).flatten</code></pre>
<p>And can be written as this:</p>
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.flat_map(<span class="o">&amp;</span>.chars)</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/FlattenAfterMap:
Enabled: true</code></pre>
</div>
@ -1065,7 +1052,7 @@
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/flatten_after_map.cr#L24" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/flatten_after_map.cr#L24" target="_blank">View source</a>]
</div>
</div>
@ -1089,7 +1076,7 @@
def <strong>description</strong> : String
<a class="method-permalink" href="#description:String-instance-method">#</a>
<a class="method-permalink" href="#description%3AString-instance-method">#</a>
</div>
<br/>
@ -1103,7 +1090,7 @@
def <strong>description=</strong>(description : String)
<a class="method-permalink" href="#description=(description:String)-instance-method">#</a>
<a class="method-permalink" href="#description%3D%28description%3AString%29-instance-method">#</a>
</div>
<br/>
@ -1117,7 +1104,7 @@
def <strong>enabled</strong> : Bool
<a class="method-permalink" href="#enabled:Bool-instance-method">#</a>
<a class="method-permalink" href="#enabled%3ABool-instance-method">#</a>
</div>
<br/>
@ -1131,7 +1118,7 @@
def <strong>enabled=</strong>(enabled)
<a class="method-permalink" href="#enabled=(enabled)-instance-method">#</a>
<a class="method-permalink" href="#enabled%3D%28enabled%29-instance-method">#</a>
</div>
<br/>
@ -1145,7 +1132,7 @@
def <strong>excluded</strong> : Array(String)?
<a class="method-permalink" href="#excluded:Array(String)?-instance-method">#</a>
<a class="method-permalink" href="#excluded%3AArray%28String%29%3F-instance-method">#</a>
</div>
<br/>
@ -1159,7 +1146,7 @@
def <strong>excluded=</strong>(excluded : Array(String)?)
<a class="method-permalink" href="#excluded=(excluded:Array(String)?)-instance-method">#</a>
<a class="method-permalink" href="#excluded%3D%28excluded%3AArray%28String%29%3F%29-instance-method">#</a>
</div>
<br/>
@ -1173,7 +1160,7 @@
def <strong>severity</strong> : <a href="../../../Ameba/Severity.html">Ameba::Severity</a>
<a class="method-permalink" href="#severity:Ameba::Severity-instance-method">#</a>
<a class="method-permalink" href="#severity%3AAmeba%3A%3ASeverity-instance-method">#</a>
</div>
<br/>
@ -1187,7 +1174,7 @@
def <strong>severity=</strong>(severity)
<a class="method-permalink" href="#severity=(severity)-instance-method">#</a>
<a class="method-permalink" href="#severity%3D%28severity%29-instance-method">#</a>
</div>
<br/>
@ -1201,13 +1188,13 @@
def <strong>test</strong>(source, node : Crystal::Call)
<a class="method-permalink" href="#test(source,node:Crystal::Call)-instance-method">#</a>
<a class="method-permalink" href="#test%28source%2Cnode%3ACrystal%3A%3ACall%29-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/flatten_after_map.cr#L42" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/flatten_after_map.cr#L42" target="_blank">View source</a>]
</div>
</div>
@ -1217,13 +1204,13 @@
def <strong>test</strong>(source)
<a class="method-permalink" href="#test(source)-instance-method">#</a>
<a class="method-permalink" href="#test%28source%29-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/flatten_after_map.cr#L33" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/flatten_after_map.cr#L33" target="_blank">View source</a>]
</div>
</div>

View file

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Crystal Docs 0.36.1">
<meta name="generator" content="Crystal Docs 1.1.1">
<meta name="crystal_docs.project_version" content="master">
<meta name="crystal_docs.project_name" content="ameba">
@ -286,6 +286,11 @@
<ul>
<li class=" " data-id="ameba/Ameba/Rule/Lint/AmbiguousAssignment" data-name="ameba::rule::lint::ambiguousassignment">
<a href="../../../Ameba/Rule/Lint/AmbiguousAssignment.html">AmbiguousAssignment</a>
</li>
<li class=" " data-id="ameba/Ameba/Rule/Lint/BadDirective" data-name="ameba::rule::lint::baddirective">
<a href="../../../Ameba/Rule/Lint/BadDirective.html">BadDirective</a>
@ -641,17 +646,11 @@
<p>This rule is used to identify usage of <code>sum/product</code> calls
that follow <code>map</code>.</p>
<p>For example, this is considered inefficient:</p>
<pre><code class="language-crystal">(<span class="n">1</span>..<span class="n">3</span>).map(<span class="o">&amp;</span>.<span class="o">*</span>(<span class="n">2</span>)).sum</code></pre>
<p>And can be written as this:</p>
<pre><code class="language-crystal">(<span class="n">1</span>..<span class="n">3</span>).sum(<span class="o">&amp;</span>.<span class="o">*</span>(<span class="n">2</span>))</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/MapInsteadOfBlock:
Enabled: true</code></pre>
@ -694,7 +693,7 @@ that follow <code>map</code>.</p>
</h2>
<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/map_instead_of_block.cr#L25" target="_blank">
<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/map_instead_of_block.cr#L25" target="_blank">
ameba/rule/performance/map_instead_of_block.cr
</a>
@ -745,14 +744,14 @@ that follow <code>map</code>.</p>
<ul class="list-summary">
<li class="entry-summary">
<a href="#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method" class="signature"><strong>.new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)</a>
<a href="#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method" class="signature"><strong>.new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)</a>
<div class="summary"><p>This rule is used to identify usage of <code>sum/product</code> calls that follow <code>map</code>.</p></div>
</li>
<li class="entry-summary">
<a href="#new(config=nil)-class-method" class="signature"><strong>.new</strong>(config = <span class="n">nil</span>)</a>
<a href="#new%28config%3Dnil%29-class-method" class="signature"><strong>.new</strong>(config = <span class="n">nil</span>)</a>
<div class="summary"><p>This rule is used to identify usage of <code>sum/product</code> calls that follow <code>map</code>.</p></div>
@ -775,52 +774,52 @@ that follow <code>map</code>.</p>
<ul class="list-summary">
<li class="entry-summary">
<a href="#description:String-instance-method" class="signature"><strong>#description</strong> : String</a>
<a href="#description%3AString-instance-method" class="signature"><strong>#description</strong> : String</a>
</li>
<li class="entry-summary">
<a href="#description=(description:String)-instance-method" class="signature"><strong>#description=</strong>(description : String)</a>
<a href="#description%3D%28description%3AString%29-instance-method" class="signature"><strong>#description=</strong>(description : String)</a>
</li>
<li class="entry-summary">
<a href="#enabled:Bool-instance-method" class="signature"><strong>#enabled</strong> : Bool</a>
<a href="#enabled%3ABool-instance-method" class="signature"><strong>#enabled</strong> : Bool</a>
</li>
<li class="entry-summary">
<a href="#enabled=(enabled)-instance-method" class="signature"><strong>#enabled=</strong>(enabled)</a>
<a href="#enabled%3D%28enabled%29-instance-method" class="signature"><strong>#enabled=</strong>(enabled)</a>
</li>
<li class="entry-summary">
<a href="#excluded:Array(String)?-instance-method" class="signature"><strong>#excluded</strong> : Array(String)?</a>
<a href="#excluded%3AArray%28String%29%3F-instance-method" class="signature"><strong>#excluded</strong> : Array(String)?</a>
</li>
<li class="entry-summary">
<a href="#excluded=(excluded:Array(String)?)-instance-method" class="signature"><strong>#excluded=</strong>(excluded : Array(String)?)</a>
<a href="#excluded%3D%28excluded%3AArray%28String%29%3F%29-instance-method" class="signature"><strong>#excluded=</strong>(excluded : Array(String)?)</a>
</li>
<li class="entry-summary">
<a href="#severity:Ameba::Severity-instance-method" class="signature"><strong>#severity</strong> : Ameba::Severity</a>
<a href="#severity%3AAmeba%3A%3ASeverity-instance-method" class="signature"><strong>#severity</strong> : Ameba::Severity</a>
</li>
<li class="entry-summary">
<a href="#severity=(severity)-instance-method" class="signature"><strong>#severity=</strong>(severity)</a>
<a href="#severity%3D%28severity%29-instance-method" class="signature"><strong>#severity=</strong>(severity)</a>
</li>
<li class="entry-summary">
<a href="#test(source,node:Crystal::Call)-instance-method" class="signature"><strong>#test</strong>(source, node : Crystal::Call)</a>
<a href="#test%28source%2Cnode%3ACrystal%3A%3ACall%29-instance-method" class="signature"><strong>#test</strong>(source, node : Crystal::Call)</a>
</li>
<li class="entry-summary">
<a href="#test(source)-instance-method" class="signature"><strong>#test</strong>(source)</a>
<a href="#test%28source%29-instance-method" class="signature"><strong>#test</strong>(source)</a>
</li>
@ -857,7 +856,7 @@ that follow <code>map</code>.</p>
<h3>Instance methods inherited from class <code><a href="../../../Ameba/Rule/Performance/Base.html">Ameba::Rule::Performance::Base</a></code></h3>
<a href="../../../Ameba/Rule/Performance/Base.html#catch(source:Source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Performance/Base.html#catch%28source%3ASource%29-instance-method" class="tooltip">
<span>catch(source : Source)</span>
catch</a>
@ -869,7 +868,7 @@ that follow <code>map</code>.</p>
<h3>Constructor methods inherited from class <code><a href="../../../Ameba/Rule/Performance/Base.html">Ameba::Rule::Performance::Base</a></code></h3>
<a href="../../../Ameba/Rule/Performance/Base.html#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method" class="tooltip">
<a href="../../../Ameba/Rule/Performance/Base.html#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method" class="tooltip">
<span>new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)<br/>new(config = <span class="n">nil</span>)</span>
new</a>
@ -905,17 +904,17 @@ that follow <code>map</code>.</p>
<h3>Instance methods inherited from class <code><a href="../../../Ameba/Rule/Base.html">Ameba::Rule::Base</a></code></h3>
<a href="../../../Ameba/Rule/Base.html#==(other)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#%3D%3D%28other%29-instance-method" class="tooltip">
<span>==(other)</span>
==</a>,
<a href="../../../Ameba/Rule/Base.html#catch(source:Source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#catch%28source%3ASource%29-instance-method" class="tooltip">
<span>catch(source : Source)</span>
catch</a>,
<a href="../../../Ameba/Rule/Base.html#excluded?(source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#excluded%3F%28source%29-instance-method" class="tooltip">
<span>excluded?(source)</span>
excluded?</a>,
@ -935,12 +934,12 @@ that follow <code>map</code>.</p>
name</a>,
<a href="../../../Ameba/Rule/Base.html#special?-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#special%3F-instance-method" class="tooltip">
<span>special?</span>
special?</a>,
<a href="../../../Ameba/Rule/Base.html#test(source:Source,node:Crystal::ASTNode,*opts)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#test%28source%3ASource%2Cnode%3ACrystal%3A%3AASTNode%2C%2Aopts%29-instance-method" class="tooltip">
<span>test(source : Source, node : Crystal::ASTNode, *opts)<br/>test(source : Source)</span>
test</a>
@ -1010,24 +1009,18 @@ that follow <code>map</code>.</p>
def self.<strong>new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
<a class="method-permalink" href="#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method">#</a>
<a class="method-permalink" href="#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method">#</a>
</div>
<div class="doc">
<p>This rule is used to identify usage of <code>sum/product</code> calls
that follow <code>map</code>.</p>
<p>For example, this is considered inefficient:</p>
<pre><code class="language-crystal">(<span class="n">1</span>..<span class="n">3</span>).map(<span class="o">&amp;</span>.<span class="o">*</span>(<span class="n">2</span>)).sum</code></pre>
<p>And can be written as this:</p>
<pre><code class="language-crystal">(<span class="n">1</span>..<span class="n">3</span>).sum(<span class="o">&amp;</span>.<span class="o">*</span>(<span class="n">2</span>))</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/MapInsteadOfBlock:
Enabled: true</code></pre>
</div>
@ -1043,24 +1036,18 @@ that follow <code>map</code>.</p>
def self.<strong>new</strong>(config = <span class="n">nil</span>)
<a class="method-permalink" href="#new(config=nil)-class-method">#</a>
<a class="method-permalink" href="#new%28config%3Dnil%29-class-method">#</a>
</div>
<div class="doc">
<p>This rule is used to identify usage of <code>sum/product</code> calls
that follow <code>map</code>.</p>
<p>For example, this is considered inefficient:</p>
<pre><code class="language-crystal">(<span class="n">1</span>..<span class="n">3</span>).map(<span class="o">&amp;</span>.<span class="o">*</span>(<span class="n">2</span>)).sum</code></pre>
<p>And can be written as this:</p>
<pre><code class="language-crystal">(<span class="n">1</span>..<span class="n">3</span>).sum(<span class="o">&amp;</span>.<span class="o">*</span>(<span class="n">2</span>))</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/MapInsteadOfBlock:
Enabled: true</code></pre>
</div>
@ -1068,7 +1055,7 @@ that follow <code>map</code>.</p>
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/map_instead_of_block.cr#L25" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/map_instead_of_block.cr#L25" target="_blank">View source</a>]
</div>
</div>
@ -1092,7 +1079,7 @@ that follow <code>map</code>.</p>
def <strong>description</strong> : String
<a class="method-permalink" href="#description:String-instance-method">#</a>
<a class="method-permalink" href="#description%3AString-instance-method">#</a>
</div>
<br/>
@ -1106,7 +1093,7 @@ that follow <code>map</code>.</p>
def <strong>description=</strong>(description : String)
<a class="method-permalink" href="#description=(description:String)-instance-method">#</a>
<a class="method-permalink" href="#description%3D%28description%3AString%29-instance-method">#</a>
</div>
<br/>
@ -1120,7 +1107,7 @@ that follow <code>map</code>.</p>
def <strong>enabled</strong> : Bool
<a class="method-permalink" href="#enabled:Bool-instance-method">#</a>
<a class="method-permalink" href="#enabled%3ABool-instance-method">#</a>
</div>
<br/>
@ -1134,7 +1121,7 @@ that follow <code>map</code>.</p>
def <strong>enabled=</strong>(enabled)
<a class="method-permalink" href="#enabled=(enabled)-instance-method">#</a>
<a class="method-permalink" href="#enabled%3D%28enabled%29-instance-method">#</a>
</div>
<br/>
@ -1148,7 +1135,7 @@ that follow <code>map</code>.</p>
def <strong>excluded</strong> : Array(String)?
<a class="method-permalink" href="#excluded:Array(String)?-instance-method">#</a>
<a class="method-permalink" href="#excluded%3AArray%28String%29%3F-instance-method">#</a>
</div>
<br/>
@ -1162,7 +1149,7 @@ that follow <code>map</code>.</p>
def <strong>excluded=</strong>(excluded : Array(String)?)
<a class="method-permalink" href="#excluded=(excluded:Array(String)?)-instance-method">#</a>
<a class="method-permalink" href="#excluded%3D%28excluded%3AArray%28String%29%3F%29-instance-method">#</a>
</div>
<br/>
@ -1176,7 +1163,7 @@ that follow <code>map</code>.</p>
def <strong>severity</strong> : <a href="../../../Ameba/Severity.html">Ameba::Severity</a>
<a class="method-permalink" href="#severity:Ameba::Severity-instance-method">#</a>
<a class="method-permalink" href="#severity%3AAmeba%3A%3ASeverity-instance-method">#</a>
</div>
<br/>
@ -1190,7 +1177,7 @@ that follow <code>map</code>.</p>
def <strong>severity=</strong>(severity)
<a class="method-permalink" href="#severity=(severity)-instance-method">#</a>
<a class="method-permalink" href="#severity%3D%28severity%29-instance-method">#</a>
</div>
<br/>
@ -1204,13 +1191,13 @@ that follow <code>map</code>.</p>
def <strong>test</strong>(source, node : Crystal::Call)
<a class="method-permalink" href="#test(source,node:Crystal::Call)-instance-method">#</a>
<a class="method-permalink" href="#test%28source%2Cnode%3ACrystal%3A%3ACall%29-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/map_instead_of_block.cr#L43" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/map_instead_of_block.cr#L43" target="_blank">View source</a>]
</div>
</div>
@ -1220,13 +1207,13 @@ that follow <code>map</code>.</p>
def <strong>test</strong>(source)
<a class="method-permalink" href="#test(source)-instance-method">#</a>
<a class="method-permalink" href="#test%28source%29-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/map_instead_of_block.cr#L34" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/map_instead_of_block.cr#L34" target="_blank">View source</a>]
</div>
</div>

View file

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Crystal Docs 0.36.1">
<meta name="generator" content="Crystal Docs 1.1.1">
<meta name="crystal_docs.project_version" content="master">
<meta name="crystal_docs.project_name" content="ameba">
@ -286,6 +286,11 @@
<ul>
<li class=" " data-id="ameba/Ameba/Rule/Lint/AmbiguousAssignment" data-name="ameba::rule::lint::ambiguousassignment">
<a href="../../../Ameba/Rule/Lint/AmbiguousAssignment.html">AmbiguousAssignment</a>
</li>
<li class=" " data-id="ameba/Ameba/Rule/Lint/BadDirective" data-name="ameba::rule::lint::baddirective">
<a href="../../../Ameba/Rule/Lint/BadDirective.html">BadDirective</a>
@ -640,25 +645,19 @@
</h2>
<p>This rule is used to identify usage of <code>size</code> calls that follow filter.</p>
<p>For example, this is considered invalid:</p>
<pre><code class="language-crystal">[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].<span class="k">select</span> { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">2</span> }.size
[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].reject { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&lt;</span> <span class="n">2</span> }.size
[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].<span class="k">select</span>(<span class="o">&amp;</span>.<span class="o">&lt;</span> <span class="n">2</span>).size
[<span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].<span class="k">select</span>(<span class="o">&amp;</span>.zero?).size
[<span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].reject(<span class="o">&amp;</span>.zero?).size</code></pre>
<p>And it should be written as this:</p>
<pre><code class="language-crystal">[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].count { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">2</span> }
[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].count { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;=</span> <span class="n">2</span> }
[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].count(<span class="o">&amp;</span>.<span class="o">&lt;</span> <span class="n">2</span>)
[<span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].count(<span class="o">&amp;</span>.zero?)
[<span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].count(<span class="o">&amp;</span>.<span class="o">!=</span> <span class="n">0</span>)</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/SizeAfterFilter:
Enabled: true
FilterNames:
@ -704,7 +703,7 @@
</h2>
<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/size_after_filter.cr#L35" target="_blank">
<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/size_after_filter.cr#L35" target="_blank">
ameba/rule/performance/size_after_filter.cr
</a>
@ -750,14 +749,14 @@
<ul class="list-summary">
<li class="entry-summary">
<a href="#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method" class="signature"><strong>.new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)</a>
<a href="#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method" class="signature"><strong>.new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)</a>
<div class="summary"><p>This rule is used to identify usage of <code>size</code> calls that follow filter.</p></div>
</li>
<li class="entry-summary">
<a href="#new(config=nil)-class-method" class="signature"><strong>.new</strong>(config = <span class="n">nil</span>)</a>
<a href="#new%28config%3Dnil%29-class-method" class="signature"><strong>.new</strong>(config = <span class="n">nil</span>)</a>
<div class="summary"><p>This rule is used to identify usage of <code>size</code> calls that follow filter.</p></div>
@ -780,62 +779,62 @@
<ul class="list-summary">
<li class="entry-summary">
<a href="#description:String-instance-method" class="signature"><strong>#description</strong> : String</a>
<a href="#description%3AString-instance-method" class="signature"><strong>#description</strong> : String</a>
</li>
<li class="entry-summary">
<a href="#description=(description:String)-instance-method" class="signature"><strong>#description=</strong>(description : String)</a>
<a href="#description%3D%28description%3AString%29-instance-method" class="signature"><strong>#description=</strong>(description : String)</a>
</li>
<li class="entry-summary">
<a href="#enabled:Bool-instance-method" class="signature"><strong>#enabled</strong> : Bool</a>
<a href="#enabled%3ABool-instance-method" class="signature"><strong>#enabled</strong> : Bool</a>
</li>
<li class="entry-summary">
<a href="#enabled=(enabled)-instance-method" class="signature"><strong>#enabled=</strong>(enabled)</a>
<a href="#enabled%3D%28enabled%29-instance-method" class="signature"><strong>#enabled=</strong>(enabled)</a>
</li>
<li class="entry-summary">
<a href="#excluded:Array(String)?-instance-method" class="signature"><strong>#excluded</strong> : Array(String)?</a>
<a href="#excluded%3AArray%28String%29%3F-instance-method" class="signature"><strong>#excluded</strong> : Array(String)?</a>
</li>
<li class="entry-summary">
<a href="#excluded=(excluded:Array(String)?)-instance-method" class="signature"><strong>#excluded=</strong>(excluded : Array(String)?)</a>
<a href="#excluded%3D%28excluded%3AArray%28String%29%3F%29-instance-method" class="signature"><strong>#excluded=</strong>(excluded : Array(String)?)</a>
</li>
<li class="entry-summary">
<a href="#filter_names:Array(String)-instance-method" class="signature"><strong>#filter_names</strong> : Array(String)</a>
<a href="#filter_names%3AArray%28String%29-instance-method" class="signature"><strong>#filter_names</strong> : Array(String)</a>
</li>
<li class="entry-summary">
<a href="#filter_names=(filter_names:Array(String))-instance-method" class="signature"><strong>#filter_names=</strong>(filter_names : Array(String))</a>
<a href="#filter_names%3D%28filter_names%3AArray%28String%29%29-instance-method" class="signature"><strong>#filter_names=</strong>(filter_names : Array(String))</a>
</li>
<li class="entry-summary">
<a href="#severity:Ameba::Severity-instance-method" class="signature"><strong>#severity</strong> : Ameba::Severity</a>
<a href="#severity%3AAmeba%3A%3ASeverity-instance-method" class="signature"><strong>#severity</strong> : Ameba::Severity</a>
</li>
<li class="entry-summary">
<a href="#severity=(severity)-instance-method" class="signature"><strong>#severity=</strong>(severity)</a>
<a href="#severity%3D%28severity%29-instance-method" class="signature"><strong>#severity=</strong>(severity)</a>
</li>
<li class="entry-summary">
<a href="#test(source,node:Crystal::Call)-instance-method" class="signature"><strong>#test</strong>(source, node : Crystal::Call)</a>
<a href="#test%28source%2Cnode%3ACrystal%3A%3ACall%29-instance-method" class="signature"><strong>#test</strong>(source, node : Crystal::Call)</a>
</li>
<li class="entry-summary">
<a href="#test(source)-instance-method" class="signature"><strong>#test</strong>(source)</a>
<a href="#test%28source%29-instance-method" class="signature"><strong>#test</strong>(source)</a>
</li>
@ -872,7 +871,7 @@
<h3>Instance methods inherited from class <code><a href="../../../Ameba/Rule/Performance/Base.html">Ameba::Rule::Performance::Base</a></code></h3>
<a href="../../../Ameba/Rule/Performance/Base.html#catch(source:Source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Performance/Base.html#catch%28source%3ASource%29-instance-method" class="tooltip">
<span>catch(source : Source)</span>
catch</a>
@ -884,7 +883,7 @@
<h3>Constructor methods inherited from class <code><a href="../../../Ameba/Rule/Performance/Base.html">Ameba::Rule::Performance::Base</a></code></h3>
<a href="../../../Ameba/Rule/Performance/Base.html#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method" class="tooltip">
<a href="../../../Ameba/Rule/Performance/Base.html#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method" class="tooltip">
<span>new(ctx : YAML::ParseContext, node : YAML::Nodes::Node)<br/>new(config = <span class="n">nil</span>)</span>
new</a>
@ -920,17 +919,17 @@
<h3>Instance methods inherited from class <code><a href="../../../Ameba/Rule/Base.html">Ameba::Rule::Base</a></code></h3>
<a href="../../../Ameba/Rule/Base.html#==(other)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#%3D%3D%28other%29-instance-method" class="tooltip">
<span>==(other)</span>
==</a>,
<a href="../../../Ameba/Rule/Base.html#catch(source:Source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#catch%28source%3ASource%29-instance-method" class="tooltip">
<span>catch(source : Source)</span>
catch</a>,
<a href="../../../Ameba/Rule/Base.html#excluded?(source)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#excluded%3F%28source%29-instance-method" class="tooltip">
<span>excluded?(source)</span>
excluded?</a>,
@ -950,12 +949,12 @@
name</a>,
<a href="../../../Ameba/Rule/Base.html#special?-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#special%3F-instance-method" class="tooltip">
<span>special?</span>
special?</a>,
<a href="../../../Ameba/Rule/Base.html#test(source:Source,node:Crystal::ASTNode,*opts)-instance-method" class="tooltip">
<a href="../../../Ameba/Rule/Base.html#test%28source%3ASource%2Cnode%3ACrystal%3A%3AASTNode%2C%2Aopts%29-instance-method" class="tooltip">
<span>test(source : Source, node : Crystal::ASTNode, *opts)<br/>test(source : Source)</span>
test</a>
@ -1025,31 +1024,25 @@
def self.<strong>new</strong>(ctx : YAML::ParseContext, node : YAML::Nodes::Node)
<a class="method-permalink" href="#new(ctx:YAML::ParseContext,node:YAML::Nodes::Node)-class-method">#</a>
<a class="method-permalink" href="#new%28ctx%3AYAML%3A%3AParseContext%2Cnode%3AYAML%3A%3ANodes%3A%3ANode%29-class-method">#</a>
</div>
<div class="doc">
<p>This rule is used to identify usage of <code>size</code> calls that follow filter.</p>
<p>For example, this is considered invalid:</p>
<pre><code class="language-crystal">[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].<span class="k">select</span> { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">2</span> }.size
[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].reject { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&lt;</span> <span class="n">2</span> }.size
[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].<span class="k">select</span>(<span class="o">&amp;</span>.<span class="o">&lt;</span> <span class="n">2</span>).size
[<span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].<span class="k">select</span>(<span class="o">&amp;</span>.zero?).size
[<span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].reject(<span class="o">&amp;</span>.zero?).size</code></pre>
<p>And it should be written as this:</p>
<pre><code class="language-crystal">[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].count { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">2</span> }
[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].count { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;=</span> <span class="n">2</span> }
[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].count(<span class="o">&amp;</span>.<span class="o">&lt;</span> <span class="n">2</span>)
[<span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].count(<span class="o">&amp;</span>.zero?)
[<span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].count(<span class="o">&amp;</span>.<span class="o">!=</span> <span class="n">0</span>)</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/SizeAfterFilter:
Enabled: true
FilterNames:
@ -1068,31 +1061,25 @@
def self.<strong>new</strong>(config = <span class="n">nil</span>)
<a class="method-permalink" href="#new(config=nil)-class-method">#</a>
<a class="method-permalink" href="#new%28config%3Dnil%29-class-method">#</a>
</div>
<div class="doc">
<p>This rule is used to identify usage of <code>size</code> calls that follow filter.</p>
<p>For example, this is considered invalid:</p>
<pre><code class="language-crystal">[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].<span class="k">select</span> { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">2</span> }.size
[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].reject { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&lt;</span> <span class="n">2</span> }.size
[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].<span class="k">select</span>(<span class="o">&amp;</span>.<span class="o">&lt;</span> <span class="n">2</span>).size
[<span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].<span class="k">select</span>(<span class="o">&amp;</span>.zero?).size
[<span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].reject(<span class="o">&amp;</span>.zero?).size</code></pre>
<p>And it should be written as this:</p>
<pre><code class="language-crystal">[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].count { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;</span> <span class="n">2</span> }
[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].count { <span class="o">|</span>e<span class="o">|</span> e <span class="o">&gt;=</span> <span class="n">2</span> }
[<span class="n">1</span>, <span class="n">2</span>, <span class="n">3</span>].count(<span class="o">&amp;</span>.<span class="o">&lt;</span> <span class="n">2</span>)
[<span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].count(<span class="o">&amp;</span>.zero?)
[<span class="n">0</span>, <span class="n">1</span>, <span class="n">2</span>].count(<span class="o">&amp;</span>.<span class="o">!=</span> <span class="n">0</span>)</code></pre>
<p>YAML configuration example:</p>
<pre><code class="language-crystal">Performance/SizeAfterFilter:
Enabled: true
FilterNames:
@ -1103,7 +1090,7 @@
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/size_after_filter.cr#L35" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/size_after_filter.cr#L35" target="_blank">View source</a>]
</div>
</div>
@ -1127,7 +1114,7 @@
def <strong>description</strong> : String
<a class="method-permalink" href="#description:String-instance-method">#</a>
<a class="method-permalink" href="#description%3AString-instance-method">#</a>
</div>
<br/>
@ -1141,7 +1128,7 @@
def <strong>description=</strong>(description : String)
<a class="method-permalink" href="#description=(description:String)-instance-method">#</a>
<a class="method-permalink" href="#description%3D%28description%3AString%29-instance-method">#</a>
</div>
<br/>
@ -1155,7 +1142,7 @@
def <strong>enabled</strong> : Bool
<a class="method-permalink" href="#enabled:Bool-instance-method">#</a>
<a class="method-permalink" href="#enabled%3ABool-instance-method">#</a>
</div>
<br/>
@ -1169,7 +1156,7 @@
def <strong>enabled=</strong>(enabled)
<a class="method-permalink" href="#enabled=(enabled)-instance-method">#</a>
<a class="method-permalink" href="#enabled%3D%28enabled%29-instance-method">#</a>
</div>
<br/>
@ -1183,7 +1170,7 @@
def <strong>excluded</strong> : Array(String)?
<a class="method-permalink" href="#excluded:Array(String)?-instance-method">#</a>
<a class="method-permalink" href="#excluded%3AArray%28String%29%3F-instance-method">#</a>
</div>
<br/>
@ -1197,7 +1184,7 @@
def <strong>excluded=</strong>(excluded : Array(String)?)
<a class="method-permalink" href="#excluded=(excluded:Array(String)?)-instance-method">#</a>
<a class="method-permalink" href="#excluded%3D%28excluded%3AArray%28String%29%3F%29-instance-method">#</a>
</div>
<br/>
@ -1211,7 +1198,7 @@
def <strong>filter_names</strong> : Array(String)
<a class="method-permalink" href="#filter_names:Array(String)-instance-method">#</a>
<a class="method-permalink" href="#filter_names%3AArray%28String%29-instance-method">#</a>
</div>
<br/>
@ -1225,7 +1212,7 @@
def <strong>filter_names=</strong>(filter_names : Array(String))
<a class="method-permalink" href="#filter_names=(filter_names:Array(String))-instance-method">#</a>
<a class="method-permalink" href="#filter_names%3D%28filter_names%3AArray%28String%29%29-instance-method">#</a>
</div>
<br/>
@ -1239,7 +1226,7 @@
def <strong>severity</strong> : <a href="../../../Ameba/Severity.html">Ameba::Severity</a>
<a class="method-permalink" href="#severity:Ameba::Severity-instance-method">#</a>
<a class="method-permalink" href="#severity%3AAmeba%3A%3ASeverity-instance-method">#</a>
</div>
<br/>
@ -1253,7 +1240,7 @@
def <strong>severity=</strong>(severity)
<a class="method-permalink" href="#severity=(severity)-instance-method">#</a>
<a class="method-permalink" href="#severity%3D%28severity%29-instance-method">#</a>
</div>
<br/>
@ -1267,13 +1254,13 @@
def <strong>test</strong>(source, node : Crystal::Call)
<a class="method-permalink" href="#test(source,node:Crystal::Call)-instance-method">#</a>
<a class="method-permalink" href="#test%28source%2Cnode%3ACrystal%3A%3ACall%29-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/size_after_filter.cr#L53" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/size_after_filter.cr#L53" target="_blank">View source</a>]
</div>
</div>
@ -1283,13 +1270,13 @@
def <strong>test</strong>(source)
<a class="method-permalink" href="#test(source)-instance-method">#</a>
<a class="method-permalink" href="#test%28source%29-instance-method">#</a>
</div>
<br/>
<div>
[<a href="https://github.com/crystal-ameba/ameba/blob/9a91e42b/src/ameba/rule/performance/size_after_filter.cr#L44" target="_blank">View source</a>]
[<a href="https://github.com/crystal-ameba/ameba/blob/48b15b9b/src/ameba/rule/performance/size_after_filter.cr#L44" target="_blank">View source</a>]
</div>
</div>