mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Deploying to gh-pages from @ crystal-ameba/ameba@52a3e47a3b 🚀
This commit is contained in:
parent
78ed02da45
commit
4be0551946
146 changed files with 855 additions and 855 deletions
|
@ -900,12 +900,12 @@
|
|||
Overview
|
||||
</h2>
|
||||
|
||||
<p>This rule is used to identify usage of <code>index/rindex/find</code> calls
|
||||
<p>This rule is used to identify usage of <code>index/rindex/find/match</code> calls
|
||||
followed by a call to <code>not_nil!</code>.</p>
|
||||
<p>For example, this is considered a code smell:</p>
|
||||
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.find(<span class="o">&</span>.match(<span class="o">/</span><span class="o">^</span><span class="t">A</span>.<span class="o">/</span>)).not_nil!</code></pre>
|
||||
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.find(<span class="o">&</span>.chars.any?(<span class="o">&</span>.in?(<span class="s">'o'</span>, <span class="s">'b'</span>))).not_nil!</code></pre>
|
||||
<p>And can be written as this:</p>
|
||||
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.find!(<span class="o">&</span>.match(<span class="o">/</span><span class="o">^</span><span class="t">A</span>.<span class="o">/</span>))</code></pre>
|
||||
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.find!(<span class="o">&</span>.chars.any?(<span class="o">&</span>.in?(<span class="s">'o'</span>, <span class="s">'b'</span>)))</code></pre>
|
||||
<p>YAML configuration example:</p>
|
||||
<pre><code class="language-crystal"><span class="t">Lint</span><span class="o">/</span><span class="t">NotNilAfterNoBang</span>:
|
||||
<span class="t">Enabled</span>: <span class="n">true</span></code></pre>
|
||||
|
@ -951,7 +951,7 @@ followed by a call to <code>not_nil!</code>.</p>
|
|||
</h2>
|
||||
|
||||
|
||||
<a href="https://github.com/crystal-ameba/ameba/blob/3b87aa6/src/ameba/rule/lint/not_nil_after_no_bang.cr#L23" target="_blank">
|
||||
<a href="https://github.com/crystal-ameba/ameba/blob/52a3e47/src/ameba/rule/lint/not_nil_after_no_bang.cr#L23" target="_blank">
|
||||
ameba/rule/lint/not_nil_after_no_bang.cr
|
||||
</a>
|
||||
|
||||
|
@ -978,7 +978,7 @@ followed by a call to <code>not_nil!</code>.</p>
|
|||
|
||||
|
||||
<dt class="entry-const" id="CALL_NAMES">
|
||||
<strong>CALL_NAMES</strong> = <code>[<span class="s">"index"</span>, <span class="s">"rindex"</span>] <span class="k">of</span> <span class="t">::</span><span class="t">String</span></code>
|
||||
<strong>CALL_NAMES</strong> = <code>[<span class="s">"index"</span>, <span class="s">"rindex"</span>, <span class="s">"match"</span>] <span class="k">of</span> <span class="t">::</span><span class="t">String</span></code>
|
||||
</dt>
|
||||
|
||||
|
||||
|
@ -1009,7 +1009,7 @@ followed by a call to <code>not_nil!</code>.</p>
|
|||
<li class="entry-summary">
|
||||
<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>index/rindex/find</code> calls followed by a call to <code>not_nil!</code>.</p></div>
|
||||
<div class="summary"><p>This rule is used to identify usage of <code>index/rindex/find/match</code> calls followed by a call to <code>not_nil!</code>.</p></div>
|
||||
|
||||
</li>
|
||||
|
||||
|
@ -1349,12 +1349,12 @@ followed by a call to <code>not_nil!</code>.</p>
|
|||
|
||||
<div class="doc">
|
||||
|
||||
<p>This rule is used to identify usage of <code>index/rindex/find</code> calls
|
||||
<p>This rule is used to identify usage of <code>index/rindex/find/match</code> calls
|
||||
followed by a call to <code>not_nil!</code>.</p>
|
||||
<p>For example, this is considered a code smell:</p>
|
||||
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.find(<span class="o">&</span>.match(<span class="o">/</span><span class="o">^</span><span class="t">A</span>.<span class="o">/</span>)).not_nil!</code></pre>
|
||||
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.find(<span class="o">&</span>.chars.any?(<span class="o">&</span>.in?(<span class="s">'o'</span>, <span class="s">'b'</span>))).not_nil!</code></pre>
|
||||
<p>And can be written as this:</p>
|
||||
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.find!(<span class="o">&</span>.match(<span class="o">/</span><span class="o">^</span><span class="t">A</span>.<span class="o">/</span>))</code></pre>
|
||||
<pre><code class="language-crystal"><span class="s">%w[Alice Bob]</span>.find!(<span class="o">&</span>.chars.any?(<span class="o">&</span>.in?(<span class="s">'o'</span>, <span class="s">'b'</span>)))</code></pre>
|
||||
<p>YAML configuration example:</p>
|
||||
<pre><code class="language-crystal"><span class="t">Lint</span><span class="o">/</span><span class="t">NotNilAfterNoBang</span>:
|
||||
<span class="t">Enabled</span>: <span class="n">true</span></code></pre>
|
||||
|
@ -1363,7 +1363,7 @@ followed by a call to <code>not_nil!</code>.</p>
|
|||
<br/>
|
||||
<div>
|
||||
|
||||
[<a href="https://github.com/crystal-ameba/ameba/blob/3b87aa6/src/ameba/rule/lint/not_nil_after_no_bang.cr#L23" target="_blank">View source</a>]
|
||||
[<a href="https://github.com/crystal-ameba/ameba/blob/52a3e47/src/ameba/rule/lint/not_nil_after_no_bang.cr#L23" target="_blank">View source</a>]
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1544,7 +1544,7 @@ followed by a call to <code>not_nil!</code>.</p>
|
|||
<br/>
|
||||
<div>
|
||||
|
||||
[<a href="https://github.com/crystal-ameba/ameba/blob/3b87aa6/src/ameba/rule/lint/not_nil_after_no_bang.cr#L39" target="_blank">View source</a>]
|
||||
[<a href="https://github.com/crystal-ameba/ameba/blob/52a3e47/src/ameba/rule/lint/not_nil_after_no_bang.cr#L39" target="_blank">View source</a>]
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1560,7 +1560,7 @@ followed by a call to <code>not_nil!</code>.</p>
|
|||
<br/>
|
||||
<div>
|
||||
|
||||
[<a href="https://github.com/crystal-ameba/ameba/blob/3b87aa6/src/ameba/rule/lint/not_nil_after_no_bang.cr#L35" target="_blank">View source</a>]
|
||||
[<a href="https://github.com/crystal-ameba/ameba/blob/52a3e47/src/ameba/rule/lint/not_nil_after_no_bang.cr#L35" target="_blank">View source</a>]
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue