In many rules, we want the string value of an expression. We always support the simple case, when the expression is directly a string literal:
However, it is not rare to have an identifier referring to a final String instead of the literal:
Currently, we are not supporting this situation in many rules despite the fact that we have all the tools to support this with very little effort.
More specifically, in addition to supporting string literals, this will add the support for:
- identifier referring to static final variable in the same file
- identifier referring to static final variable in another file/dependency
- text block, once
Rules that could benefit from this improvement:
An issue will already be reported for the variable declaration, no need to report it a second time.
The typical pattern used in these rules is:
Simply changing this code to:
will have the same behavior with the advantages described above.