# Custom rules with Sonar plugin

**URL:** <https://community.sonarsource.com/t/custom-rules-with-sonar-plugin/128971>\
**Category:** Plugin Development\
**Tags:** custom\_rules, sonarqube, java\
**Created:** [October 24, 2024, 2:15pm UTC](https://community.sonarsource.com/t/custom-rules-with-sonar-plugin/128971 "2024-10-24T14:15:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabriel.linero](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/gabriel.linero/32/63366_2.png) [@gabriel.linero](https://community.sonarsource.com/u/gabriel.linero)\
**Post date:** [October 24, 2024, 2:15pm UTC](https://community.sonarsource.com/t/custom-rules-with-sonar-plugin/128971/1 "2024-10-24T14:15:49Z")

</div>

Looking at the documentation, there is limited options for custom rules using XPath rules and most of the languages support the creation via plugins

> **[Adding coding rules](https://docs.sonarsource.com/sonarqube/9.9/extension-guide/adding-coding-rules/#adding-coding-rules-using-java)**
>
> How to add custom coding rules to your SonarQube analysis.

This is the first time I try to customise my own plugin in order to add custom rules and I wanted to know if there are recommendations on how to approach it.

- When adding a plugin with custom rules, do the rules directly appear in the rules and quality profile section?
- Are there specific naming conventions that should be followed when it comes to adding rules?
- If we are potentially going to have several custom rules required by different teams, should we capture all of them under the same plugin?  
Thanks!!!

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [October 25, 2024, 3:12pm UTC](https://community.sonarsource.com/t/custom-rules-with-sonar-plugin/128971/2 "2024-10-25T15:12:18Z")

</div>

Hi,

There’s a tutorial for writing rules for Java:

> <https://github.com/SonarSource/sonar-java/blob/master/docs/CUSTOM_RULES_101.md>

&nbsp;  
HTH,  
Ann

---

<div class="post-metadata">

**Author:** ![gabriel.linero](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/gabriel.linero/32/63366_2.png) [@gabriel.linero](https://community.sonarsource.com/u/gabriel.linero)\
**Post date:** [October 30, 2024, 4:43pm UTC](https://community.sonarsource.com/t/custom-rules-with-sonar-plugin/128971/3 "2024-10-30T16:43:03Z")

</div>

That’s pretty handy information. Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [November 6, 2024, 4:43pm UTC](https://community.sonarsource.com/t/custom-rules-with-sonar-plugin/128971/4 "2024-11-06T16:43:13Z")

</div>

Closed on November 6, 2024, 4:43pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
