Open Catoons opened 3 months ago
Update: I was able to implement this on a fork by changing line 61 of ForbiddenValueCheck.java to addViolation("Forbidden value " + value + " found in " + keyName, t);
Note that the forbidden value appears as however you put it in as regex, but I think it's still helpful overall, and I imagine there's a way to fix this. At the very least, the key it's found in appears as you'd want and makes the warnings a lot more helpful at a glance. @sbaudoin You're welcome to implement these changes or something similar.
Here's an example of what it looks like:
As a reminder, it previously would say: "Forbidden value found"
While the other custom rule templates give helpful issue messages, the message for "ForbiddenValueCheck" is not very helpful. All violations of that rule appear in SonarQube with the title "Forbidden value found". I believe the relevant code is
addViolation("Forbidden value found", t);
in line 61 of src/main/java/com/github/sbaudoin/sonar/plugins/yaml/checks/ForbiddenValueCheck.javaI think this should be changed to fit more closely with the other custom rule templates. For example, any violations of the RequiredKeyCheck appear in SonarQube with the title: "Required [requiredKeyName] key not found". This is helpful as you can understand the issue with a glance. I believe this is coded as
addViolation("Required " + requiredKeyName + " key not found");
on line 205 of src/main/java/com/github/sbaudoin/sonar/plugins/yaml/checks/RequiredKeyCheck.javaThe ideal final output would probably be something like: "Forbidden value [forbidden value] found in [forbidden value's key]"