<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Kotlin on afanasev.net</title><link>https://afanasev.net/categories/kotlin/</link><description>Recent content in Kotlin on afanasev.net</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Fri, 10 Apr 2020 16:26:00 +0700</lastBuildDate><atom:link href="https://afanasev.net/categories/kotlin/feed.xml" rel="self" type="application/rss+xml"/><item><title>Filter out classes from JaCoCo report using annotaitons</title><link>https://afanasev.net/kotlin/jacoco/2020/04/10/jacoco-ignore-annotation.html</link><pubDate>Fri, 10 Apr 2020 16:26:00 +0700</pubDate><guid>https://afanasev.net/kotlin/jacoco/2020/04/10/jacoco-ignore-annotation.html</guid><description>&lt;p&gt;&lt;img alt="JaCoCo code coverage report with Generated annotation" loading="lazy" src="https://afanasev.net/assets/img/jacoco-code-coverage.png"&gt;&lt;/p&gt;
&lt;h2 id="story"&gt;Story&lt;/h2&gt;
&lt;p&gt;Engineering culture at scale is difficult to build and even harder to maintain. In our company, we made a deliberate decision to enforce code coverage as a merge requirement — a hard gate on the CI pipeline that prevented branches from being merged unless they met a minimum threshold. We chose 80%: every new or modified class had to be covered by unit tests to at least that level.&lt;/p&gt;</description></item><item><title>Exclude properties from toString() of Kotlin data class (Sekret appx.)</title><link>https://afanasev.net/kotlin/data-class/2019/08/13/kotlin-data-class-tostirng-hide.html</link><pubDate>Tue, 13 Aug 2019 15:00:00 +0700</pubDate><guid>https://afanasev.net/kotlin/data-class/2019/08/13/kotlin-data-class-tostirng-hide.html</guid><description>&lt;p&gt;&lt;em&gt;This post describes how to remove class properties from the &lt;code&gt;toString()&lt;/code&gt; method manually if you prefer not to use the &lt;a href="https://afanasev.net/kotlin-library/2019/08/13/sekret.html"&gt;Sekret&lt;/a&gt; compiler plugin.&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Kotlin&amp;rsquo;s data class &lt;code&gt;toString&lt;/code&gt; is generated automatically to include every property defined in the primary constructor. This is convenient for debugging but problematic when some of those properties contain sensitive data — passwords, tokens, PII — that must not appear in logs, crash reports, or analytics pipelines.&lt;/p&gt;
&lt;p&gt;There is no built-in Kotlin mechanism to exclude a specific field from the generated &lt;code&gt;toString&lt;/code&gt; while keeping it in &lt;code&gt;equals&lt;/code&gt;, &lt;code&gt;hashCode&lt;/code&gt;, and &lt;code&gt;copy&lt;/code&gt;. The language does not (yet) offer an annotation equivalent to &lt;code&gt;@Transient&lt;/code&gt; for serialization. The approaches below represent the practical trade-offs available in pure Kotlin, each with distinct implications for class semantics, mutability, and maintainability.&lt;/p&gt;</description></item></channel></rss>