Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/update-from-template' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
AB-xdev committed Jun 28, 2024
2 parents ca81b25 + 034ee38 commit 07859e0
Show file tree
Hide file tree
Showing 11 changed files with 319 additions and 48 deletions.
152 changes: 152 additions & 0 deletions .config/pmd/ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Default"
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 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">

<description>
This ruleset checks the code for discouraged programming constructs.
</description>

<!-- Only rules that don't overlap with CheckStyle! -->

<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP"/>
<rule ref="category/java/bestpractices.xml/PreserveStackTrace"/>
<rule ref="category/java/bestpractices.xml/UseCollectionIsEmpty"/>
<rule ref="category/java/bestpractices.xml/UseStandardCharsets"/>

<!-- Native code is platform dependent; Loading external native libs might pose a security threat -->
<rule ref="category/java/codestyle.xml/AvoidUsingNativeCode"/>
<rule ref="category/java/codestyle.xml/IdenticalCatchBranches"/>
<rule ref="category/java/codestyle.xml/NoPackage"/>
<rule ref="category/java/codestyle.xml/PrematureDeclaration"/>

<rule ref="category/java/design.xml">
<!-- Sometimes abstract classes have just fields -->
<exclude name="AbstractClassWithoutAnyMethod"/>

<!-- Using RuntimeExceptions is ok -->
<exclude name="AvoidCatchingGenericException"/>
<exclude name="AvoidThrowingRawExceptionTypes"/>

<!-- Limit too low -->
<exclude name="AvoidDeeplyNestedIfStmts"/>

<!-- Limit too low -->
<exclude name="CouplingBetweenObjects"/>

<!-- Limit too low -->
<exclude name="CyclomaticComplexity"/>

<!-- Makes entity classes impossible -->
<exclude name="DataClass"/>

<!-- Used commonly particular in bigger methods with upstream throws -->
<exclude name="ExceptionAsFlowControl"/>

<!-- Limit too low -->
<exclude name="ExcessiveImports"/>

<!-- Handled by TooManyFields/TooManyMethods -->
<exclude name="ExcessivePublicCount"/>

<!-- Prohibits accessing members using multiple depths -->
<exclude name="LawOfDemeter"/>

<!-- No effect -->
<exclude name="LoosePackageCoupling"/>

<!-- Prohibits singleton pattern -->
<exclude name="MutableStaticState"/>

<!-- Some override methods or Junit require this -->
<exclude name="SignatureDeclareThrowsException"/>

<!-- Reports FP for equals methods -->
<exclude name="SimplifyBooleanReturns"/>

<!-- Limit too low -->
<exclude name="TooManyFields"/>

<!-- Limit too low -->
<exclude name="TooManyMethods"/>

<!-- Limit too low -->
<exclude name="UseObjectForClearerAPI"/>

<!-- Handled by checkstyle -->
<exclude name="UseUtilityClass"/>
</rule>

<rule ref="category/java/design.xml/AvoidDeeplyNestedIfStmts">
<properties>
<property name="problemDepth" value="4"/>
</properties>
</rule>
<rule ref="category/java/design.xml/CouplingBetweenObjects">
<properties>
<property name="threshold" value="100"/>
</properties>
</rule>
<rule ref="category/java/design.xml/CyclomaticComplexity">
<properties>
<property name="classReportLevel" value="150"/>
<property name="methodReportLevel" value="25"/>
<property name="cycloOptions" value=""/>
</properties>
</rule>
<rule ref="category/java/design.xml/ExcessiveImports">
<properties>
<property name="minimum" value="200"/>
</properties>
</rule>
<rule ref="category/java/design.xml/TooManyFields">
<properties>
<property name="maxfields" value="50"/>
</properties>
</rule>
<rule ref="category/java/design.xml/TooManyMethods">
<properties>
<property name="maxmethods" value="100"/>
</properties>
</rule>

<rule ref="category/java/errorprone.xml/AvoidUsingOctalValues"/>
<rule ref="category/java/errorprone.xml/BrokenNullCheck"/>
<rule ref="category/java/errorprone.xml/ComparisonWithNaN"/>
<rule ref="category/java/errorprone.xml/DoNotCallGarbageCollectionExplicitly"/>
<rule ref="category/java/errorprone.xml/DontImportSun"/>
<rule ref="category/java/errorprone.xml/MisplacedNullCheck"/>
<rule ref="category/java/errorprone.xml/UnnecessaryCaseChange"/>


<rule ref="category/java/multithreading.xml">
<!-- Just bloats code -->
<exclude name="AvoidSynchronizedAtMethodLevel"/>

<!-- NOPE -->
<exclude name="DoNotUseThreads"/>

<!-- Doesn't detect nested thread safe singleton pattern -->
<exclude name="NonThreadSafeSingleton"/>

<!-- Should relevant for fields that use multithreading which is rare -->
<exclude name="UseConcurrentHashMap"/>
</rule>

<rule ref="category/java/performance.xml">
<!-- This was fixed in Java 10 -->
<exclude name="AvoidFileStream"/>

<!-- Used everywhere and has neglectable performance impact -->
<exclude name="AvoidInstantiatingObjectsInLoops"/>

<!-- Handled by checkstyle -->
<exclude name="RedundantFieldInitializer"/>

<!-- Nowadays optimized by compiler; No code bloating needed -->
<exclude name="UseStringBufferForStringAppends"/>
</rule>

<rule ref="category/java/security.xml"/>
</ruleset>
39 changes: 38 additions & 1 deletion .github/workflows/check-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
exit 1
fi
code-style:
checkstyle:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}

Expand All @@ -84,3 +84,40 @@ jobs:

- name: Run Checkstyle
run: ./mvnw -B checkstyle:check -P checkstyle -T2C

pmd:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}

strategy:
matrix:
java: [17]
distribution: [temurin]

steps:
- uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.distribution }}
java-version: ${{ matrix.java }}
cache: 'maven'

- name: Run PMD
run: ./mvnw -B test pmd:aggregate-pmd-no-fork pmd:check -P pmd -DskipTests -T2C

- name: Run CPD (Copy Paste Detector)
run: ./mvnw -B pmd:aggregate-cpd pmd:cpd-check -P pmd -DskipTests -T2C

- name: Upload report
if: always()
uses: actions/upload-artifact@v4
with:
name: pmd-report
if-no-files-found: ignore
path: |
target/site/*.html
target/site/css/**
target/site/images/logos/maven-feather.png
target/site/images/external.png
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ jobs:
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}

- name: Publish to Apache Maven Central
run: ../mvnw -B deploy -Possrh
run: ../mvnw -B deploy -Possrh -DskipTests
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.S01_OSS_SONATYPE_MAVEN_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.S01_OSS_SONATYPE_MAVEN_TOKEN }}
Expand All @@ -157,7 +157,7 @@ jobs:
cache: 'maven'

- name: Build site
run: ../mvnw -B site
run: ../mvnw -B site -DskipTests
working-directory: ${{ env.PRIMARY_MAVEN_MODULE }}

- name: Deploy to Github pages
Expand Down Expand Up @@ -186,7 +186,7 @@ jobs:
for i in "${modules[@]}"
do
echo "Processing $i/pom.xml"
(cd "$i" && $mvnwPath -B build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} -DgenerateBackupPoms=false -DnextSnapshot=true)
(cd "$i" && $mvnwPath -B build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} -DgenerateBackupPoms=false -DnextSnapshot=true -DupdateMatchingVersions=false)
done
- name: Git Commit and Push
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/update-from-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ jobs:
echo "Checking if update-branch-merged exists"
git fetch
if [[ $(git rev-parse origin/${{ env.UPDATE_BRANCH_MERGED }}) ]]; then
echo "Branch still exists; Continuing..."
else
echo "Branch origin/${{ env.UPDATE_BRANCH_MERGED }} is missing"
exit 0
fi
Expand Down Expand Up @@ -274,6 +276,8 @@ jobs:
echo "Fetching..."
git fetch
if [[ $(git rev-parse origin/${{ env.UPDATE_BRANCH_MERGED }}) ]]; then
echo "Branch still exists; Continuing..."
else
echo "Branch origin/${{ env.UPDATE_BRANCH_MERGED }} is missing"
exit 0
fi
Expand Down
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ buildNumber.properties
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*


# bin / compiled stuff
target/


# JRebel
**/resources/rebel.xml
**/resources/rebel-remote.xml
Expand Down
1 change: 1 addition & 0 deletions .idea/saveactions_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip
66 changes: 63 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
<module>testcontainers-selenium-demo</module>
</modules>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<licenses>
<license>
<name>Apache License, Version 2.0</name>
Expand All @@ -29,20 +34,75 @@

<profiles>
<profile>
<!-- Disable checkstyle in root module as there is nothing to check -->
<id>checkstyle</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.3.1</version>
<version>3.4.0</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>10.17.0</version>
</dependency>
</dependencies>
<configuration>
<skip>true</skip>
<configLocation>.config/checkstyle/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>pmd</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.23.0</version>
<configuration>
<includeTests>true</includeTests>
<printFailingErrors>true</printFailingErrors>
<rulesets>
<ruleset>.config/pmd/ruleset.xml</ruleset>
</rulesets>
</configuration>
<dependencies>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId>
<version>7.2.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-java</artifactId>
<version>7.2.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<!-- Required for reporting -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>3.4.0</version>
</plugin>
</plugins>
</reporting>
</profile>
</profiles>
</project>
8 changes: 8 additions & 0 deletions renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"rebaseWhen": "behind-base-branch",
"packageRules": [
{
"description": "Ignore project internal dependencies",
"packagePattern": "^software.xdev:testcontainers-selenium ",
"datasources": [
"maven"
],
"enabled": false
},
{
"description": "Group Selenium",
"matchPackagePatterns": [
Expand Down
Loading

0 comments on commit 07859e0

Please sign in to comment.