SONARJAVA-6687 S2129 Java: add BigDecimal(String) to exceptions - #6052
SONARJAVA-6687 S2129 Java: add BigDecimal(String) to exceptions#6052asya-vorobeva wants to merge 1 commit into
Conversation
| <p><code>BigDecimal</code> constructor with a <code>String</code> argument is also ignored because <code>BigDecimal.valueOf</code> does not accept a | ||
| <code>String</code>, leaving no equivalent alternative.</p> |
There was a problem hiding this comment.
⚠️ Quality: Rule description edited in generated (RSPEC-sourced) folder
S2129.html lives in sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java, whose README states the files are generated from RSPEC and that PRs modifying descriptions there will be rejected; sonarpedia.json points rule-api at this same directory. Editing the HTML directly means the new Exceptions paragraph is silently reverted the next time rule metadata is regenerated by rule-api (which also bumps latest-update — unchanged in this diff). The wording change should be made in RSPEC and pulled in via a rule-api metadata update instead of hand-editing the generated file.
Was this helpful? React with 👍 / 👎
| <h3>Exceptions</h3> | ||
| <p><code>BigDecimal</code> constructor with a <code>double</code> argument is ignored as using <code>valueOf</code> instead might change the resulting | ||
| value. See {rule:java:S2111}.</p> | ||
| <p><code>BigDecimal</code> constructor with a <code>String</code> argument is also ignored because <code>BigDecimal.valueOf</code> does not accept a | ||
| <code>String</code>, leaving no equivalent alternative.</p> |
There was a problem hiding this comment.
💡 Quality: Exceptions list implies non-double/String BigDecimal ctors are flagged
StringPrimitiveConstructorCheck's matchers contains no BigDecimal entry at all, so no BigDecimal constructor is ever reported (e.g. new BigDecimal(42L), for which BigDecimal.valueOf(long) does exist, raises nothing). By listing only the double and String overloads as exceptions while the title and intro keep advertising BigDecimal as a flagged class, the updated description tells users that the remaining overloads are reported, which they are not. Either state that all BigDecimal constructors are ignored or drop BigDecimal from the title/intro claim.
Was this helpful? React with 👍 / 👎
BigDecimal.valueOf has no String overload, so new BigDecimal(String) has no equivalent alternative and should not be flagged.
142b08b to
c020dba
Compare
Code Review
|
| Auto-apply | Compact | Unblock |
|
|
|
Was this helpful? React with 👍 / 👎 | Gitar
|





BigDecimal.valueOf has no String overload, so new BigDecimal(String) has no equivalent alternative and should not be flagged.