# Have a rule apply to a particular Java submodule

**URL:** <https://community.sonarsource.com/t/have-a-rule-apply-to-a-particular-java-submodule/59205>\
**Category:** Writing rules\
**Tags:** modules, custom\_rules, sonarqube, java\
**Created:** [March 2, 2022, 12:44pm UTC](https://community.sonarsource.com/t/have-a-rule-apply-to-a-particular-java-submodule/59205 "2022-03-02T12:44:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![murilophilips](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/murilophilips/32/30822_2.png) [@murilophilips](https://community.sonarsource.com/u/murilophilips)\
**Post date:** [March 2, 2022, 12:44pm UTC](https://community.sonarsource.com/t/have-a-rule-apply-to-a-particular-java-submodule/59205/1 "2022-03-02T12:44:38Z")

</div>

Hi,  
I have a custom rule we built for a particular project that works correctly. However, as the project is expanding, we need it to apply only to classes inside a specific module.  
Right now it seems to me the rule is a very little modified copy of the tutorial rule, using a rulesDefinition implementation to add the check to be enforced to all classes. But I just want it to apply to classes in a module I wish to name. I couldn’t find an example like that, can anyone point me to a sample that does that?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [March 3, 2022, 1:25pm UTC](https://community.sonarsource.com/t/have-a-rule-apply-to-a-particular-java-submodule/59205/2 "2022-03-03T13:25:38Z")

</div>

Hey there.

Instead of trying to craft logic inside the rule to skip other modules, I would reccomend checking the documentation on [Narrowing the Focus \> Ignore Issue \> Restrict Scope of Coding Rules](https://docs.sonarqube.org/latest/project-administration/narrowing-the-focus/#header-5)
