Skip to content

Commit

Permalink
Replace + does not support expressions in exceptions #51
Browse files Browse the repository at this point in the history
  • Loading branch information
markiewb committed Mar 19, 2015
1 parent 517d5f6 commit 9b8d9f8
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 145 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@
<li>[<a href="https://github.com/markiewb/nb-additional-hints/issues/42">Updated Fix</a>]: "Convert to if/else" now supports assignments to new variables</li>
<li>[<a href="https://github.com/markiewb/nb-additional-hints/issues/43">Updated Fix</a>]: "Invert ternary"/"Convert to ternary" now support conditions without brackets</li>
<li>[<a href="https://github.com/markiewb/nb-additional-hints/issues/3">Updated Fix</a>]: "Replace +..." is not proposed for erroneous conditions anymore</li>
<li>[<a href="https://github.com/markiewb/nb-additional-hints/issues/51">Updated Fix</a>]: "Replace +..." works for more expressions</li>
<li>[<a href="https://github.com/markiewb/nb-additional-hints/issues/50">Updated Fix</a>]: Remove false positive detected by "Detect dead instanceof"</li>
<li>[<a href="https://github.com/markiewb/nb-additional-hints/issues/56">New Fix</a>]: Replace with Optional.isPresent()/Convert return null to return Optional.empty()</li>
<li>[Task]: Update requirements JDK7 and NB7.4</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,18 @@ public ErrorDescription run(Config config) {
* <pre>String foo; foo="B"+42;</pre>
*/
final boolean isAssignment = checkParentKind(treePath, 1, Kind.ASSIGNMENT);
/**
* <pre>throw new RuntimeException("B"+42)</pre>
*/
final boolean isNewClass = checkParentKind(treePath, 1, Kind.NEW_CLASS);

//ignore errornous expressions "a"+42+"b"; with no assignment
/**
* https://github.com/markiewb/nb-additional-hints/issues/3
* Detecting erroneous expressions via Kind.ERRONEOUS seems not to
* work so we use a whitelist here instead.
*/
if (!isMethodInvocation && !isVariableAssignment && !isAssignment) {
if (!isMethodInvocation && !isVariableAssignment && !isAssignment && !isNewClass) {
return null;
}

Expand Down
Loading

0 comments on commit 9b8d9f8

Please sign in to comment.