Enable findbugs in more artifacts 17/76017/4
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 12 Sep 2018 00:26:19 +0000 (02:26 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 12 Sep 2018 09:28:05 +0000 (11:28 +0200)
This fixed/enables FB warnings in yang-maven-plugin-spi,
yang-parser-spi, yang-test-util and yang-xpath-api,
yang-parser-impl and ang-maven-plugin-it.

Change-Id: I1b9abdbd32f81b16243c111c74143929a573d76e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
13 files changed:
yang/yang-maven-plugin-it/pom.xml
yang/yang-maven-plugin-spi/pom.xml
yang/yang-parser-impl/pom.xml
yang/yang-parser-spi/pom.xml
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StatementSupportBundle.java
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContextUtils.java
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/SourceException.java
yang/yang-test-util/pom.xml
yang/yang-test-util/src/main/java/org/opendaylight/yangtools/yang/test/util/YangParserTestUtils.java
yang/yang-xpath-api/pom.xml
yang/yang-xpath-api/src/main/java/org/opendaylight/yangtools/yang/xpath/api/YangBinaryOperator.java
yang/yang-xpath-api/src/main/java/org/opendaylight/yangtools/yang/xpath/api/YangLocationPath.java
yang/yang-xpath-api/src/main/java/org/opendaylight/yangtools/yang/xpath/api/YangNaryOperator.java

index be141991a23698f3e18df2bc9313ecb978c84f6d..3deeff1046e091af6ab156236a2ddb8637600dd3 100644 (file)
                     <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+                <configuration>
+                    <failOnError>true</failOnError>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 
index cd9d7267d8cd8cacc5dbbf8f77dd952cf6b78353..8d0846082eab3bb84cb8f41072ebeac430518b13 100644 (file)
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+                <configuration>
+                    <failOnError>true</failOnError>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 
index 2036a28338c96e4331acdceb882ca566a8673490..64d6a32a1f88e34a678163ebcf65cae9c6fc4903 100644 (file)
                     <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+                <configuration>
+                    <failOnError>true</failOnError>
+                </configuration>
+            </plugin>
             <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
index 041aca8a0ebfea37f8d9831dd0520d74e1c32479..4425a166ce1d6a2086b125698b1ae9271e1c0877 100644 (file)
                     <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+                <configuration>
+                    <failOnError>true</failOnError>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 
index 110c5f1c2f5555d2dbb3512f4ef59608e301dc7e..4f53b98359ee66685bc0e3ee13706a78f29b5dcd 100644 (file)
@@ -100,6 +100,7 @@ public final class StatementSupportBundle implements Immutable, NamespaceBehavio
     }
 
     @Override
+    @SuppressWarnings("unchecked")
     public <K, V, N extends IdentifierNamespace<K, V>> NamespaceBehaviour<K, V, N> getNamespaceBehaviour(
             final Class<N> namespace) {
         final NamespaceBehaviour<?, ?, ?> potential = namespaceDefinitions.get(namespace);
index 7fd1bc7a968745fd05866035a2c1ded3dfaa3f62..d0e3bfd4dacc227ed4c34eb09ec88f1d9701774e 100644 (file)
@@ -255,7 +255,9 @@ public final class StmtContextUtils {
         for (final StmtContext<?, ?, ?> stmt : stmtContext.declaredSubstatements()) {
             if (YangStmtMapping.IF_FEATURE.equals(stmt.getPublicDefinition())) {
                 containsIfFeature = true;
-                if (((Predicate<Set<QName>>) stmt.getStatementArgument()).test(supportedFeatures)) {
+                @SuppressWarnings("unchecked")
+                final Predicate<Set<QName>> argument = (Predicate<Set<QName>>) stmt.getStatementArgument();
+                if (argument.test(supportedFeatures)) {
                     isSupported = true;
                 } else {
                     isSupported = false;
index 42989dce57044fc2b03691d749f3113f9ea4e618..fba795725b40baa1ff70417c6bd3d417cdc0ff42 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.parser.spi.source;
 
 import static java.util.Objects.requireNonNull;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.Optional;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -19,6 +20,7 @@ import javax.annotation.Nullable;
 public class SourceException extends RuntimeException {
     private static final long serialVersionUID = 1L;
 
+    @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "Interface-specified member")
     private final StatementSourceReference sourceRef;
 
     /**
index c183307022ba94caf0ed8ef951170e15ad0b7f09..638246f64c85b009be498e694e71066570c48fd1 100644 (file)
                     <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+                <configuration>
+                    <failOnError>true</failOnError>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 
index ed1a0de441bd3537b8cd9e4d7bb6f1b9a58ab0c8..a395b1899ed761d721504aaf8d1c51683d7b4780 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.yangtools.yang.test.util;
 
 import com.google.common.annotations.Beta;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
@@ -247,6 +248,7 @@ public final class YangParserTestUtils {
      * @param parserMode mode of statement parser
      * @return effective schema context
      */
+    @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "Wrong inferent on listFiles")
     public static SchemaContext parseYangResourceDirectory(final String resourcePath,
             final Set<QName> supportedFeatures, final StatementParserMode parserMode) {
         final URI directoryPath;
@@ -362,6 +364,7 @@ public final class YangParserTestUtils {
         }
     }
 
+    @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "Wrong inferent on listFiles")
     private static Collection<File> getYangFiles(final String resourcePath) {
         final URI directoryPath;
         try {
index 26f5ecd65bf701570168d97a8b6ce5fe0ed83cfd..80734dc3aaee034b640216d4ea397d5eb0656875 100644 (file)
                     <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+                <configuration>
+                    <failOnError>true</failOnError>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 </project>
index 2718716222377c93dd21cb2f6affc3b15512cbc1..598f5b0c813693a968a2484f16888f8b17b02a12 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.xpath.api;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.annotations.Beta;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 
 /**
  * YANG XPath binary operator.
@@ -88,6 +89,7 @@ public enum YangBinaryOperator {
      */
     MOD("mod");
 
+    @SuppressFBWarnings(value = "SE_INNER_CLASS", justification = "Outer class is a retained enumeration")
     private final class Expr extends YangBinaryExpr {
         private static final long serialVersionUID = 1L;
 
index b3de1ee777e572c112687c8b46a6b9434c65a30e..973070b904d8b14e59c19b38eb311422388025fb 100644 (file)
@@ -13,6 +13,7 @@ import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.collect.ImmutableList;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.io.Serializable;
 import java.util.Arrays;
 import java.util.Collection;
@@ -83,6 +84,8 @@ public class YangLocationPath implements YangExpr {
             return getAxis().equals(other.getAxis()) && getPredicates().equals(other.getPredicates());
         }
 
+        @SuppressFBWarnings(value = "SE_PRIVATE_READ_RESOLVE_NOT_INHERITED",
+                justification = "We have only one subclass, and that does not want to inherit this")
         private Object readResolve() {
             return getAxis().asStep();
         }
@@ -235,6 +238,8 @@ public class YangLocationPath implements YangExpr {
         }
     }
 
+    @SuppressFBWarnings(value = "EQ_DOESNT_OVERRIDE_EQUALS",
+            justification = "https://github.com/spotbugs/spotbugs/issues/511")
     static final class NodeTypeStepWithPredicates extends NodeTypeStep {
         private static final long serialVersionUID = 1L;
 
index 84c94d5ca8d517abb45010ee5e29672aa6487620..b358b219027e369b04add8ffb0e484278e962011 100644 (file)
@@ -11,6 +11,7 @@ import static java.util.Objects.requireNonNull;
 
 import com.google.common.annotations.Beta;
 import com.google.common.collect.ImmutableSet;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.Collection;
 import java.util.Set;
 
@@ -40,6 +41,7 @@ public enum YangNaryOperator {
      */
     UNION("|");
 
+    @SuppressFBWarnings(value = "SE_INNER_CLASS", justification = "Outer class is a retained enumeration")
     private final class Expr extends YangNaryExpr {
         private static final long serialVersionUID = 1L;