Skip to content

Instantly share code, notes, and snippets.

@pgreze
Created April 6, 2020 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pgreze/7fb5a1074f246b7f2f84d36f7d88f546 to your computer and use it in GitHub Desktop.
Save pgreze/7fb5a1074f246b7f2f84d36f7d88f546 to your computer and use it in GitHub Desktop.
Detekt build/reports/detekt/ examples
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>detekt report</title>
<style>
h2 {
background-color: #666666;
padding: 0.2em;
color: #ffffff;
}
h3 {
background-color:#f8dfdf;
padding:0.5em;
}
.rule {
background-color: #dddddd;
padding: 0.3em;
font-weight: bold;
}
.description {
color:#000000;
padding:0.3em;
}
.location {
color: #690505;
font-family: monospace;
display: block;
}
.message {
font-size: 0.8em;
color: #444444;
display: block;
margin-top: 1pt;
}
.rule-container {
border: 0.1em dashed #dddddd;
padding: 0.1em;
line-height: 1.5em;
margin-bottom: 8px;
margin-top: 8px;
}
pre {
border: 1px solid #e0e0e0;
overflow: scroll;
}
.lineno {
color: #999999;
background-color: #f0f0f0;
}
.error {
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4AwCFR4T/3uLMgAAADxJREFUCNdNyLERQEAABMCjL4lQwIzcjErpguAL+C9AvgKJDbeD/PRpLdm35Hm+MU+cB+tCKaJW4L4YBy+CAiLJrFs9mgAAAABJRU5ErkJggg==) bottom repeat-x;
}
.exception {
color: #b60808;
display: inline-block;
background-color: #ecdada;
border-color: #b60808;
border-radius: 10px;
border: solid 2px;
padding-left: 16px;
padding-right: 16px;
margin-bottom: 16px;
}
</style>
</head>
<body>
<h1>detekt report</h1>
<h2>Metrics</h2>
<div>
<ul>
<li>37 number of kt files</li>
<li>12 number of packages</li>
<li>32 number of classes</li>
<li>76 number of functions</li>
<li>31 number of properties</li>
</ul>
</div>
<h2>Complexity Report</h2>
<div>
<ul>
<li>1,476 lines of code (loc)</li>
<li>1,142 source lines of code (sloc)</li>
<li>751 logical lines of code (lloc)</li>
<li>93 comment lines of code (cloc)</li>
<li>91 McCabe complexity (mcc)</li>
<li>2 number of total code smells</li>
<li>8% comment source ratio</li>
<li>121 mcc per 1,000 lloc</li>
<li>2 code smells per 1,000 lloc</li>
</ul>
</div>
<h2>Findings</h2>
<div>Total: 2
<h3>complexity: 1</h3>
<details id="LongMethod" open="open">
<summary class="rule-container"><span class="rule">LongMethod: 1 </span><span class="description">One method should have one responsibility. Long methods tend to handle many things at once. Prefer smaller methods to make them easier to understand.</span></summary>
<ul>
<li><span class="location">/.....kt:39:5</span><span class="message">The function ItemDetailComposeLayout is too long (131). The maximum length is 60.</span>
<pre><code><span class="lineno"> 36 </span>import com.example.feature.item_detail.R
<span class="lineno"> 37 </span>
<span class="lineno"> 38 </span>@Composable
<span class="lineno"> 39 </span>fun <span class="error">ItemDetailComposeLayout</span>() {
<span class="lineno"> 40 </span> val image = loadImageResource(R.drawable.logo_256x256)
<span class="lineno"> 41 </span> MaterialTheme {
<span class="lineno"> 42 </span> VerticalScroller {
</code></pre>
</li>
</ul>
</details>
<h3>style: 1</h3>
<details id="MaxLineLength" open="open">
<summary class="rule-container"><span class="rule">MaxLineLength: 1 </span><span class="description">Line detected that is longer than the defined maximum line length in the code style.</span></summary>
<ul>
<li><span class="location">/.....gradle.kts:15:44</span><span class="message">Line detected that is longer than the defined maximum line length in the code style.</span>
<pre><code><span class="lineno"> 12 </span>import com.example.utils.kapt
<span class="lineno"> 13 </span>import com.example.utils.kaptAndroidTest
<span class="lineno"> 14 </span>import com.example.utils.release
<span class="lineno"> 15 </span>import com.example.utils.testImplementation<span class="error"></span>
<span class="lineno"> 16 </span><span class="error"></span>
<span class="lineno"> 17 </span><span class="error">//</span>
<span class="lineno"> 18 </span><span class="error">// Common logic for all Android modules.</span>
</code></pre>
</li>
</ul>
</details>
</div>
generated with <a href="https://arturbosch.github.io/detekt">detekt version 1.7.4</a> on 2020-04-06 10:06:10 UTC.
</body>
</html>
LongMethod - 131/60 - [ItemDetailComposeLayout] at /....kt:39:5 - Signature=ItemDetailComposeLayout.kt$ItemDetailComposeLayout
<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
<file name="/Users/....kt">
<error line="39" column="5" severity="warning" message="The function ItemDetailComposeLayout is too long (131). The maximum length is 60." source="detekt.LongMethod" />
</file>
<file name="/....gradle.kts">
<error line="15" column="44" severity="warning" message="Line detected that is longer than the defined maximum line length in the code style." source="detekt.MaxLineLength" />
</file>
</checkstyle>
@pgreze
Copy link
Author

pgreze commented Apr 6, 2020

Preview HTML with https://htmlpreview.github.io/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment