Sonarlint helps the developers to identify the issues on the fly when you write the code immediately. It helps to detect the common mistakes and vulnerabilities based on the thousands of rules in various languages such as Java,Javascript,PHP and PHP . It also helps to scan the source code in different IDE’s such as Eclipse IDE,Intellij IDEA,Visual Studio and VS Code. Please find the list of Sonarlint rules from the link mentioned below:
Vulnerability Examples:
Its a weakness in the code, which can be exploited by an actor to perform unauthorized actions within a computer system.
“public static” fields should be constant:
Noncompliant Code Example:
1 2 3 4 5 |
public class TotalQA{ public static ClassA a1 = new ClassA(); } |
Compliant Code Example:
1 2 3 |
public class TotalQA{ public static final ClassA a1 = new ClassA(); } |
Bug Example:
Loops should not be infinite:
Noncompliant Code Example:
1 2 3 |
for (;;) { // Noncompliant; end condition omitted // ... } |
Code Smells:
Nothing but the violation of the Fundamental Design Principals.
Tests Should include Assertions:
Noncompliant Code Example:
1 2 3 4 5 6 |
public void verityTitle() { WebDriver driver = new ChromeDriver(); driver.get("http://www.total-qa.com"); driver.getTitle(); } |
default Clauses should be last in the Switch Case
1 2 3 4 5 6 7 8 9 |
switch (param) { case 0: break; default: error(); break; case 1: break; } |
1 2 3 4 5 6 7 8 |
switch (param) { case 0: break; case 1: break; default: break; } |
Using Sonarlint in Eclipse:
Download the Sonarlint Plugin from the Eclipse Market Place. During the Development of the Code, the Sonarlint highlights the issues in the editor. It also gives the rule description on the the fly.Once the plugin is installed successfully. Open the Eclipse and write a sample program to verify the rules.
Analyze the Java Source Code using Sonarlint:
Click on the rule to view the Rule Description
Enable the rules in Sonarlint:
Navigate to the Window->Preferences->Sonarlint->Rules Configuration to select the rule configuration for different languages.
Conclusion:
Sonarlint plugin in Eclipse enables the Developers to identify the issues early in the Coding phase to fix the issues during the time of development and fix them on the fly with Compliant Solution.
Do you want more people to visit your website? Get tons of people who are ready to buy sent directly to your website. Boost your profits super fast. Start seeing results in as little as 48 hours. To get info reply to: florence3145hod@gmail.com