Merge branch 'pr/3739' into 7.0.x
This commit is contained in:
@ -206,6 +206,7 @@
|
||||
<rule ref="category/java/errorprone.xml/DoNotCallGarbageCollectionExplicitly"/>
|
||||
<rule ref="category/java/errorprone.xml/DoNotExtendJavaLangThrowable"/>
|
||||
<rule ref="category/java/errorprone.xml/DoNotHardCodeSDCard"/>
|
||||
<rule ref="category/java/errorprone.xml/DoNotTerminateVM"/>
|
||||
<rule ref="category/java/errorprone.xml/DoNotThrowExceptionInFinally"/>
|
||||
<rule ref="category/java/errorprone.xml/DontImportSun"/>
|
||||
<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices"/>
|
||||
|
@ -1327,11 +1327,11 @@ This rule was called *DoNotCallSystemExit* until PMD 6.29.0.
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//Name[
|
||||
starts-with(@Image,'System.exit')
|
||||
or
|
||||
(starts-with(@Image,'Runtime.getRuntime') and ../../PrimarySuffix[ends-with(@Image,'exit') or ends-with(@Image,'halt')])
|
||||
][not(ancestor::MethodDeclaration[1][@Name="main" and @Static = true()])]
|
||||
//(MethodDeclaration[@MainMethod = false()] | Initializer)//MethodCall[
|
||||
pmd-java:matchesSig("java.lang.System#exit(int)")
|
||||
or pmd-java:matchesSig("java.lang.Runtime#exit(int)")
|
||||
or pmd-java:matchesSig("java.lang.Runtime#halt(int)")
|
||||
]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
|
@ -6,7 +6,6 @@ package net.sourceforge.pmd.lang.java.rule.errorprone;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
@org.junit.Ignore("Rule has not been updated yet")
|
||||
public class DoNotTerminateVMTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
<test-code>
|
||||
<description>basic violations</description>
|
||||
<expected-problems>2</expected-problems>
|
||||
<expected-linenumbers>5,10</expected-linenumbers>
|
||||
<code><![CDATA[
|
||||
public class Bar {
|
||||
|
||||
@ -28,10 +29,14 @@ public class Bar {
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class SystemCall {
|
||||
private App application;
|
||||
public void methode() {
|
||||
// OK
|
||||
application.exit(0);
|
||||
}
|
||||
}
|
||||
abstract class App {
|
||||
void exit(int i);
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
@ -39,6 +44,7 @@ public class SystemCall {
|
||||
<test-code>
|
||||
<description>basic violations with Runtime</description>
|
||||
<expected-problems>2</expected-problems>
|
||||
<expected-linenumbers>4,5</expected-linenumbers>
|
||||
<code><![CDATA[
|
||||
public class Bar {
|
||||
public void foo() {
|
||||
@ -66,6 +72,7 @@ public class SystemCall {
|
||||
<test-code>
|
||||
<description>system exit in anonymous class inside main</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<expected-linenumbers>6</expected-linenumbers>
|
||||
<code><![CDATA[
|
||||
public class SystemCall {
|
||||
public static void main(String[] args) {
|
||||
|
Reference in New Issue
Block a user