[java] AvoidPrintStackTrace - fix tests and deprecation warning

This commit is contained in:
Andreas Dangel
2020-05-22 20:19:45 +02:00
parent 4899d04cb3
commit d21e309043
2 changed files with 11 additions and 6 deletions

View File

@ -188,7 +188,7 @@ Avoid printStackTrace(); use a logger call instead.
//PrimaryExpression[ //PrimaryExpression[
( PrimaryPrefix[Name[contains(@Image,'printStackTrace')]] ( PrimaryPrefix[Name[contains(@Image,'printStackTrace')]]
| PrimarySuffix[@Image='printStackTrace'] | PrimarySuffix[@Image='printStackTrace']
)/following-sibling::*[1][self::PrimarySuffix/Arguments[@ArgumentCount=0]] )/following-sibling::*[1][self::PrimarySuffix/Arguments[@Size=0]]
] ]
]]> ]]>
</value> </value>

View File

@ -7,7 +7,7 @@
<test-code> <test-code>
<description>simple failure</description> <description>simple failure</description>
<expected-problems>1</expected-problems> <expected-problems>1</expected-problems>
<expected-linenumbers>4</expected-linenumbers> <expected-linenumbers>5</expected-linenumbers>
<code><![CDATA[ <code><![CDATA[
public class Foo { public class Foo {
void bar() { void bar() {
@ -38,10 +38,12 @@ public class Foo {
<test-code> <test-code>
<description>pos in call chain #2437</description> <description>pos in call chain #2437</description>
<expected-problems>1</expected-problems> <expected-problems>1</expected-problems>
<expected-linenumbers>5</expected-linenumbers>
<code><![CDATA[ <code><![CDATA[
public class Foo { public class Foo {
void bar() { void bar() {
try {} catch (Exception e) { try {
} catch (Exception e) {
e.getCause().printStackTrace(); e.getCause().printStackTrace();
} }
} }
@ -55,7 +57,8 @@ public class Foo {
<code><![CDATA[ <code><![CDATA[
public class Foo { public class Foo {
void bar() { void bar() {
try {} catch (Exception e) { try {
} catch (Exception e) {
e.getCause().printStackTrace; e.getCause().printStackTrace;
} }
} }
@ -69,7 +72,8 @@ public class Foo {
<code><![CDATA[ <code><![CDATA[
public class Foo { public class Foo {
void bar() { void bar() {
try {} catch (Exception e) { try {
} catch (Exception e) {
e.printStackTrace; e.printStackTrace;
} }
} }
@ -83,7 +87,8 @@ public class Foo {
<code><![CDATA[ <code><![CDATA[
public class Foo { public class Foo {
void bar() { void bar() {
try {} catch (Exception e) { try {
} catch (Exception e) {
e.printStackTrace(e); e.printStackTrace(e);
} }
} }