Skip to content

Commit

Permalink
Merge pull request #407 from xdev-software/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
AB-xdev authored Jun 28, 2024
2 parents a4989ef + ed22c44 commit adcdd1c
Show file tree
Hide file tree
Showing 24 changed files with 751 additions and 288 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>
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: Leaflet
open_collective: leafletjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
path: ${{ env.DEMO_MAVEN_MODULE }}/target/${{ env.DEMO_MAVEN_MODULE }}.jar
if-no-files-found: error

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

Expand All @@ -91,3 +91,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
26 changes: 13 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
pull-requests: write

jobs:
check_code: # Validates the code
check-code:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -45,9 +45,9 @@ jobs:
exit 1
fi
prepare_release:
prepare-release:
runs-on: ubuntu-latest
needs: [check_code]
needs: [check-code]
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
Expand Down Expand Up @@ -93,8 +93,8 @@ jobs:
release_name: v${{ steps.version.outputs.release }}
commitish: master
body: |
## [Changelog](https://github.com/xdev-software/${{ env.PRIMARY_MAVEN_MODULE }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }})
See [Changelog#v${{ steps.version.outputs.release }}](https://github.com/xdev-software/${{ env.PRIMARY_MAVEN_MODULE }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }}) for more information.
## [Changelog](https://github.com/${{ github.repository }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }})
See [Changelog#v${{ steps.version.outputs.release }}](https://github.com/${{ github.repository }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }}) for more information.
## Installation
Add the following lines to your pom:
Expand All @@ -109,9 +109,9 @@ jobs:
### Additional notes
* [Spring-Boot] You may have to include ``software/xdev`` inside [``vaadin.allowed-packages``](https://vaadin.com/docs/latest/integrations/spring/configuration#configure-the-scanning-of-packages)
publish_central: # Publish the code to central
publish-maven:
runs-on: ubuntu-latest
needs: [prepare_release]
needs: [prepare-release]
steps:
- uses: actions/checkout@v4

Expand All @@ -133,7 +133,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 @@ -142,7 +142,7 @@ jobs:

publish-pages:
runs-on: ubuntu-latest
needs: [prepare_release]
needs: [prepare-release]
steps:
- uses: actions/checkout@v4

Expand All @@ -160,7 +160,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 All @@ -169,9 +169,9 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./${{ env.PRIMARY_MAVEN_MODULE }}/target/site

after_release:
after-release:
runs-on: ubuntu-latest
needs: [publish_central]
needs: [publish-maven]
steps:
- uses: actions/checkout@v4

Expand All @@ -189,7 +189,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
18 changes: 15 additions & 3 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,22 @@ env:
SONARCLOUD_HOST: https://sonarcloud.io

jobs:
sonar:
name: SonarCloud Scan
token-check:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }}
if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'renovate/')) }}
outputs:
hasToken: ${{ steps.check-token.outputs.has }}
steps:
- id: check-token
run: |
[ -z $SONAR_TOKEN ] && echo "has=false" || echo "has=true" >> "$GITHUB_OUTPUT"
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

sonar-scan:
runs-on: ubuntu-latest
needs: token-check
if: ${{ needs.token-check.outputs.hasToken }}
steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
PRIMARY_MAVEN_MODULE: ${{ github.event.repository.name }}

jobs:
publish_central: # Publish the code to central
publish-maven:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
Loading

0 comments on commit adcdd1c

Please sign in to comment.