<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Crap on MyVar.dev</title><link>https://gibbok.github.io/myvar/tags/crap/</link><description>Recent content in Crap on MyVar.dev</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Sun, 30 Aug 2026 07:29:36 +0000</lastBuildDate><atom:link href="https://gibbok.github.io/myvar/tags/crap/index.xml" rel="self" type="application/rss+xml"/><item><title>Cyclomatic Complexity and CRAP Metrics Guide</title><link>https://gibbok.github.io/myvar/code-quality-metrics/cyclomatic-complexity-and-crap-metrics-guide/</link><pubDate>Sun, 30 Aug 2026 07:29:36 +0000</pubDate><guid>https://gibbok.github.io/myvar/code-quality-metrics/cyclomatic-complexity-and-crap-metrics-guide/</guid><description>&lt;h2 id="overview"&gt;Overview&lt;/h2&gt;
&lt;p&gt;Cyclomatic Complexity and Change Risk Anti-Patterns (CRAP) are essential software engineering metrics used to evaluate code maintainability, testability, and modification risk. Cyclomatic Complexity measures execution paths within a function, while CRAP combines complexity with code coverage to quantify the risk of introducing defects during changes.&lt;/p&gt;
&lt;h2 id="key-insights"&gt;Key Insights&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Execution Path Tracking:&lt;/strong&gt; &lt;strong&gt;Cyclomatic Complexity&lt;/strong&gt; quantifies the number of independent execution paths in code, directly impacting test effort and readability.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Exponential Risk Penalty:&lt;/strong&gt; The &lt;strong&gt;CRAP score&lt;/strong&gt; heavily penalizes complex logic that lacks automated tests, highlighting high-risk areas in pull requests and code reviews.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dual-Path Remediation:&lt;/strong&gt; High CRAP scores can be lowered either by &lt;strong&gt;reducing code complexity&lt;/strong&gt; through refactoring or by &lt;strong&gt;increasing test coverage&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Target Thresholds:&lt;/strong&gt; Maintain a Cyclomatic Complexity score below &lt;strong&gt;10&lt;/strong&gt; and a CRAP score under &lt;strong&gt;30&lt;/strong&gt; to ensure code stability.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="technical-details"&gt;Technical Details&lt;/h2&gt;
&lt;h3 id="cyclomatic-complexity"&gt;Cyclomatic Complexity&lt;/h3&gt;
&lt;p&gt;Cyclomatic Complexity calculates structural complexity based on control flow branches. Every function starts with a baseline score of 1 and increases by 1 for each conditional branch or iteration construct.&lt;/p&gt;</description></item><item><title>Understanding Change Risk Anti-Patterns CRAP Metric</title><link>https://gibbok.github.io/myvar/crap-metric/understanding-change-risk-anti-patterns-crap-metric/</link><pubDate>Thu, 27 Aug 2026 19:24:11 +0000</pubDate><guid>https://gibbok.github.io/myvar/crap-metric/understanding-change-risk-anti-patterns-crap-metric/</guid><description>&lt;h2 id="overview"&gt;Overview&lt;/h2&gt;
&lt;p&gt;The &lt;strong&gt;Change Risk Anti-Patterns (CRAP)&lt;/strong&gt; metric evaluates the software maintenance risk of a function or method by combining its structural complexity with its automated test coverage. It highlights code where high cyclomatic complexity intersects with insufficient test protection, creating a high probability of regression bugs during modification.&lt;/p&gt;
&lt;h2 id="key-insights"&gt;Key Insights&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Dual-Factor Analysis&lt;/strong&gt;: Combines &lt;strong&gt;cyclomatic complexity&lt;/strong&gt; (independent execution paths) and &lt;strong&gt;test coverage&lt;/strong&gt; into a single actionable risk indicator.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Non-Linear Penalty&lt;/strong&gt;: Exponentially penalizes high complexity (squared) and uncovered code paths (cubed), ensuring complex, untested code generates drastically elevated scores.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Inherent Complexity Floor&lt;/strong&gt;: A function&amp;rsquo;s CRAP score can never drop below its cyclomatic complexity value, even with 100% test coverage.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Actionable Prioritization&lt;/strong&gt;: Helps engineering teams identify where refactoring or writing unit tests provides the highest return on investment.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="technical-details"&gt;Technical Details&lt;/h2&gt;
&lt;h3 id="mathematical-formula"&gt;Mathematical Formula&lt;/h3&gt;
&lt;p&gt;The standard CRAP formula for a method $m$ is expressed as:&lt;/p&gt;</description></item></channel></rss>