Suppress/disable some Eclipse unnecessary-code warnings in test code

Often the easiest way to create a desired test scenario is to write
code that would make no sense in a complete, realistic application.
So we generally want to let test code do oddball things.
This commit is contained in:
Ben Liblit 2017-03-28 18:57:24 -05:00
parent 5f23949d9f
commit 91b9c9e28b
5 changed files with 5 additions and 1 deletions

View File

@ -104,7 +104,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.7

View File

@ -9,6 +9,7 @@
* IBM Corporation - initial API and implementation
*****************************************************************************/
public class CastFromNull {
@SuppressWarnings({ "cast", "unused" })
public static void main(String args[]) {
new CastFromNull();
Object x = (Object) null;

View File

@ -38,6 +38,7 @@
package foo.bar.hello.world;
public class LoopsAndLabels {
@SuppressWarnings({ "cast", "unused" })
public static void main(String args[]) {
aaa: do {

View File

@ -39,6 +39,7 @@ package foo.bar.hello.world;
public class Misc {
@SuppressWarnings({ "cast", "unused" })
public static void main(String args[]) {
if ( "hello" instanceof Object ) {
System.out.println("strings are objects in java");

View File

@ -86,6 +86,7 @@ class Outer {
}
class Outer2 {
@SuppressWarnings("unused")
class Middle<S> {
class Inner<T> {
}