Skip to content

Commit

Permalink
[SpotBugs][pulsar-io]Enable spotbugs for pulsar-io/core, common, docs (
Browse files Browse the repository at this point in the history
…apache#8903)

Master Issue: apache#8843 

### Motivation

Enable spotbugs for the pulsar-io module. 

### Modifications

Enable soptbugs for pulsar-io/core, pulsar-io/common, pulsar-io/docs.

### Verifying this change

```
mvn clean install -pl pulsar-io/core
mvn clean install -pl pulsar-io/common
mvn clean install -pl pulsar-io/docs

```
  • Loading branch information
devosend authored Dec 11, 2020
1 parent 0e6ad1c commit 6fd5c85
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 5 deletions.
28 changes: 27 additions & 1 deletion pulsar-io/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,30 @@
</dependency>
</dependencies>

</project>
<build>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs-maven-plugin.version}</version>
<executions>
<execution>
<id>spotbugs</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<configuration>
<excludeFilterFile>${basedir}/src/main/resources/findbugsExclude.xml</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</build>

</project>
22 changes: 22 additions & 0 deletions pulsar-io/common/src/main/resources/findbugsExclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<FindBugsFilter>
</FindBugsFilter>
26 changes: 26 additions & 0 deletions pulsar-io/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,30 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs-maven-plugin.version}</version>
<executions>
<execution>
<id>spotbugs</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<configuration>
<excludeFilterFile>${basedir}/src/main/resources/findbugsExclude.xml</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</build>

</project>
22 changes: 22 additions & 0 deletions pulsar-io/core/src/main/resources/findbugsExclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<FindBugsFilter>
</FindBugsFilter>
26 changes: 26 additions & 0 deletions pulsar-io/docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,30 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs-maven-plugin.version}</version>
<executions>
<execution>
<id>spotbugs</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<configuration>
<excludeFilterFile>${basedir}/src/main/resources/findbugsExclude.xml</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.google.common.base.Strings;
import java.io.FileWriter;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -112,12 +115,12 @@ private void generatorConnectorYamls(String outputDir) throws IOException {

for (Class<?> connectorClass : connectorClasses) {
Connector connectorDef = connectorClass.getDeclaredAnnotation(Connector.class);
try (FileWriter fileWriter = new FileWriter(
Paths.get(
try (FileOutputStream fos = new FileOutputStream(
Paths.get(
outputDir,
"pulsar-io-" + connectorDef.name()
+ "-" + connectorDef.type().name().toLowerCase()).toString() + ".yml")) {
PrintWriter pw = new PrintWriter(fileWriter);
PrintWriter pw = new PrintWriter(new OutputStreamWriter(fos, StandardCharsets.UTF_8));
generateConnectorYaml(connectorClass, connectorDef, pw);
pw.flush();
}
Expand Down
22 changes: 22 additions & 0 deletions pulsar-io/docs/src/main/resources/findbugsExclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<FindBugsFilter>
</FindBugsFilter>

0 comments on commit 6fd5c85

Please sign in to comment.