Skip to content

Commit

Permalink
- Maven format, pmd, spotbugs
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed May 7, 2024
1 parent c0c78b2 commit 963d843
Show file tree
Hide file tree
Showing 361 changed files with 9,744 additions and 10,230 deletions.
37 changes: 36 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,42 @@
</executions>
</plugin>

<plugin>
<groupId>com.coveo</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<verbose>false</verbose>
<filesNamePattern>.*\.java</filesNamePattern>
<skip>false</skip>
<style>aosp</style>
</configuration>
<executions>
<execution>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.commonjava.maven.plugins</groupId>
<artifactId>directory-maven-plugin</artifactId>
<version>0.3.1</version>
<executions>
<execution>
<id>directories</id>
<goals>
<goal>highest-basedir</goal>
</goals>
<phase>initialize</phase>
<configuration>
<property>geostore.basedir</property>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

<extensions>
Expand All @@ -208,7 +244,6 @@

<reporting>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
Expand Down
104 changes: 104 additions & 0 deletions qa/pmd-ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<ruleset name="Default Maven PMD Plugin Ruleset"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">

<description>
The default ruleset used by the Maven PMD Plugin, when no other ruleset is specified.
It contains the rules of the old (pre PMD 6.0.0) rulesets java-basic, java-empty, java-imports,
java-unnecessary, java-unusedcode.

This ruleset might be used as a starting point for an own customized ruleset [0].

[0] https://pmd.github.io/latest/pmd_userdocs_understanding_rulesets.html
</description>

<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP" />
<rule ref="category/java/bestpractices.xml/CheckResultSet" />
<rule ref="category/java/bestpractices.xml/UnusedImports" />
<!--rule ref="category/java/bestpractices.xml/UnusedFormalParameter" /-->
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable" />
<rule ref="category/java/bestpractices.xml/UnusedPrivateField" />
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod" />
<rule ref="category/java/bestpractices.xml/SystemPrintln" />

<rule ref="category/java/codestyle.xml/DontImportJavaLang" />
<rule ref="category/java/codestyle.xml/DuplicateImports" />
<rule ref="category/java/codestyle.xml/ExtendsObject" />
<rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop" />
<!--rule ref="category/java/codestyle.xml/TooManyStaticImports" / -->
<rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName" />
<!-- rule ref="category/java/codestyle.xml/UnnecessaryModifier" / -->
<rule ref="category/java/codestyle.xml/UnnecessaryReturn" />
<rule ref="category/java/codestyle.xml/UselessParentheses" />
<rule ref="category/java/codestyle.xml/UselessQualifiedThis" />

<!-- rule ref="category/java/design.xml/CollapsibleIfStatements" / -->
<!-- rule ref="category/java/design.xml/SimplifiedTernary" / -->
<!-- rule ref="category/java/design.xml/UselessOverridingMethod" / -->

<!--
<rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop" />
-->
<rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor" />
<rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators" />
<rule ref="category/java/errorprone.xml/AvoidUsingOctalValues" />
<rule ref="category/java/errorprone.xml/BrokenNullCheck" />
<rule ref="category/java/errorprone.xml/CheckSkipResult" />
<rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray" />
<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices" />
<!-- rule ref="category/java/errorprone.xml/EmptyCatchBlock" /-->
<rule ref="category/java/errorprone.xml/EmptyFinallyBlock" />
<rule ref="category/java/errorprone.xml/EmptyIfStmt" />
<rule ref="category/java/errorprone.xml/EmptyInitializer" />
<rule ref="category/java/errorprone.xml/EmptyStatementBlock" />
<rule ref="category/java/errorprone.xml/EmptyStatementNotInLoop" />
<rule ref="category/java/errorprone.xml/EmptySwitchStatements" />
<rule ref="category/java/errorprone.xml/EmptySynchronizedBlock" />
<rule ref="category/java/errorprone.xml/EmptyTryBlock" />
<rule ref="category/java/errorprone.xml/EmptyWhileStmt" />
<rule ref="category/java/errorprone.xml/ImportFromSamePackage" />
<rule ref="category/java/errorprone.xml/JumbledIncrementer" />
<rule ref="category/java/errorprone.xml/MisplacedNullCheck" />
<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode" />
<rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock" />
<rule ref="category/java/errorprone.xml/UnconditionalIfStatement" />
<rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary" />
<rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals" />
<rule ref="category/java/errorprone.xml/UselessOperationOnImmutable" />
<rule ref="category/java/errorprone.xml/CloseResource" >
<properties>
<!-- When calling the store to close, PMD wants the full prefix before the call to the method to match, so let's try to use common var names for store ... -->
<property name="closeTargets" value="releaseConnection,store.releaseConnection,closeQuietly,closeConnection,closeSafe,store.closeSafe,dataStore.closeSafe,getDataStore().closeSafe,close,closeResultSet,closeStmt,closeFinally,JDBCUtils.close"/>
</properties>
</rule>

<rule ref="category/java/multithreading.xml/AvoidThreadGroup" />
<rule ref="category/java/multithreading.xml/DontCallThreadRun" />
<rule ref="category/java/multithreading.xml/DoubleCheckedLocking" />

<rule ref="category/java/performance.xml/BigIntegerInstantiation" />
<rule ref="category/java/performance.xml/BooleanInstantiation" />
<rule ref="category/java/performance.xml/ByteInstantiation" />
<rule ref="category/java/performance.xml/IntegerInstantiation" />
<rule ref="category/java/performance.xml/LongInstantiation" />
<rule ref="category/java/performance.xml/ShortInstantiation" />
<rule ref="category/java/performance.xml/StringInstantiation" />
</ruleset>
74 changes: 74 additions & 0 deletions qa/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!-- This file specifies a spotbugs filter for excluding reports that
should not be considered errors.
The format of this file is documented at:
https://spotbugs.readthedocs.io/en/latest/filter.html
When possible, please specify the full names of the bug codes,
using the pattern attribute, to make it clearer what reports are
being suppressed. You can find a listing of codes at:
https://spotbugs.readthedocs.io/en/latest/bugDescriptions.html
-->
<FindBugsFilter>
<!-- Won't use prepared statements, very bad performance for geospatial use cases -->
<Match>
<Bug pattern="SQL_NONCONSTANT_STRING_PASSED_TO_EXECUTE"/>
</Match>
<Match>
<Bug pattern="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING"/>
</Match>
<!-- Returns mostly false positives -->
<Match>
<Bug pattern="FE_FLOATING_POINT_EQUALITY"/>
</Match>
<!-- Too many cases where we have a semi-legit usage of same name -->
<Match>
<Bug pattern="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS"/>
</Match>
<!-- False positives might want to revisit later -->
<Match>
<Bug pattern="EC_UNRELATED_TYPES_USING_POINTER_EQUALITY"/>
</Match>
<!-- Annoying but not actually a bug per se might want to revisit later -->
<Match>
<Bug pattern="MF_CLASS_MASKS_FIELD"/>
</Match>
<!-- False positives -->
<Match>
<Bug pattern="UWF_UNWRITTEN_FIELD"/>
</Match>
<!-- Too many false positives -->
<Match>
<Bug pattern="CN_IMPLEMENTS_CLONE_BUT_NOT_CLONEABLE"/>
</Match>
<!-- Too many false positives -->
<Match>
<Bug pattern="NP_NULL_PARAM_DEREF"/>
</Match>
<Match>
<Bug pattern="NP_NULL_ON_SOME_PATH"/>
</Match>
<Match>
<Bug pattern="NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE"/>
</Match>
<Match>
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
</Match>
<!-- Too many false positives -->
<Match>
<Bug pattern="NP_BOOLEAN_RETURN_NULL"/>
</Match>
<Match>
<Bug pattern="NP_NONNULL_RETURN_VIOLATION"/>
</Match>
<Match>
<Bug pattern="DMI_INVOKING_TOSTRING_ON_ARRAY"/>
</Match>
<!-- False positives under Java 11, see https://github.com/spotbugs/spotbugs/issues/878
and https://github.com/spotbugs/spotbugs/issues/756 -->
<Match>
<Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/>
</Match>

<Match>
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>
</Match>
</FindBugsFilter>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* http://www.geo-solutions.it
*
* GPLv3 + Classpath exception
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
Expand All @@ -17,7 +17,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.
* along with this program.
*
* ====================================================================
*
Expand All @@ -27,17 +27,17 @@
*
*/
package it.geosolutions.geostore.cli;

import picocli.CommandLine;

/**
* CLI tool to export a GeoStore H2 database as a script for a destination database.
* Usage: H2ToPgSQL [-o, --output=<path to output sql>] <path to H2 database file>
* CLI tool to export a GeoStore H2 database as a script for a destination database. Usage:
* H2ToPgSQL [-o, --output=<path to output sql>] <path to H2 database file>
*/
public class H2ToPgSQLExportCLI {

public static void main(String[] args) {
H2ToPgSQLExporter exporter = new H2ToPgSQLExporter();
System.exit(new CommandLine(exporter).execute(args));
}

}
Loading

0 comments on commit 963d843

Please sign in to comment.