<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <id>https://detekt.dev/blog</id>
    <title>Detekt Blog</title>
    <updated>2020-09-27T00:00:00.000Z</updated>
    <generator>https://github.com/jpmonette/feed</generator>
    <link rel="alternate" href="https://detekt.dev/blog"/>
    <subtitle>Detekt Blog</subtitle>
    <icon>https://detekt.dev/img/favicon.svg</icon>
    <entry>
        <title type="html"><![CDATA[Recipe: diff your detekt config with the default one]]></title>
        <id>/2020/09/27/additional-diff-config-task</id>
        <link href="https://detekt.dev/blog/2020/09/27/additional-diff-config-task"/>
        <updated>2020-09-27T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[detekt's ./gradlew detektGenerateConfig task copies the default configuration file to the location]]></summary>
        <content type="html"><![CDATA[<p>detekt's <code>./gradlew detektGenerateConfig</code> task copies the default configuration file to the location
specified by the <code>config</code> property.</p><div class="language-kt codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-kt codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">detekt </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token operator" style="color:#393A34">..</span><span class="token punctuation" style="color:#393A34">.</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  config </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">files</span><span class="token punctuation" style="color:#393A34">(</span><span class="token operator" style="color:#393A34">..</span><span class="token punctuation" style="color:#393A34">.</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token operator" style="color:#393A34">..</span><span class="token punctuation" style="color:#393A34">.</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>When the file on this location already exists, your configuration won't be overwritten, and the task is a noop.</p><p>When we release a new version, some users like to generate the default one to compare changed properties.
This can be done by running the detekt cli with the <code>--generate-config --config [/new/location]</code> flags.
When already using Gradle, we can write a custom task and share this procedure with the team:</p><div class="language-kt codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-kt codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token keyword" style="color:#00009f">import</span><span class="token plain"> io</span><span class="token punctuation" style="color:#393A34">.</span><span class="token plain">gitlab</span><span class="token punctuation" style="color:#393A34">.</span><span class="token plain">arturbosch</span><span class="token punctuation" style="color:#393A34">.</span><span class="token plain">detekt</span><span class="token punctuation" style="color:#393A34">.</span><span class="token plain">DetektGenerateConfigTask</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token keyword" style="color:#00009f">val</span><span class="token plain"> createDetektConfigForDiff </span><span class="token keyword" style="color:#00009f">by</span><span class="token plain"> tasks</span><span class="token punctuation" style="color:#393A34">.</span><span class="token function" style="color:#d73a49">registering</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">DetektGenerateConfigTask</span><span class="token operator" style="color:#393A34">::</span><span class="token keyword" style="color:#00009f">class</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    description </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token string-literal singleline string" style="color:#e3116c">"Generate newest default detekt config"</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    config</span><span class="token punctuation" style="color:#393A34">.</span><span class="token function" style="color:#d73a49">setFrom</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">buildDir</span><span class="token punctuation" style="color:#393A34">.</span><span class="token function" style="color:#d73a49">resolve</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string-literal singleline string" style="color:#e3116c">"detekt-diff.yaml"</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    doFirst </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">      </span><span class="token comment" style="color:#999988;font-style:italic">// optionally delete the old config diff file first </span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>The last step involves calling your favorite diff tool (e.g. <code>diff detekt-diff.yaml my_config.yaml</code>) or using an online service like <code>http://incaseofstairs.com/jsdiff/</code>.</p><p>Likewise we can diff the default config of detekt version X with the default config of detekt version X-1. This will tell us which properties are new in version X.</p>]]></content>
        <category label="guides" term="guides"/>
    </entry>
    <entry>
        <title type="html"><![CDATA[Howto: make detekt silent]]></title>
        <id>/2019/08/14/custom-console-reports</id>
        <link href="https://detekt.dev/blog/2019/08/14/custom-console-reports"/>
        <updated>2019-08-14T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[detekt's reporting mechanism relies on implementations of ConsoleReport's.]]></summary>
        <content type="html"><![CDATA[<p>detekt's reporting mechanism relies on implementations of <a href="/kdoc/detekt-api/io.gitlab.arturbosch.detekt.api/-console-report/index.html">ConsoleReport</a>'s.
The cli module and therefore the Gradle plugin implement a bunch of this reports.</p><p>A typical detekt report will look like following:</p><p><img loading="lazy" alt="report" src="/assets/images/typical_console_report-dac0a808bc92ff7a4b5c82cbcfba0724.png" width="1574" height="798" class="img_ev3q"></p><p>There are many different parts which might or might not interest you.
If one part is not important to you, it can be excluded in the yaml configuration file.
A <strong>silent</strong> configuration would exclude all possible processors and reports:</p><div class="language-yaml codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-yaml codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token key atrule" style="color:#00a4db">processors</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token key atrule" style="color:#00a4db">active</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean important" style="color:#36acaa">true</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token key atrule" style="color:#00a4db">exclude</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'DetektProgressListener'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'FunctionCountProcessor'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'PropertyCountProcessor'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'ClassCountProcessor'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'PackageCountProcessor'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'KtFileCountProcessor'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token key atrule" style="color:#00a4db">console-reports</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token key atrule" style="color:#00a4db">active</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean important" style="color:#36acaa">true</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token key atrule" style="color:#00a4db">exclude</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'ProjectStatisticsReport'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'ComplexityReport'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'NotificationReport'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'FindingsReport'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'BuildFailureReport'</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>Running with this config won't produce any console messages: </p><p><img loading="lazy" alt="report" src="/assets/images/silent_run-ee41325cf336b082776926e1d187e9e6.png" width="1919" height="41" class="img_ev3q"></p><p>Just verify that the <code>./report.txt</code> is not empty ;).</p><p>We might find detekt's <code>FindingsReport</code> too verbose and just want to print one message line per finding.
This can be achieved by implementing a custom <code>ConsoleReport</code>.</p><div class="language-kotlin codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-kotlin codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token keyword" style="color:#00009f">class</span><span class="token plain"> SingleLineFindingsReport </span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">ConsoleReport</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token keyword" style="color:#00009f">override</span><span class="token plain"> </span><span class="token keyword" style="color:#00009f">fun</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">render</span><span class="token punctuation" style="color:#393A34">(</span><span class="token plain">detektion</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> Detektion</span><span class="token punctuation" style="color:#393A34">)</span><span class="token operator" style="color:#393A34">:</span><span class="token plain"> String</span><span class="token operator" style="color:#393A34">?</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">        detektion</span><span class="token punctuation" style="color:#393A34">.</span><span class="token plain">findings</span><span class="token punctuation" style="color:#393A34">.</span><span class="token plain">values</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">            </span><span class="token punctuation" style="color:#393A34">.</span><span class="token function" style="color:#d73a49">flatten</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">            </span><span class="token punctuation" style="color:#393A34">.</span><span class="token function" style="color:#d73a49">joinToString</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string-literal singleline string" style="color:#e3116c">"\n"</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"> </span><span class="token string-literal singleline string" style="color:#e3116c">"</span><span class="token string-literal singleline interpolation interpolation-punctuation punctuation" style="color:#393A34">${</span><span class="token string-literal singleline interpolation expression">it</span><span class="token string-literal singleline interpolation expression punctuation" style="color:#393A34">.</span><span class="token string-literal singleline interpolation expression">id</span><span class="token string-literal singleline interpolation interpolation-punctuation punctuation" style="color:#393A34">}</span><span class="token string-literal singleline string" style="color:#e3116c"> - </span><span class="token string-literal singleline interpolation interpolation-punctuation punctuation" style="color:#393A34">${</span><span class="token string-literal singleline interpolation expression">it</span><span class="token string-literal singleline interpolation expression punctuation" style="color:#393A34">.</span><span class="token string-literal singleline interpolation expression">message</span><span class="token string-literal singleline interpolation interpolation-punctuation punctuation" style="color:#393A34">}</span><span class="token string-literal singleline string" style="color:#e3116c"> - </span><span class="token string-literal singleline interpolation interpolation-punctuation punctuation" style="color:#393A34">${</span><span class="token string-literal singleline interpolation expression">it</span><span class="token string-literal singleline interpolation expression punctuation" style="color:#393A34">.</span><span class="token string-literal singleline interpolation expression">entity</span><span class="token string-literal singleline interpolation expression punctuation" style="color:#393A34">.</span><span class="token string-literal singleline interpolation expression">location</span><span class="token string-literal singleline interpolation expression punctuation" style="color:#393A34">.</span><span class="token string-literal singleline interpolation expression">file</span><span class="token string-literal singleline interpolation interpolation-punctuation punctuation" style="color:#393A34">}</span><span class="token string-literal singleline string" style="color:#e3116c">"</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>Combined with our silent configuration only messages are printed when findings are actually found:</p><p><img loading="lazy" alt="report" src="/assets/images/compact_report-00d1098a4ed023bc29252a07cbdcbecc.png" width="1916" height="222" class="img_ev3q"></p><p>See the <a href="/docs/introduction/extensions">extension</a> documention on how to let detekt know about your custom report.</p>]]></content>
        <category label="guides" term="guides"/>
    </entry>
    <entry>
        <title type="html"><![CDATA[Calling it One Zero]]></title>
        <id>/2019/08/04/calling-it-one-zero</id>
        <link href="https://detekt.dev/blog/2019/08/04/calling-it-one-zero"/>
        <updated>2019-08-04T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Today we are announcing the 1.0 release of detekt, a static code analysis tool for Kotlin.]]></summary>
        <content type="html"><![CDATA[<p>Today we are announcing the <strong>1.0</strong> release of detekt, a static code analysis tool for Kotlin.
It operates on the abstract syntax tree provided by the Kotlin compiler and finds common
programming flaws like unused or too complex constructs. Think of it as <em>pmd</em> or <em>checkstyle</em> but for Kotlin.</p><p><strong>1.0</strong> offers the following features:</p><ul><li>Code smell analysis for your Kotlin projects</li><li>Complexity reports based on lines of code, cyclomatic complexity and amount of code smells</li><li>Highly configurable rule sets</li><li>Suppression of findings with Kotlin's <code>@Suppress</code> and Java's <code>@SuppressWarnings</code> annotations</li><li>Specification of quality gates which will break your build </li><li>Code Smell baseline for legacy projects</li><li><a href="#with-gradle">Gradle plugin</a> for code analysis via Gradle builds</li><li>Gradle tasks to use local <code>IntelliJ</code> distribution for formatting and inspecting Kotlin code</li><li><a href="https://github.com/arturbosch/sonar-kotlin" target="_blank" rel="noopener noreferrer">SonarQube integration</a></li><li>Extensibility by enabling incorporation of personal rule sets, <code>FileProcessListener's</code> and <code>OutputReport's</code></li><li><a href="https://github.com/detekt/detekt-intellij-plugin" target="_blank" rel="noopener noreferrer">IntelliJ integration</a></li><li>Unofficial <a href="https://github.com/Ozsie/detekt-maven-plugin" target="_blank" rel="noopener noreferrer">Maven plugin</a> by <a href="https://github.com/Ozsie" target="_blank" rel="noopener noreferrer">Ozsie</a></li></ul><p>Here are some metrics describing detekt's lifespan so far:</p><p><img loading="lazy" alt="lifespan" src="/assets/images/1-lifespan-b89210c1bdb421987179e6da2646ff37.png" width="816" height="323" class="img_ev3q"></p><p>detekt is almost <strong>3</strong> years old already!<br>
<!-- -->As GitHub tells us the project is pretty active.<br>
<!-- -->You may argue that in 2018 it was more active looking at the number of commits, however that year
we also changed our merge strategy from merge-with-rebase to squash-and-merge.
That said, it is much harder to achieve these high commit numbers now ;).</p><p><img loading="lazy" alt="numbers" src="data:image/png;base64,[encoded data, 12136 characters]" width="1082" height="76" class="img_ev3q"></p><p>There are <strong>2516</strong> commits, <strong>52</strong> releases on GitHub and a total <strong>93</strong> contributors at the time of writing.
<strong>20</strong> out of the 93 authors contributed once or more in the last three months.</p><p><img loading="lazy" alt="numbers" src="/assets/images/3-bintray-absolute-924adc575a374ccf834da3e88b3fc7ec.png" width="1160" height="516" class="img_ev3q"></p><p><strong>~780k</strong> downloads in the last <strong>30 days</strong> is a pretty high number... three months ago it was around <strong>500k</strong>.
Weekends clearly stand out. That's when the CI has to rest ;).</p><p>This does however not mean one download equals one user. There are like eight detekt modules each with a jar and pom which needs to be downloaded.
As most of the downloads are bound to be CI, it is hard to calculate the actual number of detekt users.</p><p><img loading="lazy" alt="numbers" src="/assets/images/4-bintray-percent-46d42d5abfba0157bd16dc6f6077e3c0.png" width="1151" height="533" class="img_ev3q"></p><p>What I also noticed is the high number of "early adopters" in the Kotlin world (or just detekt).</p><ul><li>RC09 was released in Sep 2018</li><li>RC10 was released in Nov 2018</li><li>RC11 was released in Nov 2018</li><li>RC12 was released in Dec 2018</li><li>RC14 was released in Feb 2019</li><li>RC15 was released in Jun 2019</li><li>RC16 was released in Jun 2019</li></ul><p><strong>65%</strong> of users are on a version published in 2019. But we clearly lost some users in the older versions due to breaking changes in RC13 and RC15.
We are excited to see how many users will jump on the 1.x.x release train and how these numbers will look like.</p><p>Last but not least here is a worldmap of where detekt users are coming from.</p><p><img loading="lazy" alt="numbers" src="/assets/images/5-bintray-world-b0ef653e07203593d6fec23013825ec8.png" width="1166" height="644" class="img_ev3q"></p><p>References:</p><ul><li><a href="https://bintray.com/arturbosch/code-analysis/detekt#statistics" target="_blank" rel="noopener noreferrer">https://bintray.com/arturbosch/code-analysis/detekt#statistics</a></li><li><a href="https://github.com/detekt/detekt/graphs/contributors" target="_blank" rel="noopener noreferrer">https://github.com/detekt/detekt/graphs/contributors</a></li></ul>]]></content>
        <category label="news" term="news"/>
    </entry>
    <entry>
        <title type="html"><![CDATA[Howto: using snapshot releases of detekt]]></title>
        <id>/2019/06/29/using-detekt-snapshots</id>
        <link href="https://detekt.dev/blog/2019/06/29/using-detekt-snapshots"/>
        <updated>2019-06-29T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[detekt uses bintray for releases and artifactory for snapshots.]]></summary>
        <content type="html"><![CDATA[<p>detekt uses <a href="https://bintray.com/arturbosch/code-analysis/detekt" target="_blank" rel="noopener noreferrer">bintray</a> for releases and <a href="https://oss.jfrog.org/artifactory/webapp/#/artifacts/browse/tree/General/oss-snapshot-local/io/gitlab/arturbosch/detekt/detekt-cli/" target="_blank" rel="noopener noreferrer">artifactory</a> for snapshots.
To configure snapshot usage in your gradle plugin apply the following changes to your build file:</p><div class="language-kotlin codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-kotlin codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">detekt </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token comment" style="color:#999988;font-style:italic">// if a new release of detekt stays binary compatible with a previous</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token comment" style="color:#999988;font-style:italic">// release, just change the 'toolVersion'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    toolVersion </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token string-literal singleline string" style="color:#e3116c">"1.0.0-RC16-20190629.171442-3"</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    config </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">files</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string-literal singleline string" style="color:#e3116c">"</span><span class="token string-literal singleline interpolation interpolation-punctuation punctuation" style="color:#393A34">$</span><span class="token string-literal singleline interpolation expression">projectDir</span><span class="token string-literal singleline string" style="color:#e3116c">/detekt/config.yml"</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    baseline </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">file</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string-literal singleline string" style="color:#e3116c">"</span><span class="token string-literal singleline interpolation interpolation-punctuation punctuation" style="color:#393A34">$</span><span class="token string-literal singleline interpolation expression">projectDir</span><span class="token string-literal singleline string" style="color:#e3116c">/baseline.xml"</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    reports </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">        html </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">            enabled </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token boolean" style="color:#36acaa">true</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">            destination </span><span class="token operator" style="color:#393A34">=</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">file</span><span class="token punctuation" style="color:#393A34">(</span><span class="token string-literal singleline string" style="color:#e3116c">"</span><span class="token string-literal singleline interpolation interpolation-punctuation punctuation" style="color:#393A34">$</span><span class="token string-literal singleline interpolation expression">rootDir</span><span class="token string-literal singleline string" style="color:#e3116c">/detekt.html"</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">        </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic">// this changes may be necessary if detekt's core modules like 'cli, core, api or rules'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token comment" style="color:#999988;font-style:italic">// change in a way that is not binary compatible to older releases</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">dependencies </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token comment" style="color:#999988;font-style:italic">// use the detekt configuration for only official detekt modules</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    detekt </span><span class="token string-literal singleline string" style="color:#e3116c">"io.gitlab.arturbosch.detekt:detekt-cli:1.0.0-RC16-20190629.171442-3"</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    detekt </span><span class="token string-literal singleline string" style="color:#e3116c">"io.gitlab.arturbosch.detekt:detekt-core:1.0.0-RC16-20190629.171442-3"</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    detekt </span><span class="token string-literal singleline string" style="color:#e3116c">"io.gitlab.arturbosch.detekt:detekt-api:1.0.0-RC16-20190629.171442-3"</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token operator" style="color:#393A34">..</span><span class="token punctuation" style="color:#393A34">.</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token comment" style="color:#999988;font-style:italic">// use detektPlugins for detekt plugins - custom or official like the formatting one</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    detektPlugins </span><span class="token string-literal singleline string" style="color:#e3116c">"io.gitlab.arturbosch.detekt:detekt-formatting:1.0.0-RC16-20190629.171442-3"</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>]]></content>
        <category label="guides" term="guides"/>
    </entry>
    <entry>
        <title type="html"><![CDATA[Howto: migrating from the *test-pattern*]]></title>
        <id>/2019/06/08/migrating-the-test-pattern</id>
        <link href="https://detekt.dev/blog/2019/06/08/migrating-the-test-pattern"/>
        <updated>2019-06-08T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[Starting with RC15 the test-pattern is obsolete. This post shows how to leverage rule path excludes to achieve the same functionality.]]></summary>
        <content type="html"><![CDATA[<p>Starting with RC15 the test-pattern is obsolete. This post shows how to leverage rule path excludes to achieve the same functionality.</p><p>With version &lt; RC15 the configuration file allowed to specify
which paths should be mapped to test files so detekt would not run
specific rule sets and rules on these test files:</p><div class="language-yaml codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-yaml codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token key atrule" style="color:#00a4db">test-pattern</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic"># Configure exclusions for test sources</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token key atrule" style="color:#00a4db">active</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"> </span><span class="token boolean important" style="color:#36acaa">true</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token key atrule" style="color:#00a4db">patterns</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"> </span><span class="token comment" style="color:#999988;font-style:italic"># Test file regexes</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'.*/test/.*'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'.*Test.kt'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'.*Spec.kt'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token key atrule" style="color:#00a4db">exclude-rule-sets</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'comments'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  </span><span class="token key atrule" style="color:#00a4db">exclude-rules</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'NamingRules'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'WildcardImport'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'MagicNumber'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'MaxLineLength'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'LateinitUsage'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'StringLiteralDuplication'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'SpreadOperator'</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'TooManyFunctions'</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>This was an okay approach as we nowadays separate production code and test code.
However more different kinds of source files can be identified.
For example generated and library code.</p><p>With the new approach of offering path patterns on the rule and rule set level the user has much more freedom
in defining which rule should run on which path.</p><p>If we do not care about documented test classes because we write our test code
in a <em>documenting way</em>, we could simply exclude the <code>comments</code> rule set for following patterns:</p><div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">comments:</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  ...</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  excludes: "**/*Test.kt, **/*Spec.kt"</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>If we for example do not care about <code>MagicNumber</code>'s in test code, we can
exclude our test files for this rule:</p><div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">style:</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  ...</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  MagicNumber:</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    excludes: "**/*Test.kt, **/*Spec.kt"</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>Make sure to use globing patterns here as detekt does not support regular expressions anymore.
This change was done to make use of the <code>java.nio.file</code> library when handling os-specific paths.</p><p>If you were using the default detekt configuration with the default test-pattern,
you will not notice any changes when upgrading to &gt;= RC15.
All <em>exclude-rules</em> and <em>exclude-rule-sets</em> will now make use of <code>excludes: "**/test/**,**/*Test.kt,**/*Spec.kt"</code>.</p>]]></content>
        <category label="guides" term="guides"/>
    </entry>
    <entry>
        <title type="html"><![CDATA[Howto: build upon the default yaml config file]]></title>
        <id>/2019/03/03/build-upon-the-default-config</id>
        <link href="https://detekt.dev/blog/2019/03/03/build-upon-the-default-config"/>
        <updated>2019-03-03T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[A common use case of detekt users was to build upon the default config file and use a second config file to override]]></summary>
        <content type="html"><![CDATA[<p>A common use case of <em>detekt</em> users was to build upon the default config file and use a second config file to override
some defaults.
Speaking in <em>Gradle</em> terms, this could look like following:</p><div class="language-gradle codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-gradle codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">detekt {</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    ...</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    config = files(</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">            project.rootDir.resolve("config/default-detekt-config.yml"),</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">            project.rootDir.resolve("config/our.yml")</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    )</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    baseline = project.rootDir.resolve("config/baseline.xml")</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    ...</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>Starting from RC13, two new commandline flags got introduced:</p><ul><li><code>--fail-fast</code></li><li>and <code>--build-upon-default-config</code></li><li>(<code>buildUponDefaultConfig</code> and <code>failFast</code> properties for gradle setup)</li></ul><p>Both options allow us to use the distributed <code>default-detekt-config.yml</code> as the backup configuration when
no rule configuration is found in the specified configuration (<code>--config</code> or <code>config = ...</code>).<br>
<!-- -->This allows us to simplify our detekt setup without copy-pasting a huge config file:</p><div class="language-gradle codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-gradle codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">detekt {</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    ...</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    buildUponDefaultConfig = true</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    config = files(project.rootDir.resolve("config/our.yml"))</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    baseline = project.rootDir.resolve("config/baseline.xml")</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    ...</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>{% include links.html %}</p>]]></content>
        <category label="guides" term="guides"/>
    </entry>
    <entry>
        <title type="html"><![CDATA[Howto: configure detekt for gradle root project]]></title>
        <id>/2019/03/03/configure-detekt-on-root-project</id>
        <link href="https://detekt.dev/blog/2019/03/03/configure-detekt-on-root-project"/>
        <updated>2019-03-03T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[When configuring detekt for your Gradle based project, you basically have two options:]]></summary>
        <content type="html"><![CDATA[<p>When configuring <em>detekt</em> for your <em>Gradle</em> based project, you basically have two options:</p><ul><li>for each sub module a new gradle task should be created</li><li>or one <strong>uber</strong>-task analyzes your whole project</li></ul><p>For the first option, please see how <a href="https://github.com/detekt/detekt" target="_blank" rel="noopener noreferrer">detekt</a> itself creates a task for each module:</p><div class="language-gradle codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-gradle codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">subprojecs {</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">...</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    detekt {</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">        debug = true</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">        toolVersion = usedDetektVersion</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">        buildUponDefaultConfig = true</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">        config = files(project.rootDir.resolve("reports/failfast.yml"))</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">        baseline = project.rootDir.resolve("reports/baseline.xml")</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">        reports {</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">            xml.enabled = true</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">            html.enabled = true</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">        }</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    }</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>Sometimes it makes sense to add an additional <em>detekt</em> task which runs over the whole project and produces one big report.
Such a setup could look like the following in its simplest form:</p><div class="language-gradle codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-gradle codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">plugins {</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    id "io.gitlab.arturbosch.detekt" version "1.0.0-RC14"</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">}</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">repositories {</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    jcenter()</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">}</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">detekt {</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    source = files(rootProject.rootDir)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    buildUponDefaultConfig = true</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>Make sure to specify the <code>input</code> parameter or no sources are found and <em>detekt</em> won't run!</p><p>If you need more fine grained <em>detekt</em> tasks, you could register more tasks using the <em>Detekt</em> task as the base task.
Using the <em>Kotlin-Dsl</em> it could look like this:</p><div class="language-gradle codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-gradle codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">val detektAll by tasks.registering(Detekt::class) {</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    description = "Runs over whole code base without the starting overhead for each module."</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    parallel = true</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    buildUponDefaultConfig = true</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    setSource(files(projectDir))</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    config = files(project.rootDir.resolve("reports/failfast.yml"))</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    include("**/*.kt")</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    include("**/*.kts")</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    exclude("resources/")</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    exclude("build/")</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    baseline.set(project.rootDir.resolve("reports/baseline.xml"))</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    reports {</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">        xml.enabled = false</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">        html.enabled = false</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    }</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>{% include links.html %}</p>]]></content>
        <category label="guides" term="guides"/>
    </entry>
    <entry>
        <title type="html"><![CDATA[Website Online]]></title>
        <id>/2018/02/11/website-online</id>
        <link href="https://detekt.dev/blog/2018/02/11/website-online"/>
        <updated>2018-02-11T00:00:00.000Z</updated>
        <summary type="html"><![CDATA[As of today the website was launched!]]></summary>
        <content type="html"><![CDATA[<p>As of today the website was launched!</p><p>{% include links.html %}</p>]]></content>
        <category label="news" term="news"/>
    </entry>
</feed>