# @RuleProperty in a custom language

**URL:** <https://community.sonarsource.com/t/ruleproperty-in-a-custom-language/144698>\
**Category:** Rules and Languages\
**Tags:** custom\_plugin, configuration\
**Created:** [July 18, 2025, 3:43pm UTC](https://community.sonarsource.com/t/ruleproperty-in-a-custom-language/144698 "2025-07-18T15:43:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![christian.jacob](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@christian.jacob](https://community.sonarsource.com/u/christian.jacob)\
**Post date:** [July 18, 2025, 3:43pm UTC](https://community.sonarsource.com/t/ruleproperty-in-a-custom-language/144698/1 "2025-07-18T15:43:43Z")

</div>

Hi all, I have implemented a custom language with a bunch of custom rules. In one of these rules, I wanted to have a limit configurable. So I added this to my rule:

```java
    private static final String DEFAULT_MAX_ALLOWED_STR = "25";

    @RuleProperty(
            key = "limit",
            description = "maximum number of allowed steps within a scenario",
            defaultValue = DEFAULT_MAX_ALLOWED_STR)
    public String maxAllowedStr = DEFAULT_MAX_ALLOWED_STR;

```

However, that parameter is not shown in the frontend, and it cannot be configured in a quality profile. What else do I need to do?

---

<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:** [July 19, 2025, 8:17am UTC](https://community.sonarsource.com/t/ruleproperty-in-a-custom-language/144698/2 "2025-07-19T08:17:55Z")

</div>

I’ve done exactly as you have and the rule parameter shows up when I browse the rule in my SQ instance.

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/8/9/8910c644b430cf24f5d5d7883ae4800680ab2906.png)

What do you see? What version of SonarQube are you using?

---

<div class="post-metadata">

**Author:** ![christian.jacob](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@christian.jacob](https://community.sonarsource.com/u/christian.jacob)\
**Post date:** [July 21, 2025, 6:13am UTC](https://community.sonarsource.com/t/ruleproperty-in-a-custom-language/144698/3 "2025-07-21T06:13:04Z")

</div>

After clicking on the “Change” button:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/4/9/490c577fae5db54cee8c3a2bc06e14688ea265a2.png)

I don’t see anything of the rule:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/6/8/682c20ea0b7dc981f161a3550d5f9bc2cc7d32f6.png)

The version of my SonarQube server is

- Community Build
- v25.7.0.110598
- MQR Mode

---

<div class="post-metadata">

**Author:** ![christian.jacob](https://avatars.discourse-cdn.com/v4/letter/c/4491bb/32.png) [@christian.jacob](https://community.sonarsource.com/u/christian.jacob)\
**Post date:** [July 21, 2025, 6:42am UTC](https://community.sonarsource.com/t/ruleproperty-in-a-custom-language/144698/4 "2025-07-21T06:42:34Z")

</div>

I eventually found out after some inspection of the Sonar code. For some other reasons, I had to set up the repositoy myself and fill the rules. In that, I had to add these methods:

```java

    private void loadField(Field field, NewRule newRule) {
        RuleProperty ruleProperty = field.getAnnotation(RuleProperty.class);
        if (ruleProperty != null) {
            String fieldKey = StringUtils.defaultIfEmpty(ruleProperty.key(), field.getName());
            String defaultValue = ruleProperty.defaultValue();
            NewParam param = newRule.createParam(fieldKey)
                    .setDescription(ruleProperty.description())
                    .setDefaultValue(defaultValue);
            String propertyType = ruleProperty.type();
            RuleParamType ruleParamType = ruleParamType(propertyType);
            param.setType(ruleParamType);
            logger.info("added rule property \"{}\" default-value \"{}\" type {}", fieldKey, defaultValue, ruleParamType);
        }
    }

    private RuleParamType ruleParamType(String source) {
        RuleParamType result;
        if (!StringUtils.isBlank(source)) {
            result = RuleParamType.parse(source);
        } else {
            result = RuleParamType.STRING;
        }
        return result;
    }

```

---

<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:** [July 28, 2025, 6:43am UTC](https://community.sonarsource.com/t/ruleproperty-in-a-custom-language/144698/5 "2025-07-28T06:43:20Z")

</div>

Closed on July 28, 2025, 6:43am UTC

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