<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Code Smell - TheCodeBuzz</title>
	<atom:link href="https://thecodebuzz.com/category/code-smell/feed/" rel="self" type="application/rss+xml" />
	<link>https://thecodebuzz.com</link>
	<description>Best Practices for Software Development</description>
	<lastBuildDate>Sat, 09 Mar 2024 22:41:12 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://thecodebuzz.com/wp-content/uploads/2022/11/cropped-android-chrome-512x512-1-1-51x51.jpg</url>
	<title>Code Smell - TheCodeBuzz</title>
	<link>https://thecodebuzz.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to use Visual Studio IntelliCode &#8211;  Code Development using AI</title>
		<link>https://thecodebuzz.com/visual-studio-intellicode-code-development-using-ai/</link>
					<comments>https://thecodebuzz.com/visual-studio-intellicode-code-development-using-ai/#comments</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 01 Mar 2022 00:00:00 +0000</pubDate>
				<category><![CDATA[Code Smell]]></category>
		<category><![CDATA[activating intellicode support for java in visual studio code]]></category>
		<category><![CDATA[AI in Visual Studio]]></category>
		<category><![CDATA[how to use intellicode visual studio]]></category>
		<category><![CDATA[intellicode api usage examples]]></category>
		<category><![CDATA[Intellicode step by step]]></category>
		<category><![CDATA[intellicode vs intellisense]]></category>
		<category><![CDATA[Intellisense in Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2019]]></category>
		<category><![CDATA[visual studio 2022 intellicode]]></category>
		<category><![CDATA[visual studio ai-assisted intellicode]]></category>
		<category><![CDATA[Visual Studio IntelliCode]]></category>
		<category><![CDATA[Visual Studio IntelliCode - Code Development using AI]]></category>
		<category><![CDATA[visual studio intellicode extension]]></category>
		<category><![CDATA[visual studio intellisense]]></category>
		<category><![CDATA[visual studio intellisense not working]]></category>
		<category><![CDATA[VS Intellicode]]></category>
		<guid isPermaLink="false">https://thecodebuzz.com/?p=1823</guid>

					<description><![CDATA[<p>How to use Visual Studio IntelliCode &#8211; Code Development using AI Visual Studio IntelliCode is a tool helping in code development and analysis of code using Artificial intelligence. This tool provides contextual recommendations for code completion as you type your code. As per Microsoft, these contextual recommendations are provided based on best practices that are [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/visual-studio-intellicode-code-development-using-ai/">How to use Visual Studio IntelliCode –  Code Development using AI</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading">How to use Visual Studio IntelliCode &#8211;  Code Development using AI</h1>



<figure class="wp-block-image is-resized"><a href="https://www.thecodebuzz.com/visual-studio-intellicode-code-development-using-ai/" target="_blank" rel="noopener"><img fetchpriority="high" decoding="async" width="1139" height="837" src="https://i2.wp.com/thecodebuzz.com/wp-content/uploads/2019/03/VisualStudio-Intellicode-VS2017-VSCode-1.jpg?fit=785%2C576&amp;ssl=1" alt="Visual Studio IntelliCode - Productive Code Development using AI" class="wp-image-1848" style="width:539px;height:432px" srcset="https://thecodebuzz.com/wp-content/uploads/2019/03/VisualStudio-Intellicode-VS2017-VSCode-1.jpg 1139w, https://thecodebuzz.com/wp-content/uploads/2019/03/VisualStudio-Intellicode-VS2017-VSCode-1-300x220.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/03/VisualStudio-Intellicode-VS2017-VSCode-1-1024x752.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/03/VisualStudio-Intellicode-VS2017-VSCode-1-768x564.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/03/VisualStudio-Intellicode-VS2017-VSCode-1-708x520.jpg 708w" sizes="(max-width: 1139px) 100vw, 1139px" /></a></figure>



<p>Visual Studio IntelliCode is a tool helping in code development and analysis of code using Artificial intelligence. </p>



<p>This tool provides contextual recommendations for code completion as you type your code. </p>



<p></p>



<p>As per Microsoft, these contextual recommendations are provided based on best practices that are developed using AI by verifying thousands of high-quality, open-source projects on GitHub plus these tools also help to analyze your codebase and train itself to provide a project-specific recommendation. </p>



<p></p>



<p> This tool is currently available through Visual Studio Marketplace as an extension. This is one of the good to have an extension on the developer&#8217;s machine. </p>



<p>Today in this article, we will cover below aspects,</p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-main-features">Main Features</a></li><li><a href="#aioseo-language-support">Language Support</a></li><li><a href="#aioseo-getting-started">Getting Started</a><ul><li><a href="#aioseo-prerequisites">Prerequisites :</a></li></ul></li><li><a href="#aioseo-steps-for-configuring-visual-studio-intellicode">Steps for configuring Visual Studio IntelliCode</a></li></ul></div>



<h3 class="wp-block-heading" id="aioseo-main-features"><strong>Main Features</strong></h3>



<p></p>



<ul class="wp-block-list">
<li>Improve developer productivity using AI.</li>



<li>Help following the code and style patterns. Patterns get created from your code base itself.</li>



<li>All suggestions are provided using the existing code context.</li>



<li>Code review support by highlighting the code changes which require more attention. </li>



<li>AI-assisted  IntelliSense context-aware code completions, signature tool-tips, and help instead of traditional IntelliSense support. </li>
</ul>



<p></p>



<h3 class="wp-block-heading" id="aioseo-language-support"><strong>Language Support</strong></h3>



<ul class="wp-block-list">
<li><strong>Visual Studio:</strong> C#, C++, and XAML</li>



<li><strong>Visual Studio Code:</strong> Java, JavaScript, Python, and TypeScript</li>
</ul>



<p></p>



<h3 class="wp-block-heading" id="aioseo-getting-started"><strong>Getting Started</strong></h3>



<p></p>



<h4 class="wp-block-heading" id="aioseo-prerequisites">Prerequisites :</h4>



<ul class="wp-block-list">
<li>Latest version of <strong>VS2017 </strong>(15.8 and above)</li>



<li>Latest version of <strong>VSCode</strong>(1.29.1 and above)</li>
</ul>



<p></p>



<h3 class="wp-block-heading" id="aioseo-steps-for-configuring-visual-studio-intellicode">Steps for configuring Visual Studio IntelliCode</h3>



<p></p>



<ul class="wp-block-list">
<li>Install <strong>Intellicode</strong> from Marketplace or from VS Extension as below,</li>
</ul>



<p>Marketplace:<em> https://visualstudio.microsoft.com/services/intellicode/</em></p>



<p> </p>



<p><strong><em>VS Tools extension: </em></strong></p>



<p></p>



<p></p>



<figure class="wp-block-image"><a href="https://www.thecodebuzz.com/visual-studio-intellicode-code-development-using-ai/" target="_blank" rel="noopener"><img decoding="async" width="2119" height="356" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-tools-install.jpg?fit=785%2C132&amp;ssl=1" alt="" class="wp-image-1825" srcset="https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-tools-install.jpg 2119w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-tools-install-300x50.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-tools-install-1024x172.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-tools-install-768x129.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-tools-install-1536x258.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-tools-install-2048x344.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-tools-install-785x132.jpg 785w" sizes="(max-width: 2119px) 100vw, 2119px" /></a></figure>



<ul class="wp-block-list">
<li>The first-time installation requires you to restart Visual Studio 2017 to process installation.</li>
</ul>



<figure class="wp-block-image is-resized"><img decoding="async" width="1105" height="924" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/03/Intellicode_Preview.jpg?fit=785%2C656&amp;ssl=1" alt="" class="wp-image-1827" style="width:393px;height:328px" srcset="https://thecodebuzz.com/wp-content/uploads/2019/03/Intellicode_Preview.jpg 1105w, https://thecodebuzz.com/wp-content/uploads/2019/03/Intellicode_Preview-300x251.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/03/Intellicode_Preview-1024x856.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/03/Intellicode_Preview-768x642.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/03/Intellicode_Preview-622x520.jpg 622w" sizes="(max-width: 1105px) 100vw, 1105px" /></figure>



<p></p>



<ul class="wp-block-list">
<li>After successful installation lets open your project solution.Got to View-&gt;Other Windows-&gt;Intellicode  </li>
</ul>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="2266" height="924" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-menu-access.jpg?fit=785%2C320&amp;ssl=1" alt="Visual Studio IntelliCode " class="wp-image-1828" srcset="https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-menu-access.jpg 2266w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-menu-access-300x122.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-menu-access-1024x418.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-menu-access-768x313.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-menu-access-1536x626.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-menu-access-2048x835.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-menu-access-785x320.jpg 785w" sizes="auto, (max-width: 2266px) 100vw, 2266px" /></figure>



<ul class="wp-block-list">
<li>Click on Train my code</li>
</ul>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1752" height="750" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-trainmodel-pattern.jpg?fit=785%2C336&amp;ssl=1" alt="Visual Studio IntelliCode AI" class="wp-image-1831" srcset="https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-trainmodel-pattern.jpg 1752w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-trainmodel-pattern-300x128.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-trainmodel-pattern-1024x438.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-trainmodel-pattern-768x329.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-trainmodel-pattern-1536x658.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-trainmodel-pattern-785x336.jpg 785w" sizes="auto, (max-width: 1752px) 100vw, 1752px" /></figure>



<ul class="wp-block-list">
<li>After training of model completes status will be updated as complete.</li>
</ul>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="2337" height="924" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-learning-pattern-1.jpg?fit=785%2C310&amp;ssl=1" alt="" class="wp-image-1832" srcset="https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-learning-pattern-1.jpg 2337w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-learning-pattern-1-300x119.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-learning-pattern-1-1024x405.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-learning-pattern-1-768x304.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-learning-pattern-1-1536x607.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-learning-pattern-1-2048x810.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-learning-pattern-1-785x310.jpg 785w" sizes="auto, (max-width: 2337px) 100vw, 2337px" /></figure>



<p>Lets see the result of code recommendation before Intellicode and after Intellicode as shown below,</p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" width="1140" height="594" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/03/image-11.png?fit=785%2C409&amp;ssl=1" alt="" class="wp-image-1853" style="width:393px;height:205px" srcset="https://thecodebuzz.com/wp-content/uploads/2019/03/image-11.png 1140w, https://thecodebuzz.com/wp-content/uploads/2019/03/image-11-300x156.png 300w, https://thecodebuzz.com/wp-content/uploads/2019/03/image-11-1024x534.png 1024w, https://thecodebuzz.com/wp-content/uploads/2019/03/image-11-768x400.png 768w, https://thecodebuzz.com/wp-content/uploads/2019/03/image-11-785x409.png 785w" sizes="auto, (max-width: 1140px) 100vw, 1140px" /></figure>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="2560" height="914" src="https://www.thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-suggestionwithout-and-with-Intellicode.jpg" alt="" class="wp-image-1833" srcset="https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-suggestionwithout-and-with-Intellicode.jpg 2560w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-suggestionwithout-and-with-Intellicode-300x107.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-suggestionwithout-and-with-Intellicode-1024x366.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-suggestionwithout-and-with-Intellicode-768x274.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-suggestionwithout-and-with-Intellicode-1536x548.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-suggestionwithout-and-with-Intellicode-2048x731.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-suggestionwithout-and-with-Intellicode-785x280.jpg 785w" sizes="auto, (max-width: 2560px) 100vw, 2560px" /></figure>



<p>As shown above, your  IntelliSense support now uses more common sense using AI model and provide you specific code completion recommendation.</p>



<p>If you are interested to see generated model on your desktop Open file location  <em>%TEMP%\Visual Studio IntelliCode </em></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1752" height="337" src="https://i2.wp.com/thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-pattern-location-on-desktop.jpg?fit=785%2C151&amp;ssl=1" alt="" class="wp-image-1834" srcset="https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-pattern-location-on-desktop.jpg 1752w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-pattern-location-on-desktop-300x58.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-pattern-location-on-desktop-1024x197.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-pattern-location-on-desktop-768x148.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-pattern-location-on-desktop-1536x295.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/03/Visual-Studio-Intellicode-pattern-location-on-desktop-785x151.jpg 785w" sizes="auto, (max-width: 1752px) 100vw, 1752px" /></figure>



<p>The above folder contains the model (not the code) data that is sent to Microsoft over HTTPS. </p>



<p></p>



<p><strong><em>Useful References</em></strong></p>



<p></p>



<ul class="wp-block-list">
<li><a href="https://www.thecodebuzz.com/visual-studio-live-share-getting-started/" target="_blank" rel="noreferrer noopener" title="Paired Programming and Collaboration – Visual Studio Live Share"><strong><em>Paired Programming and Collaboration – Visual Studio Live Share</em></strong></a></li>
</ul>



<p></p>



<p>That&#8217;s all! Happy coding!</p>



<p></p>



<p>Does this help you fix your issue? </p>



<p></p>



<p>Do you have any better solutions or suggestions? Please sound off your comments below.</p>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p>



<p></p>



<p></p>



<p></p>



<p> </p><p>The post <a href="https://thecodebuzz.com/visual-studio-intellicode-code-development-using-ai/">How to use Visual Studio IntelliCode –  Code Development using AI</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/visual-studio-intellicode-code-development-using-ai/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Awesome code &#8211; Primitive Obsession Code Smell Resolution with example</title>
		<link>https://thecodebuzz.com/awesome-code-primitive-obsession-code-smell-with-example/</link>
					<comments>https://thecodebuzz.com/awesome-code-primitive-obsession-code-smell-with-example/#comments</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 01 Mar 2022 00:00:00 +0000</pubDate>
				<category><![CDATA[Code Smell]]></category>
		<category><![CDATA[Code smell]]></category>
		<category><![CDATA[code smells]]></category>
		<category><![CDATA[data clumps code smell example]]></category>
		<category><![CDATA[divergent change code smell]]></category>
		<category><![CDATA[long parameter list code smell]]></category>
		<category><![CDATA[primitive obsession]]></category>
		<category><![CDATA[primitive obsession adalah]]></category>
		<category><![CDATA[primitive obsession c#]]></category>
		<category><![CDATA[Primitive Obsession Code Smell Resolution with example]]></category>
		<category><![CDATA[Replace Type Code with Class]]></category>
		<category><![CDATA[Replace Type Code with Subclassesprimitive obsession java]]></category>
		<guid isPermaLink="false">https://thecodebuzz.com/?p=1994</guid>

					<description><![CDATA[<p>Today in this article, we will cover Primitive Obsession Code Smell Resolution with an example. We will cover below aspects, &#8220;Code is read more often than it is written&#8221; &#8220;Code is maintained more often than it is written&#8221; A few examples of C# primitives are as below, We understand that classes are just dumb templates [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/awesome-code-primitive-obsession-code-smell-with-example/">Awesome code – Primitive Obsession Code Smell Resolution with example</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" width="1307" height="549" src="https://i2.wp.com/thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-recipe.jpg?fit=785%2C330&amp;ssl=1" alt="c# primitive obsession" class="wp-image-2034" srcset="https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-recipe.jpg 1307w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-recipe-300x126.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-recipe-1024x430.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-recipe-768x323.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-recipe-785x330.jpg 785w" sizes="auto, (max-width: 1307px) 100vw, 1307px" /></figure>



<p>Today in this article, we will cover Primitive Obsession Code Smell Resolution with an example.</p>



<p></p>



<p>We will cover below aspects,</p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-primitive-obsession-is-a-code-smell-and-type-of-anti-pattern-where-you-are-trying-to-use-primitives-for-definable-basic-domain-models-its-an-obsession-of-using-primitives-and-for-making-the-code-better-this-code-smell-requires-remediation-efforts">What is Primitive Obsession?</a></li><li><a href="#aioseo-few-examples-of-primitives-are-as-below">A few examples of C# primitives are as below,</a></li><li><a href="#aioseo-getting-started">Getting started</a><ul><li><a href="#aioseo-is-ssn-or-phone-number-in-the-above-example-is-just-a-string">Is SSN or Phone Number in the above example just a string?</a></li><li><a href="#mce_6">Primitive Obsession Resolution(Partial):</a><ul><li><a href="#aioseo-so-here-developers-might-tend-to-add-primitive-specific-validation-logic-to-employee-class-which-is-still-code-smell-which-we-will-see-in-below-example">So here developers might tend to add primitive specific validation logic to the Employee class (which is still code smell which we will see below example.. )</a></li></ul></li><li><a href="#aioseo-issues-in-the-above-employee-class">Issues in the above Employee class:</a></li><li><a href="#aioseo-primitive-obsession-resolution-full">Primitive Obsession Resolution (Full):</a></li><li><a href="#aioseo-refactoring-recipes-for-primitive-obsession">Refactoring Recipes for Primitive Obsession</a></li></ul></li></ul></div>



<div data-schema-only="false" class="wp-block-aioseo-faq" id="aioseo-primitive-obsession-is-a-code-smell-and-type-of-anti-pattern-where-you-are-trying-to-use-primitives-for-definable-basic-domain-models-its-an-obsession-of-using-primitives-and-for-making-the-code-better-this-code-smell-requires-remediation-efforts"><h3 class="aioseo-faq-block-question"><br><br>What is Primitive Obsession?</h3><div class="aioseo-faq-block-answer">
<p>Primitive Obsession is a code smell and type of anti-pattern where you are trying to use primitives for definable basic domain models. It&#8217;s an obsession of using excessive primitives and for making the code better this code smell requires remediation efforts.</p>
</div></div>



<p></p>



<blockquote class="wp-block-quote is-style-large is-layout-flow wp-block-quote-is-layout-flow">
<p>&#8220;Code is read more often than it is written&#8221;<br></p>
</blockquote>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>&#8220;Code is maintained more often than it is written&#8221;</p>
</blockquote>



<p></p>



<h3 class="wp-block-heading" id="aioseo-few-examples-of-primitives-are-as-below">A few examples of C# primitives are as below,</h3>



<p></p>



<ul class="wp-block-list">
<li>int</li>



<li>bool</li>



<li>short</li>



<li>double</li>



<li>char</li>



<li>float etc.</li>
</ul>



<p></p>



<p>We understand that classes are just dumb templates until they are defined with proper behavior. </p>



<p></p>



<p>The behavior of a class is defined by its properties, fields, and functions. </p>



<p></p>



<p>What we need to understand here is when these primitives are less in number and less in behavioral characteristics, they are manageable. </p>



<p></p>



<p>But the real problem (which we call &#8216;Code Smell&#8217;) starts growing when these primitives grow in number along with their behavioral characteristics. </p>



<p></p>



<p>It gets worse when developers define the same primitives at different places with code duplication without realizing it and code smell gets spread everywhere.</p>



<p></p>



<p>So below are a few characteristics of Primitive obsession,</p>



<p></p>



<ul class="wp-block-list">
<li>Use of Primitives (excessive)</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>Use of Constants or String constants for field names</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>Use Numeric type code for conditional OR validation statements </li>
</ul>



<p></p>



<h2 class="wp-block-heading" id="aioseo-getting-started">Getting started </h2>



<p></p>



<p>Let’s take an example and understand this,</p>



<p></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
public class Employee
    {
        public Employee(string firstName)
        {
            FirstName = firstName;
        }
        public string FirstName { get; set; }
    }

</pre></div>


<p></p>



<p>As shown in the above example, Class <em>Employee</em> with a single property of type string is defined, very easy indeed ! and all is well.<br></p>



<p>Now for the next future enhancement, this class grows as below,<br></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
public class Employee
    {
        public Employee(string firstName, string lastName, int iD,string contactCellNo,string ssn)
        {
            FirstName = firstName;
            LastName = lastName;
            ID = iD;
            PhoneNumber = contactCellNo;
            SSN = ssn;

        }

        public string FirstName { get; set; }
        public string LastName { get; set; }
        public int ID { get; set; }
        public string PhoneNumber { get; set; }
        public string SSN{ get; set; }
  }

</pre></div>


<p></p>



<h3 class="wp-block-heading" id="aioseo-is-ssn-or-phone-number-in-the-above-example-is-just-a-string">Is SSN or Phone Number in the above example just a string<strong>?</strong></h3>



<p></p>



<p><strong><em>Requirement </em></strong>1 &#8211; The phone number here is currently defined as a string. Let&#8217;s say you would like to extract the area code (here ex. 123) then you might need to add extraction logic.</p>



<p></p>



<p><strong><em>Requirement </em></strong>2- Additionally, let&#8217;s say you have business requirements for extracting the last four digits of your SSN from a given social security number. </p>



<p></p>



<p>You’ll have to write additional logic to extract the last four digits of SSN. Now we will deal with 2 primitive as below,  </p>



<p></p>



<p>Let’s see what it takes to extract the area code from a phone number.</p>



<p></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
            var phone = PhoneNumber;
            // Extract the area code
            var areacode = &quot;&quot;;
           int index = phone.LastIndexOf(&quot;-&quot;, StringComparison.Ordinal);
           if (index &gt; 0 &amp;&amp; index &lt; phone.Length)
                 areacode = phone.Substring(0,index);
            return areacode;

</pre></div>


<p></p>



<p>The above logic will be used and repeated at different places as and when there is a need for an area code. </p>



<p></p>



<h3 class="wp-block-heading" id="mce_6"><strong>Primitive Obsession Resolution(Partial):</strong></h3>



<p></p>



<h4 class="wp-block-heading" id="aioseo-so-here-developers-might-tend-to-add-primitive-specific-validation-logic-to-employee-class-which-is-still-code-smell-which-we-will-see-in-below-example">So here developers might tend to add primitive specific validation logic to the <em>Employee </em>class (which is still code smell which we will see below example.. )</h4>



<p></p>



<p>The class definition looks like as below after putting validation logic,</p>



<p></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
public class Employee
    {
        public Employee(string firstName, string lastName, int iD,string contactCellNo,string ssn)
        {
            FirstName = firstName;
            LastName = lastName;
            ID = iD;
            SSN = ssn;
        }

        public string FirstName { get; set; }
        public string LastName { get; set; }
        public int ID { get; set; }
        public string PhoneNumber { get; set; }
        public string SSN { get; set; }
        public string GetAreaCode()
        {
            var phone = PhoneNumber;
            // Extract the area code
            var areacode = &quot;&quot;;
            int index = phone.LastIndexOf(&quot;-&quot;, StringComparison.Ordinal);
            if (index &gt; 0 &amp;&amp; index &lt; phone.Length)
                 areacode = phone.Substring(0,index);
            return areacode;
        }

        public string GetLast4Digit()
        {
            var index = SSN.LastIndexOf(&quot;-&quot;, StringComparison.Ordinal);
            return index &gt;0 &amp;&amp; index &lt; SSN.Length
                ? SSN.Substring(index + 1, SSN.Length - index + 1)
                : SSN;
        }
    }

</pre></div>


<p></p>



<h3 class="wp-block-heading" id="aioseo-issues-in-the-above-employee-class">Issues in the above <em>Employee </em>class:<br></h3>



<p></p>



<p>Here  <em><strong>GetAreaCode </strong></em>and <strong><em>GetLast4Digit  </em></strong>methods would produce the desired results but there are a few problems as listed below,</p>



<p><br></p>



<ul class="wp-block-list">
<li>Extraction or formatting logic of SSN and PhoneNumber is owned by the <em>Employee </em>class.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>If the logic is needed in other parts of your application, then the code will be duplicated. You will end up instantiating the Employee class so that you can use the GetArea() or  GetLast4Digit () method which is unnecessary. </li>
</ul>



<p></p>



<p></p>



<h3 class="wp-block-heading" id="aioseo-primitive-obsession-resolution-full"> <br>Primitive Obsession Resolution (Full): </h3>



<p></p>



<h3 class="wp-block-heading" id="aioseo-refactoring-recipes-for-primitive-obsession">Refactoring Recipes for Primitive Obsession</h3>



<p></p>



<p>I took these recipes from Martin Flower&#8217;s book <a href="https://amzn.to/2Ibf4Zc" target="_blank" rel="noreferrer noopener">&#8220;<strong><em>Refactoring: Improving the Design of Existing Code</em></strong>&#8220;.</a>  </p>



<p></p>



<p>Primitive obsession for the above two issues can be resolved by the below-refactoring recipes. </p>



<p></p>



<ul class="wp-block-list">
<li><strong>Replace Data value with Object(</strong> suitable for the above example<strong>) </strong></li>
</ul>



<p></p>



<ul class="wp-block-list">
<li><strong>Replace Type Code with Classes or Subclasses </strong></li>
</ul>



<p></p>



<ul class="wp-block-list">
<li><strong>Replace Type Code with State/Strategy</strong></li>
</ul>



<p></p>



<p></p>



<p>Both above techniques concentrate more on replacing primitive type with ValueObject/Class/SubClass.</p>



<p></p>



<p>All validation or extraction logic will become part of  ValueObject/Class/SubClass. </p>



<p></p>



<p>This will avoid code duplication.</p>



<p></p>



<p>Let&#8217;s now replace SSN and PhoneNumber primitive with objects. We shall also move their methods/validation logic.</p>



<p></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
public class SocialSecurity
    {
        public SocialSecurity(string ssn)
        {
            SSN = ssn;
        }

        public string SSN { get; set; }

        public string GetLast4Digit()
        {
           var index = SSN.LastIndexOf(&quot;-&quot;, StringComparison.Ordinal);
            return index &gt; 0 &amp;&amp; index &lt; SSN.Length
                ? SSN.Substring(index + 1, SSN.Length - index + 1)
                : SSN;
        }
    }


    public class Contact
    {
        public Contact(string number)
        { 
            PhoneNumber = number;
        }

        public string PhoneNumber { get; set; }

        public string GetAreaCode()
        {
           var index = PhoneNumber.IndexOf(&quot;-&quot;, StringComparison.Ordinal);
            return index &gt; 0 &amp;&amp; index&lt; PhoneNumber.Length
                ? PhoneNumber.Substring(0,index)
                : PhoneNumber;
        }
    }


</pre></div>


<p></p>



<p><strong>See class diagram below for high-level changes,</strong></p>



<p></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1540" height="847" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-class-diagram-1.png?fit=785%2C432&amp;ssl=1" alt="Awesome code - Primitive Obsession Code Smell Resolution with example" class="wp-image-2012" srcset="https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-class-diagram-1.png 1540w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-class-diagram-1-300x165.png 300w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-class-diagram-1-1024x563.png 1024w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-class-diagram-1-768x422.png 768w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-class-diagram-1-1536x845.png 1536w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-class-diagram-1-785x432.png 785w" sizes="auto, (max-width: 1540px) 100vw, 1540px" /><figcaption class="wp-element-caption">Employee Class with code smell Vs  Employee Class  <br>refactored for primitive obsession </figcaption></figure>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" width="2975" height="696" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-2.png?fit=785%2C184&amp;ssl=1" alt="Awesome code - Primitive Obsession Code Smell Resolution with example" class="wp-image-2015" srcset="https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-2.png 2975w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-2-300x70.png 300w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-2-1024x240.png 1024w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-2-768x180.png 768w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-2-1536x359.png 1536w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-2-2048x479.png 2048w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-resolution-2-785x184.png 785w" sizes="auto, (max-width: 2975px) 100vw, 2975px" /></figure>



<p></p>



<p>On the calling side, since behavior is now sticking to a Class of its own, the code will be simplified as below,</p>



<p></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="2409" height="610" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-Example1.png?fit=785%2C199&amp;ssl=1" alt="Awesome code - Primitive Obsession Code Smell Resolution with example" class="wp-image-2051" srcset="https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-Example1.png 2409w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-Example1-300x76.png 300w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-Example1-1024x259.png 1024w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-Example1-768x194.png 768w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-Example1-1536x389.png 1536w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-Example1-2048x519.png 2048w, https://thecodebuzz.com/wp-content/uploads/2019/03/Premitive-Obsession-Example1-785x199.png 785w" sizes="auto, (max-width: 2409px) 100vw, 2409px" /></figure>



<p></p>



<ul class="wp-block-list">
<li>The result of recipes used for Primitive obsession resembles the low-level version of DDD (Domain Driven Design) bringing your domain properties and their validation logic together so that the domain model that gets built over this can be used across your application supporting the DRY (Do Not Repeat) principle. These value objects, however, are not actual business objects or domain models but are simple logical models. </li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>These refactoring principles like Primitive Obsession or <a href="https://www.thecodebuzz.com/awesome-code-inappropriate-intimacy-code-smell-resolution/" target="_blank" rel="noopener" title="Awesome Code -Inappropriate Intimacy Code Smell">Inappropriate Intimacy</a> are really good friends of any Design Pattern including Domain Driven Design. These principles are where you will start ultimately before you can shape up design or architecture. Code is always supreme of all.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>Objects become logical containers by packaging data with their behavior as new methods/functions.</li>
</ul>



<p></p>



<ul class="wp-block-list">
<li>There are many built-in types already available that encapsulate primitives and their methods like Ex. class <em>DateTime.</em></li>
</ul>



<p></p>



<p><strong><em>References: </em></strong></p>



<p></p>



<ul class="wp-block-list">
<li><a href="https://www.thecodebuzz.com/static-code-quality-analysis-ndepend/" target="_blank" rel="noreferrer noopener"><strong><em>NDepend</em></strong></a>&#8211; <a href="https://www.thecodebuzz.com/static-code-quality-analysis-ndepend/" title="Continuous Code Quality using NDepend" target="_blank" rel="noreferrer noopener"><strong><em>Continuous Code Quality</em></strong></a></li>
</ul>



<ul class="wp-block-list">
<li><a href="https://www.thecodebuzz.com/continuous-code-quality-of-using-sonar/" title="Continuous Code Quality of .NET and .NET Core applications using Sonar" target="_blank" rel="noreferrer noopener"><em><strong>Sonar way- Continuous Code Quality of .NET and .NET Core applications using Sonar</strong></em></a></li>
</ul>



<p></p>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p>



<p></p><p>The post <a href="https://thecodebuzz.com/awesome-code-primitive-obsession-code-smell-with-example/">Awesome code – Primitive Obsession Code Smell Resolution with example</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/awesome-code-primitive-obsession-code-smell-with-example/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Sonar Qube &#8211; Code Quality of Angular, React, and Vue applications</title>
		<link>https://thecodebuzz.com/continuous-code-quality-in-angular-7-applications-using-sonar/</link>
					<comments>https://thecodebuzz.com/continuous-code-quality-in-angular-7-applications-using-sonar/#comments</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 01 Mar 2022 00:00:00 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Code Smell]]></category>
		<category><![CDATA[React]]></category>
		<category><![CDATA[Vue.js]]></category>
		<category><![CDATA[angular 4 code review tool]]></category>
		<category><![CDATA[angular 6 code review tool]]></category>
		<category><![CDATA[angular 7 code review checklist]]></category>
		<category><![CDATA[Angular ESLint]]></category>
		<category><![CDATA[Angular linting]]></category>
		<category><![CDATA[angular sonarqube coverage]]></category>
		<category><![CDATA[Angular TSLint]]></category>
		<category><![CDATA[Code analysis angular]]></category>
		<category><![CDATA[Code analysis React]]></category>
		<category><![CDATA[Code analysis Vue]]></category>
		<category><![CDATA[Code Quality of Angular]]></category>
		<category><![CDATA[code review checklist javascript]]></category>
		<category><![CDATA[Codelyzer vs Sonar  angular 8]]></category>
		<category><![CDATA[codelyzer Vs Sonar angular ]]></category>
		<category><![CDATA[codelyzer vs tslint vs SonarLint]]></category>
		<category><![CDATA[coding issues Angular]]></category>
		<category><![CDATA[command is used to run static code analysis of angular application]]></category>
		<category><![CDATA[Javascript linting]]></category>
		<category><![CDATA[node js static code analysis tools]]></category>
		<category><![CDATA[react code review checklist]]></category>
		<category><![CDATA[react code review tools]]></category>
		<category><![CDATA[react code smells]]></category>
		<category><![CDATA[react coding standards]]></category>
		<category><![CDATA[React ESLint]]></category>
		<category><![CDATA[React lint]]></category>
		<category><![CDATA[react native code review checklist]]></category>
		<category><![CDATA[React or Vue applications using Sonar.]]></category>
		<category><![CDATA[React quality]]></category>
		<category><![CDATA[reactjs code review checklist]]></category>
		<category><![CDATA[Sonar lint]]></category>
		<category><![CDATA[sonar lint vscode extension]]></category>
		<category><![CDATA[sonar-project.properties angular]]></category>
		<category><![CDATA[sonar-scanner for angular]]></category>
		<category><![CDATA[sonarqube angular 7]]></category>
		<category><![CDATA[sonarqube angular 8]]></category>
		<category><![CDATA[sonarqube angular code coverage]]></category>
		<category><![CDATA[sonarqube for angular projects]]></category>
		<category><![CDATA[sonarqube integration with angular]]></category>
		<category><![CDATA[static code analysis of angular application]]></category>
		<category><![CDATA[typescript coding best practices]]></category>
		<category><![CDATA[typescript static analysis]]></category>
		<category><![CDATA[Visual Studio sonar lint]]></category>
		<category><![CDATA[Vue ESLint]]></category>
		<category><![CDATA[Vue linting]]></category>
		<guid isPermaLink="false">https://thecodebuzz.com/?p=2398</guid>

					<description><![CDATA[<p>Continuous Code Quality UI (Angular, React, or Vue) using SonarLint Today in this article we shall see how to use the Sonar Lint IDE extension for VSCode and manage Code Quality of Angular, React, and Vue applications with Sonar Qube. Most of us understand the importance of code quality. Good coding practices are language agnostic [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/continuous-code-quality-in-angular-7-applications-using-sonar/">Sonar Qube – Code Quality of Angular, React, and Vue applications</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading"><strong>Continuous Code Quality UI (Angular, React, or Vue</strong>) <strong>using SonarLint</strong></h1>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="624" src="https://www.thecodebuzz.com/wp-content/uploads/2020/09/Code-Quality-of-Angular-React-Vue-applications-using-Sonar-1024x624.jpg" alt="Code Quality of Angular, React, Vue applications with Sonar Qube" class="wp-image-12361" srcset="https://thecodebuzz.com/wp-content/uploads/2020/09/Code-Quality-of-Angular-React-Vue-applications-using-Sonar-1024x624.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2020/09/Code-Quality-of-Angular-React-Vue-applications-using-Sonar-300x183.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2020/09/Code-Quality-of-Angular-React-Vue-applications-using-Sonar-768x468.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2020/09/Code-Quality-of-Angular-React-Vue-applications-using-Sonar-785x478.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2020/09/Code-Quality-of-Angular-React-Vue-applications-using-Sonar.jpg 1446w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Today in this article we shall see how to use the Sonar Lint<strong> IDE </strong>extension for <strong>VSCode</strong> and manage Code Quality of Angular, React, and Vue applications with Sonar Qube.</p>



<p></p>



<p>Most of us understand the importance of code quality. </p>



<p></p>



<p>Good coding practices are language agnostic and help an organization deliver clean, highly reliable, secure, and maintainable code. </p>



<p></p>



<p>Today in this article, we shall cover the below aspects,</p>



<p></p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-getting-started-code-quality-of-angular-react-vue-applications-with-sonar">Getting started &#8211; Code Quality of Angular, React, and Vue applications with Sonar</a><ul><li><a href="#aioseo-prerequisites-and-configuration">Prerequisites and Configuration:</a><ul><li><a href="#aioseo-java-run-time-jre-8">Java Run time (JRE) 8</a></li><li><a href="#aioseo-install-sonar-lint-extension-in-vscode">Install Sonar Lint extension in VSCode</a></li><li><a href="#aioseo-setting-json-update">Setting.json update</a></li></ul></li></ul></li><li><a href="#aioseo-user-settings-sonar-connected-mode">User Settings Sonar Qube &#8211;  connected mode</a><ul><li><a href="#aioseo-connected-mode-in-user-settings">Connected Mode in User Settings</a></li></ul></li><li><a href="#aioseo-workspace-settings-sonar-connected-mode">Workspace settings Sonar  &#8211;  connected mode</a><ul><li><a href="#mce_54">Connected Mode in Workspace Settings</a></li><li><a href="#aioseo-summary">Summary :</a></li></ul></li></ul></div>



<p></p>



<p>Software code quality and its maintenance is like a big fat elephant and often eat away a big chunk of project budget allocation. Re-engineering and refactoring of buggy code cost organization time, cost, and quality. </p>



<p></p>



<p>These small-looking coding issues become bigger problems in the future and potentially affect the complete architecture and design of your application.</p>



<p></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p> <strong>“Any fool can write code that a computer can understand. Good programmers write code that humans can understand” &nbsp;-Martin Fowler</strong></p>
</blockquote>



<p></p>



<p></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><strong>“Code is maintained more often than it is written”</strong></p>
</blockquote>



<p></p>



<p></p>



<p><strong>SonarLint </strong>is an IDE extension that helps to detect and fix code quality issues as you type the code in IDE. </p>



<p></p>



<p><strong>SonarLint</strong> extension combines all the best of the linting process and supports multiple analyzers and multiple languages.  </p>



<p></p>



<ul class="wp-block-list">
<li><strong>Typescript &#8211; Sonar TS analyzer </strong></li>
</ul>



<ul class="wp-block-list">
<li><strong>JavaScript, </strong>React, Vue &#8211; SonarJS<strong>, ESLint  analyzer</strong></li>
</ul>



<p></p>



<p>SonarLint IDE extension is currently supported by the below <strong><em>IDE </em></strong>overall,</p>



<p></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" width="1228" height="924" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/SonarLint-Vscode-IDE-extension-.jpg?fit=785%2C590&amp;ssl=1" alt="Angular sonar lint" class="wp-image-2399" style="width:542px;height:407px" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/SonarLint-Vscode-IDE-extension-.jpg 1228w, https://thecodebuzz.com/wp-content/uploads/2019/04/SonarLint-Vscode-IDE-extension--300x226.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/SonarLint-Vscode-IDE-extension--1024x771.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/SonarLint-Vscode-IDE-extension--768x578.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/SonarLint-Vscode-IDE-extension--691x520.jpg 691w" sizes="auto, (max-width: 1228px) 100vw, 1228px" /></figure>



<p></p>



<p>Sonar defines coding issues in the below categories,</p>



<ul class="wp-block-list">
<li><strong>Bug</strong></li>



<li><strong>Code Smell</strong></li>



<li><strong>Vulnerability </strong></li>
</ul>



<p></p>



<p>Each above categories can be further classified based on severity as below,</p>



<p></p>



<ul class="wp-block-list">
<li><strong>Blocker</strong></li>



<li><strong>Critical </strong></li>



<li><strong>Major</strong></li>



<li><strong>Minor</strong></li>



<li><strong>Info</strong></li>
</ul>



<p></p>



<p>Let&#8217;s look into SonarLint VS Code plugin extension setup and configuration details.</p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-getting-started-code-quality-of-angular-react-vue-applications-with-sonar">Getting started &#8211; Code Quality of Angular, React, and Vue applications with Sonar</h2>



<p></p>



<h3 class="wp-block-heading" id="aioseo-prerequisites-and-configuration"><strong>Prerequisites and Configuration:</strong></h3>



<p></p>



<h4 class="wp-block-heading has-text-align-left" id="aioseo-java-run-time-jre-8">Java Run time (JRE) 8 </h4>



<p></p>



<p>Once Java run time is installed, please verify using the version using the below command,</p>



<p></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" width="1117" height="208" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/image-20.png?fit=785%2C146&amp;ssl=1" alt="React sonar lint" class="wp-image-2401" style="width:560px;height:104px" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/image-20.png 1117w, https://thecodebuzz.com/wp-content/uploads/2019/04/image-20-300x56.png 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/image-20-1024x191.png 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/image-20-768x143.png 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/image-20-785x146.png 785w" sizes="auto, (max-width: 1117px) 100vw, 1117px" /></figure>



<p>Further verification can be done by checking the below folder on your Windows machine,</p>



<p></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="719" height="124" src="https://www.thecodebuzz.com/wp-content/uploads/2019/04/image-21.png" alt="react code review checklist" class="wp-image-2402" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/image-21.png 719w, https://thecodebuzz.com/wp-content/uploads/2019/04/image-21-300x52.png 300w" sizes="auto, (max-width: 719px) 100vw, 719px" /></figure>



<p></p>



<h4 class="wp-block-heading" id="aioseo-install-sonar-lint-extension-in-vscode">Install Sonar Lint extension in VSCode</h4>



<p></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" width="2686" height="564" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-vscode-extension-angular.png?fit=785%2C165&amp;ssl=1" alt="Vue sonar lint" class="wp-image-2403" style="width:562px;height:117px" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-vscode-extension-angular.png 2686w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-vscode-extension-angular-300x63.png 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-vscode-extension-angular-1024x215.png 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-vscode-extension-angular-768x161.png 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-vscode-extension-angular-1536x323.png 1536w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-vscode-extension-angular-2048x430.png 2048w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-vscode-extension-angular-785x165.png 785w" sizes="auto, (max-width: 2686px) 100vw, 2686px" /></figure>



<p></p>



<h4 class="wp-block-heading" id="aioseo-setting-json-update">Setting.json update</h4>



<p></p>



<p>Click on Settings -&gt;Edit in Settings.Json</p>



<p></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" width="1945" height="807" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-vscode-extension-angular-settings-configuration-.jpg?fit=785%2C326&amp;ssl=1" alt="Javascript sonar lint" class="wp-image-2404" style="width:564px;height:233px" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-vscode-extension-angular-settings-configuration-.jpg 1945w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-vscode-extension-angular-settings-configuration--300x124.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-vscode-extension-angular-settings-configuration--1024x425.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-vscode-extension-angular-settings-configuration--768x319.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-vscode-extension-angular-settings-configuration--1536x637.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-vscode-extension-angular-settings-configuration--785x326.jpg 785w" sizes="auto, (max-width: 1945px) 100vw, 1945px" /></figure>



<p></p>



<h2 class="wp-block-heading" id="aioseo-user-settings-sonar-connected-mode">User Settings Sonar Qube &#8211;  connected mode </h2>



<p></p>



<p>These settings will be global and will be applied at the VSCode IDE level and will be effective for all projects.</p>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size">{
"sonarlint.ls.javaHome": "C:\Program Files\Java\jdk1.8.0_201"
}</pre>



<p></p>



<p>If connecting your Organization enterprise Sonar Server please add the below setting within<strong> <em>&#8220;sonarlint.connectedMode.servers&#8221;</em></strong></p>



<p></p>



<p><strong>Note:</strong></p>



<p><br><strong>SonarLint</strong> uses the same rule set as configured on the SonarQube server thereby streamlining the code analysis and avoiding any ambiguity of issues reported on server vs desktop. </p>



<p>If not connected to the Sonar Server default ruleset ( which comes with plugin installation) will be used.</p>



<p></p>



<h4 class="wp-block-heading" id="aioseo-connected-mode-in-user-settings">Connected Mode in User Settings</h4>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size">"sonarlint.connectedMode.servers": [
 {
"serverId": "your server id if any",
"serverUrl": "https://your-org/server",//Your Organization server URL
"organizationKey": "my_organization",// Organization Key
"token": "V2VkIE1…" //Organization Auth token
 }
]</pre>



<p></p>



<h2 class="wp-block-heading" id="aioseo-workspace-settings-sonar-connected-mode">Workspace settings Sonar  &#8211;  connected mode  </h2>



<p></p>



<p>This setting will be specific to an individual project. This setting can be checked in along with your source project to SCM.</p>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size">{<br>"sonarlint.ls.javaHome": "C:\Program Files\Java\jre1.8.0_201"<br>}</pre>



<p></p>



<h4 class="wp-block-heading" id="mce_54">Connected Mode in Workspace Settings</h4>



<p></p>



<p>If connecting to your organization&#8217;s Sonar Server additionally add below within workspace settings.</p>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size">"sonarlint.connectedMode.project": {
  "serverId": "your server id if any",
  "projectKey": "your project name in sonar server"
}</pre>



<p></p>



<p>Once done with the above settings, you shall be all set to use Sonar linting. The output windows will display that SonarTS Server and the engine have started successfully. </p>



<p></p>



<p>If not connected to the server,  Sonar Lint will launch the Sonar server( with different analyzers) locally by opening a local port and will use the default rule set in such a case. </p>



<p></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="2560" height="673" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/SoanrTS-server-conenction-issue-resolution-1-2.jpg?fit=785%2C206&amp;ssl=1" alt="Sonarlint connected mode Vscode" class="wp-image-2416" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/SoanrTS-server-conenction-issue-resolution-1-2.jpg 2560w, https://thecodebuzz.com/wp-content/uploads/2019/04/SoanrTS-server-conenction-issue-resolution-1-2-300x79.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/SoanrTS-server-conenction-issue-resolution-1-2-1024x269.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/SoanrTS-server-conenction-issue-resolution-1-2-768x202.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/SoanrTS-server-conenction-issue-resolution-1-2-1536x404.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/04/SoanrTS-server-conenction-issue-resolution-1-2-2048x538.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2019/04/SoanrTS-server-conenction-issue-resolution-1-2-785x206.jpg 785w" sizes="auto, (max-width: 2560px) 100vw, 2560px" /></figure>



<p></p>



<p>If using Sonar Server in &#8220;Connected&#8221; mode kindly run the below command from the Command pallet,</p>



<p></p>



<pre class="wp-block-preformatted has-medium-font-size">Update SonarLint binding to SonarQube/SonarCloud </pre>



<p></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1800" height="325" src="https://i2.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/image-22.jpg?fit=785%2C142&amp;ssl=1" alt="Vscode Sonarlint " class="wp-image-2423" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/image-22.jpg 1800w, https://thecodebuzz.com/wp-content/uploads/2019/04/image-22-300x54.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/image-22-1024x185.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/image-22-768x139.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/image-22-1536x277.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/04/image-22-785x142.jpg 785w" sizes="auto, (max-width: 1800px) 100vw, 1800px" /></figure>



<p>As you type your code you shall be able to see the best recommendation from Sonar lint based on configured rules. </p>



<p></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="2033" height="652" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-rules-configuration-window.jpg?fit=785%2C251&amp;ssl=1" alt="Sonarlint connected mode setting" class="wp-image-2476" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-rules-configuration-window.jpg 2033w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-rules-configuration-window-300x96.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-rules-configuration-window-1024x328.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-rules-configuration-window-768x246.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-rules-configuration-window-1536x493.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-rules-configuration-window-785x252.jpg 785w" sizes="auto, (max-width: 2033px) 100vw, 2033px" /></figure>



<p></p>



<p>As we mentioned above Sonar lint uses the same rules set as configured on the SonarQube server and streamlines the code analysis by avoiding any ambiguity of reports on server vs desktop. </p>



<p></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="700" height="418" src="https://www.thecodebuzz.com/wp-content/uploads/2019/04/Continuous-Code-Quality-of-Angular-React-or-Vue-applications-using-Sonar.gif" alt="Sonarlint connected mode setting" class="wp-image-2639"/></figure>



<p></p>



<p>For server-side reporting SonarQube need to be used which is a licensed and enterprise version. </p>



<p></p>



<p>Sonar scan can be configured as part build and deploy process for the CI-CD pipeline. </p>



<p></p>



<p><strong><em>SonarQube </em></strong>provides the overall health of the portfolio within the organization with nice dashboards detailing code health.   </p>



<p></p>



<p>Happy coding !!</p>



<p></p>



<p style="font-size:18px">Do you have any <strong>comments or ideas or any better </strong>suggestions to share?</p>



<p class="has-small-font-size"></p>



<p style="font-size:18px">Please sound off your comments below.</p>



<p class="has-medium-font-size"></p>



<p class="has-medium-font-size"><strong>Happy Coding </strong>!!</p>



<p></p>



<p></p>



<p><strong><em>References: </em></strong></p>



<p></p>



<ul class="wp-block-list" id="block-ab9b38d2-be73-4989-8171-39a3b3b0203e">
<li><a href="https://www.thecodebuzz.com/static-code-quality-analysis-ndepend/" target="_blank" rel="noreferrer noopener"><strong><em>Continuous Code Quality using NDepend</em></strong></a></li>
</ul>



<p></p>



<ul class="wp-block-list" id="block-ab9b38d2-be73-4989-8171-39a3b3b0203e">
<li><a href="https://www.thecodebuzz.com/continuous-code-quality-of-using-sonar/" target="_blank" rel="noreferrer noopener" title="Continuous Code Quality of .NET with SonarQube"><strong><em>Code Quality of .NET Application using Sonar</em></strong></a></li>
</ul>



<p></p>



<h4 class="wp-block-heading" id="aioseo-summary">Summary : </h4>



<p></p>



<p>Today we learned about Sonar lint setup and configuration for Visual Studio Code IDE. <strong>Good coding practices are language agnostics and help the organization to deliver clean, highly reliable, secure, and maintainable projects.</strong> Buggy code slipping through the cracks has the potential to cost a company an entire business. Organizations can address these problems by following best practices of software development like continuous code quality and continuous code review processes.</p>



<p></p>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p>



<p></p><p>The post <a href="https://thecodebuzz.com/continuous-code-quality-in-angular-7-applications-using-sonar/">Sonar Qube – Code Quality of Angular, React, and Vue applications</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/continuous-code-quality-in-angular-7-applications-using-sonar/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Continuous Code Quality of .NET with SonarQube</title>
		<link>https://thecodebuzz.com/continuous-code-quality-of-using-sonar/</link>
					<comments>https://thecodebuzz.com/continuous-code-quality-of-using-sonar/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 01 Mar 2022 00:00:00 +0000</pubDate>
				<category><![CDATA[.NET Core]]></category>
		<category><![CDATA[CICD]]></category>
		<category><![CDATA[Code Smell]]></category>
		<category><![CDATA[c# code analysis tools free]]></category>
		<category><![CDATA[c# code analysis tools online]]></category>
		<category><![CDATA[c# coding analysis]]></category>
		<category><![CDATA[Code analysis .NET Core]]></category>
		<category><![CDATA[code analysis C#]]></category>
		<category><![CDATA[Code analysis dotnet core]]></category>
		<category><![CDATA[code analysis tools c# Visual Studio]]></category>
		<category><![CDATA[code quality analysis]]></category>
		<category><![CDATA[Code Quality of .NET and .NET Core]]></category>
		<category><![CDATA[Code Quality of C#]]></category>
		<category><![CDATA[Code Quality using Sonar]]></category>
		<category><![CDATA[code review checklist javascript]]></category>
		<category><![CDATA[Code scan .NET Core]]></category>
		<category><![CDATA[Codelyzer vs Sonar  angular 8]]></category>
		<category><![CDATA[codelyzer Vs Sonar angular ]]></category>
		<category><![CDATA[codelyzer vs tslint vs SonarLint]]></category>
		<category><![CDATA[coding best practices]]></category>
		<category><![CDATA[command is used to run static code analysis of angular application]]></category>
		<category><![CDATA[dynamic code analysis tools]]></category>
		<category><![CDATA[how to run code analysis in visual studio 2017]]></category>
		<category><![CDATA[install sonar lint]]></category>
		<category><![CDATA[microsoft code analysis 2017]]></category>
		<category><![CDATA[microsoft code analysis 2019]]></category>
		<category><![CDATA[node js static code analysis tools]]></category>
		<category><![CDATA[open source code analysis tools c#]]></category>
		<category><![CDATA[react code review checklist]]></category>
		<category><![CDATA[react code review tools]]></category>
		<category><![CDATA[react code smells]]></category>
		<category><![CDATA[react coding standards]]></category>
		<category><![CDATA[react native code review checklist]]></category>
		<category><![CDATA[reactjs code review checklist]]></category>
		<category><![CDATA[roslyn analyzer]]></category>
		<category><![CDATA[roslyn analyzer .net core]]></category>
		<category><![CDATA[Sonar lint C#]]></category>
		<category><![CDATA[sonar lint code quality]]></category>
		<category><![CDATA[Sonar lint extension VS2017]]></category>
		<category><![CDATA[sonarqube cloud]]></category>
		<category><![CDATA[sonarqube code coverage]]></category>
		<category><![CDATA[sonarqube documentation]]></category>
		<category><![CDATA[sonarqube download]]></category>
		<category><![CDATA[sonarqube features]]></category>
		<category><![CDATA[sonarqube jenkins]]></category>
		<category><![CDATA[sonarqube tutorial]]></category>
		<category><![CDATA[static code analysis tools C#]]></category>
		<category><![CDATA[visual studio 2019 code analysis]]></category>
		<category><![CDATA[visual studio static code analysis]]></category>
		<guid isPermaLink="false">https://thecodebuzz.com/?p=2495</guid>

					<description><![CDATA[<p>Code Quality of .NET using SonarQube in Visual Studio Most of us understand the importance of code quality. Good coding practices are language agnostics and help any organization to deliver clean, highly reliable, secure, and maintainable code. Today in this article, we shall see how to manage the Code Quality of .NET with SonarQube. “Any [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/continuous-code-quality-of-using-sonar/">Continuous Code Quality of .NET with SonarQube</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading"><strong>Code Quality of .NET using SonarQube</strong> <strong>in Visual Studio </strong></h1>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="https://i2.wp.com/thecodebuzz.com/wp-content/uploads/2019/05/sonarlint-code-quality-visual-studio-extension.jpg?fit=785%2C270&amp;ssl=1" alt="SonarQube in Visual Studio" class="wp-image-3142" width="609" height="209" srcset="https://thecodebuzz.com/wp-content/uploads/2019/05/sonarlint-code-quality-visual-studio-extension.jpg 2305w, https://thecodebuzz.com/wp-content/uploads/2019/05/sonarlint-code-quality-visual-studio-extension-300x103.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/05/sonarlint-code-quality-visual-studio-extension-1024x352.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/05/sonarlint-code-quality-visual-studio-extension-768x264.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/05/sonarlint-code-quality-visual-studio-extension-1536x528.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/05/sonarlint-code-quality-visual-studio-extension-2048x704.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2019/05/sonarlint-code-quality-visual-studio-extension-785x270.jpg 785w" sizes="auto, (max-width: 609px) 100vw, 609px" /></figure>



<p>Most of us understand the importance of code quality. Good coding practices are language agnostics and help any organization to deliver clean, highly reliable, secure, and maintainable code. Today in this article, we shall see how to manage the Code Quality of .NET with SonarQube.</p>



<p></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p> <strong>“Any fool can write code that a computer can understand. Good programmers write code that humans can understand” &nbsp;-Martin Fowler</strong> </p></blockquote>



<p></p>



<p>Software maintenance is like a big fat elephant and often eats away a big chunk of project budget allocation. Re-engineering and refactoring of buggy code cost organization time, cost, and quality. These small-looking coding issues become bigger problems in the future and potentially affect the complete architecture and design of your application. </p>



<p></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p><strong>“Code is maintained more often than it is written”</strong></p></blockquote>



<p>Today in this article, we will cover below aspects,</p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-getting-started-code-quality-of-net-with-sonarqube">Getting started &#8211; Code Quality of .NET with SonarQube</a><ul><li><a href="#aioseo-prerequisites">Prerequisites:</a><ul><li><a href="#aioseo-visual-studio-2015-or-2017-or-2019">* Visual Studio 2015 or 2017 or 2019</a></li><li><a href="#aioseo-install-sonarlint-extension">* Install SonarLint extension</a></li></ul></li></ul></li><li><a href="#aioseo-sonar-connected-mode-configuration">Sonar &#8211; Connected Mode configuration</a><ul><li><a href="#aioseo-summary">Summary :</a></li></ul></li></ul></div>



<p>Today in this article we shall see how to use the <em><strong>Sonar Lint IDE</strong></em> extension in <strong><em>Visual Studio 2017(or VS2019)</em></strong></p>



<p></p>



<p><strong>SonarLint&nbsp;</strong>is an IDE extension that helps to detect and fix code quality issues as you type the code in IDE.</p>



<p></p>



<p><strong>SonarLint</strong> Visual Studio extension<strong> </strong>combines together all best of the linting process and supports multiple analyzers and multiple languages.</p>



<p></p>



<ul class="wp-block-list"><li><em><strong>C# (.NET , .NET Core, .NET Standards) &#8211; Roslyn analyzer</strong></em></li></ul>



<ul class="wp-block-list"><li><em><strong>VB.NET- Roslyn analyzer </strong></em></li></ul>



<ul class="wp-block-list"><li><em><strong>JavaScript- SonarJS analyzer</strong></em></li></ul>



<ul class="wp-block-list"><li><em><strong>C/C++ &#8211; SonarCFamily </strong></em></li></ul>



<p></p>



<p>Support for <strong><em>Typescript or Python</em></strong> language is supported through another SonarLint plugin that works on Visual Studio Code IDE. Please see more details on the below link,</p>



<p></p>



<ul class="wp-block-list"><li><a href="https://www.thecodebuzz.com/continuous-code-quality-in-angular-7-applications-using-sonar/" target="_blank" rel="noreferrer noopener"><strong><em>Continuous Code Quality of Angular, React or Vue.js applications using Sonar</em></strong></a></li></ul>



<p></p>



<h2 class="wp-block-heading" id="aioseo-getting-started-code-quality-of-net-with-sonarqube">Getting started &#8211; Code Quality of .NET with SonarQube</h2>



<p></p>



<h3 class="wp-block-heading" id="aioseo-prerequisites">Prerequisites:</h3>



<p></p>



<h4 class="wp-block-heading" id="aioseo-visual-studio-2015-or-2017-or-2019">   * Visual Studio 2015 or 2017 or 2019</h4>



<h4 class="wp-block-heading" id="aioseo-install-sonarlint-extension">   * Install SonarLint extension </h4>



<p></p>



<p>From <em><strong>Menu-&gt;Extension-&gt;Manage Extension, please search with the </strong></em>keyword &#8220;Sonar&#8221; as below. Here I am installing this extension for VS2019.  </p>



<p></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1873" height="566" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-dotnetcore-1.jpg?fit=785%2C237&amp;ssl=1" alt="SonarLint visual studio" class="wp-image-2498" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-dotnetcore-1.jpg 1873w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-dotnetcore-1-300x91.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-dotnetcore-1-1024x309.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-dotnetcore-1-768x232.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-dotnetcore-1-1536x464.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-dotnetcore-1-785x237.jpg 785w" sizes="auto, (max-width: 1873px) 100vw, 1873px" /></figure>



<p></p>



<p><strong><em>Note-The first-time installation requires you to restart the Visual Studio to complete the installation.</em></strong></p>



<p></p>



<p>After successful installation of the extension, IDE will start analyzing code and shall start reporting the issue as shown below,</p>



<p></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="2017" height="510" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-dotnetcore-visual-studio-1.jpg?fit=785%2C199&amp;ssl=1" alt="Sonar C# code quality " class="wp-image-2526" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-dotnetcore-visual-studio-1.jpg 2017w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-dotnetcore-visual-studio-1-300x76.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-dotnetcore-visual-studio-1-1024x259.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-dotnetcore-visual-studio-1-768x194.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-dotnetcore-visual-studio-1-1536x388.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-dotnetcore-visual-studio-1-785x198.jpg 785w" sizes="auto, (max-width: 2017px) 100vw, 2017px" /></figure>



<p></p>



<p>As you type your code you shall be able to see the best recommendation from SonarLint based on configured rules. </p>



<p></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="692" height="526" src="https://www.thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-continous-coding-inspection-gif.gif" alt="SonarLint Visual studio plugin" class="wp-image-2552"/></figure>



<p></p>



<h2 class="wp-block-heading" id="aioseo-sonar-connected-mode-configuration">Sonar &#8211; Connected Mode configuration</h2>



<p></p>



<p><strong>SonarQube </strong>scan can be configured as part build and deploy process within the CICD pipeline. SonarQube provides the overall health of the portfolio within the organization with nice dashboards detailing the overall health of the code.</p>



<p></p>



<p><strong>Sonar Server</strong></p>



<p></p>



<p><strong><em>SonarLint if used with the SonarQube server </em></strong>streamlines the code analysis process by using a<strong><em> </em></strong>uniform rule set across the organization and avoids any ambiguity of issues reported on server vs developers Desktop/IDE. So far above we used the default ruleset which comes with plugin installation now we shall see how to use the connected mode of the sonar server.</p>



<p></p>



<p>Connected mode configuration is a simple 1-2 step process. Below we shall try connecting the application with a quality profile of the server.</p>



<p></p>



<ul class="wp-block-list"><li>Click on Team Explorer in Visual Studio and connect to SonarQube as shown below,</li></ul>



<p></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="https://i0.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-quality.jpg?fit=785%2C420&amp;ssl=1" alt="SonarLint connected mode" class="wp-image-2509" width="560" height="299" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-quality.jpg 1725w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-quality-300x161.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-quality-1024x549.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-quality-768x411.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-quality-1536x823.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-quality-785x420.jpg 785w" sizes="auto, (max-width: 560px) 100vw, 560px" /><figcaption><br></figcaption></figure>



<ul class="wp-block-list"><li>Provide Server <strong>URL </strong>and <strong>Password </strong>or <strong>Token </strong>to connect with sonar server from IDE,</li></ul>



<p></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-configuration-1.jpg?fit=785%2C398&amp;ssl=1" alt="SonarLint  .NET configuration " class="wp-image-2511" width="556" height="282" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-configuration-1.jpg 1823w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-configuration-1-300x152.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-configuration-1-1024x519.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-configuration-1-768x389.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-configuration-1-1536x779.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-configuration-1-785x398.jpg 785w" sizes="auto, (max-width: 556px) 100vw, 556px" /></figure>



<p></p>



<p>After successful authentication, please select your organization.</p>



<p></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="564" height="521" src="https://www.thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-1-1.jpg" alt="SonarQube Visual studio configuration" class="wp-image-2559" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-1-1.jpg 564w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-1-1-300x277.jpg 300w" sizes="auto, (max-width: 564px) 100vw, 564px" /></figure>



<p></p>



<p>Your application will be connected.</p>



<p></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1395" height="466" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-3.jpg?fit=785%2C262&amp;ssl=1" alt="Sonar C# code quality " class="wp-image-2561" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-3.jpg 1395w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-3-300x100.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-3-1024x342.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-3-768x257.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-3-785x262.jpg 785w" sizes="auto, (max-width: 1395px) 100vw, 1395px" /></figure>



<p></p>



<p>Establish the Sonar Server connection for the first time. Please click on &#8220;<strong>Bind</strong>&#8221; as shown below,</p>



<p></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1659" height="874" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-binding-1.jpg?fit=785%2C413&amp;ssl=1" alt="SonarQube .NET " class="wp-image-2562" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-binding-1.jpg 1659w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-binding-1-300x158.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-binding-1-1024x539.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-binding-1-768x405.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-binding-1-1536x809.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-binding-1-785x414.jpg 785w" sizes="auto, (max-width: 1659px) 100vw, 1659px" /></figure>



<p></p>



<p>After successful binding, Quality profiles from Sonar Server  will be downloaded locally in your projects which includes ruleset file and creation of <strong><em>.sonarlint</em></strong> folder as shown below,</p>



<p></p>



<ul class="wp-block-list"><li>Sonar rule set file will be created within project folder (.csproj)</li></ul>



<p></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-bind-quality-profile.jpg?fit=785%2C274&amp;ssl=1" alt="Code Quality of .NET with SonarQube" class="wp-image-2515" width="557" height="194" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-bind-quality-profile.jpg 2203w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-bind-quality-profile-300x105.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-bind-quality-profile-1024x357.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-bind-quality-profile-768x268.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-bind-quality-profile-1536x535.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-bind-quality-profile-2048x714.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-c-sonar-server-connection-bind-quality-profile-785x274.jpg 785w" sizes="auto, (max-width: 557px) 100vw, 557px" /></figure>



<p></p>



<ul class="wp-block-list"><li>Folder &#8216;.<strong>sonarlint</strong>&#8216; will be created with ruleset file and configuration file as below,</li></ul>



<p></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="https://i2.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-visual-studio-quality-profile.jpg?fit=785%2C295&amp;ssl=1" alt="Code Quality of .NET with SonarQube" class="wp-image-2516" width="555" height="208" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-visual-studio-quality-profile.jpg 2203w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-visual-studio-quality-profile-300x113.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-visual-studio-quality-profile-1024x385.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-visual-studio-quality-profile-768x289.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-visual-studio-quality-profile-1536x577.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-visual-studio-quality-profile-2048x770.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-code-quality-visual-studio-quality-profile-785x295.jpg 785w" sizes="auto, (max-width: 555px) 100vw, 555px" /></figure>



<p></p>



<p>That&#8217;s all! Once the project gets connected with the server, Your project will work in connected mode using the same Quality profiles as of Sonar Server.</p>



<p></p>



<p>You will be able to see the same coding issues in IDE and in Pipeline and analyze your code against centralized configured rules.</p>



<p></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-quality-server-desktop.jpg?fit=785%2C235&amp;ssl=1" alt="Code Quality of .NET C# with SonarQube" class="wp-image-2517" width="621" height="185" srcset="https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-quality-server-desktop.jpg 2560w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-quality-server-desktop-300x90.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-quality-server-desktop-1024x306.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-quality-server-desktop-768x229.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-quality-server-desktop-1536x458.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-quality-server-desktop-2048x611.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2019/04/sonarlint-connected-mode-code-quality-server-desktop-785x234.jpg 785w" sizes="auto, (max-width: 621px) 100vw, 621px" /></figure>



<p></p>



<p>Happy coding !!</p>



<p></p>



<p style="font-size:18px">Do you have any <strong>comments or ideas or any better </strong>suggestions to share?</p>



<p class="has-small-font-size"></p>



<p style="font-size:18px">Please sound off your comments below.</p>



<p class="has-medium-font-size"></p>



<p class="has-medium-font-size"><strong>Happy Coding </strong>!!</p>



<p></p>



<p></p>



<p><strong><em>Other References :</em></strong></p>



<p></p>



<ul class="wp-block-list"><li><a href="https://www.thecodebuzz.com/static-code-quality-analysis-ndepend/" target="_blank" rel="noreferrer noopener" title="Continuous Code Quality using NDepend"><strong><em>Continuous Code Quality using NDepend</em></strong></a></li></ul>



<ul class="wp-block-list"><li><a href="https://www.thecodebuzz.com/continuous-code-quality-in-angular-7-applications-using-sonar/" target="_blank" rel="noreferrer noopener"><strong><em>Continuous Code Quality of Angular, React or Vue.js applications using Sonar</em></strong></a></li></ul>



<p></p>



<h4 class="wp-block-heading" id="aioseo-summary">Summary : </h4>



<p></p>



<p>Today we learned about SonarLint extension set up and configuration for Visual Studio IDE. Good coding practices are language agnostics and help the organization to deliver clean, reliable, secure, and maintainable code. Buggy code slipping through cracks has the potential to cost a company an entire business. </p>



<p>Organizations can address these problems by following best practices of software development like continuous code quality and continuous code review processes.</p>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p>



<p></p><p>The post <a href="https://thecodebuzz.com/continuous-code-quality-of-using-sonar/">Continuous Code Quality of .NET with SonarQube</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/continuous-code-quality-of-using-sonar/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Awesome Code &#8211; Feature Envy Code Smell Resolutions</title>
		<link>https://thecodebuzz.com/awesome-code-feature-envy-code-smell-resolution/</link>
					<comments>https://thecodebuzz.com/awesome-code-feature-envy-code-smell-resolution/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 01 Mar 2022 00:00:00 +0000</pubDate>
				<category><![CDATA[Code Smell]]></category>
		<category><![CDATA[Awesome Code – Feature Envy Code Smell Resolutions]]></category>
		<category><![CDATA[checkstyle tool code smell]]></category>
		<category><![CDATA[code smells]]></category>
		<category><![CDATA[code smells examples]]></category>
		<category><![CDATA[data clumps code smell]]></category>
		<category><![CDATA[feature envy wikipedia]]></category>
		<category><![CDATA[inappropriate intimacy code smell example]]></category>
		<category><![CDATA[primitive obsession code smell]]></category>
		<category><![CDATA[shotgun surgery code smell]]></category>
		<guid isPermaLink="false">https://thecodebuzz.com/?p=4908</guid>

					<description><![CDATA[<p>Feature Envy Code Smell Resolution with examples Today in this article, we will see Feature Envy Code Smell Resolution with examples. Methods used in the application could be used to expose the internal or inner workings of other classes. That means a feature in a class may be using too much functionality from the feature [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/awesome-code-feature-envy-code-smell-resolution/">Awesome Code – Feature Envy Code Smell Resolutions</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading"><strong>Feature Envy Code Smell Resolution with examples</strong></h1>



<figure class="wp-block-image is-resized"><a href="https://www.thecodebuzz.com/awesome-code-feature-envy-code-smell-resolution" target="_blank" rel="noopener"><img loading="lazy" decoding="async" src="https://i2.wp.com/thecodebuzz.com/wp-content/uploads/2019/08/Feature-envy-and-inappropriate-Intimacy-Code-smell-resoltion-1.jpg?fit=785%2C303&amp;ssl=1" alt="Feature Envy" class="wp-image-4976" width="515" height="198" srcset="https://thecodebuzz.com/wp-content/uploads/2019/08/Feature-envy-and-inappropriate-Intimacy-Code-smell-resoltion-1.jpg 1307w, https://thecodebuzz.com/wp-content/uploads/2019/08/Feature-envy-and-inappropriate-Intimacy-Code-smell-resoltion-1-300x116.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/08/Feature-envy-and-inappropriate-Intimacy-Code-smell-resoltion-1-1024x395.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2019/08/Feature-envy-and-inappropriate-Intimacy-Code-smell-resoltion-1-768x296.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/08/Feature-envy-and-inappropriate-Intimacy-Code-smell-resoltion-1-785x303.jpg 785w" sizes="auto, (max-width: 515px) 100vw, 515px" /></a></figure>



<p>Today in this article, we will see  <strong>Feature Envy Code Smell Resolution with examples</strong>.</p>



<p></p>



<p>Methods used in the application could be used to expose the internal or inner workings of other classes. That means a feature in a class may be using too much functionality from the feature of another class&#8217;s method. When you see such chatty communication from features of different classes there is clear visibility of code smell.</p>



<p></p>



<p>We will cover the below aspects of the article,</p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-characteristics-of-feature-envy-smell">Characteristics of Feature Envy Smell</a></li><li><a href="#aioseo-cons">Cons</a></li><li><a href="#aioseo-resolutions-techniques">Resolutions techniques</a></li><li><a href="#aioseo-move-methods">Move Methods</a></li><li><a href="#aioseo-example-with-feature-envy-smell">Examples &#8211; Feature Envy smell</a></li><li><a href="#aioseo-feature-envy-smell-resolution">Feature Envy smell Resolution</a></li><li><a href="#aioseo-extract-methods">Extract methods</a></li></ul></div>



<p></p>



<p>Feature envy smells come under a category called &#8216;Couplers&#8217;. In our last article, we understood couplers with the smell of Inappropriate Intimacy. Feature envy is similar to Inappropriate Intimacy but here instead of class relationship we talk about features/functions/method coupling.</p>



<p></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p><strong>“Code is maintained more often than it is written”</strong></p></blockquote>



<p></p>



<p>As per the principle of single responsibility, a function or a class should do one task at a time. A class should contain within itself both the behavior and methods (i.e. data).</p>



<p></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p><strong>“Code is read more often than it is written”</strong><br></p></blockquote>



<p>In object-oriented programming, there are multiple means of making classes that can interact with each other like using composition, aggregation, and inheritance. and transfer data to and from each other ultimately achieving required business functionality.</p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-characteristics-of-feature-envy-smell">Characteristics of Feature Envy Smell</h2>



<p></p>



<ul class="wp-block-list"><li> A classic example could be where you sight a &#8216;method at the wrong place&#8217;.</li><li>The class uses a significant number of methods and fields of other Classes (being used more than the class where it is defined)</li><li>A properties /fields of a class are used by/in other class&#8217;s features (more than in the class where it is defined).</li><li>A method being used to expose internal of other classes.</li></ul>



<p></p>



<h2 class="wp-block-heading" id="aioseo-cons">Cons</h2>



<p></p>



<ul class="wp-block-list"><li>High maintenance.</li><li>Difficult to enhance/extend features.</li><li>Demote readability and hard to understand.</li></ul>



<p></p>



<h2 class="wp-block-heading" id="aioseo-resolutions-techniques">Resolutions techniques </h2>



<p></p>



<ul class="wp-block-list"><li>Move Methods</li><li>Move Fields</li><li>Extract Method</li></ul>



<p></p>



<p>Let’s look at each code recipe with examples in detail,</p>



<p></p>



<h2 class="wp-block-heading" id="aioseo-move-methods">Move Methods</h2>



<p></p>



<ul class="wp-block-list"><li>Move methods to the right place</li><li>Move tangled code to own methods</li></ul>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="https://i1.wp.com/thecodebuzz.com/wp-content/uploads/2019/08/Inappropriate-Intimacy-Code-Smell-C-sharp-examples-move-methods-1.jpg?fit=785%2C708&amp;ssl=1" alt="Feature Envy Code Smell " class="wp-image-4924" width="447" height="402" srcset="https://thecodebuzz.com/wp-content/uploads/2019/08/Inappropriate-Intimacy-Code-Smell-C-sharp-examples-move-methods-1.jpg 1025w, https://thecodebuzz.com/wp-content/uploads/2019/08/Inappropriate-Intimacy-Code-Smell-C-sharp-examples-move-methods-1-300x270.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2019/08/Inappropriate-Intimacy-Code-Smell-C-sharp-examples-move-methods-1-768x692.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2019/08/Inappropriate-Intimacy-Code-Smell-C-sharp-examples-move-methods-1-577x520.jpg 577w" sizes="auto, (max-width: 447px) 100vw, 447px" /></figure>



<p></p>



<h2 class="wp-block-heading" id="aioseo-example-with-feature-envy-smell">Examples &#8211; Feature Envy smell</h2>



<p></p>



<p>Here we will use the same example as we used for the resolution of code smell -Inappropriate Intimacy,  </p>



<p></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
namespace FeatureEnvySmell
{

    class ContactInfo
    {
        public string GetStreetName()
        {
            return &quot;1 Medison Square&quot;;
        }
        public string GetCity()
        {
            return &quot;NewYork&quot;;
        }
        public string GetState()
        {
            return &quot;NY&quot;;
        }
    }

    class User
    {
        private ContactInfo _contactInfo;

        User(ContactInfo contactInfo)
        {
            _contactInfo = contactInfo;
        }
        public string GetFullAddress(ContactInfo info)
        {
            string city = info.GetCity();//1
            string state = info.GetState();//2
            string streetName = info.GetStreetName();//3
            return streetName + &quot;;&quot; + city + &quot;;&quot; + state;
        }
    }
}

</pre></div>


<p></p>



<h2 class="wp-block-heading" id="aioseo-feature-envy-smell-resolution">Feature Envy smell Resolution</h2>



<p></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
namespace FeatureEnvySmellResolved
{

    class ContactInfo
    {
        public string GetStreetName()
        {
            return &quot;1 Medison Square&quot;;
        }
        public string GetCity()
        {
            return &quot;NewYork&quot;;
        }
        public string GetState()
        {
            return &quot;NY&quot;;
        }
        public string GetFullAddress(ContactInfo info)
        {
            string city = info.GetCity();//1
            string state = info.GetState();//2
            string streetName = info.GetStreetName();//3
            return streetName + &quot;;&quot; + city + &quot;;&quot; + state;
        }
    }

    class User
    {
        private ContactInfo _contactInfo;
        User(ContactInfo contactInfo)
        {
            _contactInfo = contactInfo;
        }
    }
}


</pre></div>


<p></p>



<h2 class="wp-block-heading" id="aioseo-extract-methods">Extract methods</h2>



<p></p>



<p>Each method should do one task at a time.</p>



<p>I shall share an example of this technique for the same soon in my next article soon.</p>



<p></p>



<p style="font-size:18px">Do you have any <strong>comments or ideas or any better </strong>suggestions to share?</p>



<p class="has-small-font-size"></p>



<p style="font-size:18px">Please sound off your comments below.</p>



<p class="has-medium-font-size"></p>



<p class="has-medium-font-size"><strong>Happy Coding </strong>!!</p>



<p></p>



<p></p>



<hr>



<p class=""></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2025) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class=""></p>



<p></p>



<p></p><p>The post <a href="https://thecodebuzz.com/awesome-code-feature-envy-code-smell-resolution/">Awesome Code – Feature Envy Code Smell Resolutions</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/awesome-code-feature-envy-code-smell-resolution/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
