How to Deactivate a Rule in SonarQube

How to Deactivate a Rule in SonarQube

16 July 2024 Stephan Petzl Leave a comment QA

Deactivating a rule in SonarQube can be a bit tricky if you are not familiar with the process. This guide will walk you through the steps needed to successfully deactivate a rule in SonarQube, ensuring that your changes are applied correctly.

Steps to Deactivate a Rule

  1. Go to Quality Profiles: Log in to your SonarQube instance and navigate to the “Quality Profiles” section.
  2. Create a New Profile: Select the profile you want to modify and create a new copy of this profile. This step is necessary as SonarQube does not allow modifications to the root profile.
    • If you have already created a custom profile, you can skip this step and proceed to the next one.
  3. Modify the New Profile: Select your new profile and make the desired changes. You can deactivate rules by unchecking the corresponding boxes.
  4. Set as Default: Ensure that you set your new profile as the default profile.

Verification

After making these changes, it is important to verify that the rule has been deactivated successfully. You can do this by running the SonarQube scanner again to see if the modifications are reflected.

Alternative Method for Newer Versions of SonarQube

If you are using a newer version of SonarQube (e.g., version 6.7.4), you can use the following method:

  1. Go to http://localhost:9000/admin/settings?category=exclusions
  2. Scroll to the “Ignore Issues on Multiple Criteria” section
  3. Add the Rule Key Pattern and File Path Pattern
  4. Save your changes and re-scan your project

Conclusion

By following these steps, you should be able to deactivate any rule in SonarQube effectively. This will help you maintain a clean and relevant set of rules for your code quality checks.

If you are looking for a more streamlined and efficient way to manage quality assurance for your mobile applications, consider using Repeato. Repeato is a No-code test automation tool for iOS and Android that leverages computer vision and AI to create, run, and maintain automated tests. Its simplicity in setup and use makes it a great choice for ensuring high-quality standards in your mobile development projects.

For more information, visit our documentation and blog pages.

Like this article? there’s more where that came from!