Skip to content

Commit

Permalink
chore: Update PMD rules
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Solórzano <[email protected]>
  • Loading branch information
jorsol committed Apr 26, 2024
1 parent c38c08f commit 61a7d21
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
distribution: 'zulu'
cache: maven
- name: Build with Maven
run: ./mvnw -B verify -Pchecks,run-its --file pom.xml
run: ./mvnw -B verify -P checks -P run-its

# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
- name: Update dependency graph
Expand Down
42 changes: 15 additions & 27 deletions checks/pmd-ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,42 +1,30 @@
<?xml version="1.0"?>
<ruleset name="Custom Rules" 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">
<ruleset name="Custom Rules" 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>Custom Rules</description>

<exclude-pattern>.*/target/.*</exclude-pattern>
<exclude-pattern>.*/generated/.*</exclude-pattern>
<exclude-pattern>.*/Tables.java</exclude-pattern>
<exclude-pattern>.*/com/ongres/stringprep/Tables.*</exclude-pattern>

<!-- Your rules will come here -->
<rule ref="rulesets/java/quickstart.xml">
<exclude name="ClassNamingConventions" />
</rule>

<rule ref="category/java/codestyle.xml/TooManyStaticImports" />
<rule ref="rulesets/java/quickstart.xml" />

<rule ref="category/java/design.xml">
<exclude name="CognitiveComplexity" />
<exclude name="CyclomaticComplexity" />
<exclude name="LawOfDemeter" />
<exclude name="LoosePackageCoupling" />
<exclude name="NPathComplexity" />
<exclude name="GodClass" />
<exclude name="TooManyFields" />
<rule ref="category/java/bestpractices.xml">
<exclude name="UseVarargs" />
<exclude name="ForLoopVariableCount" />
<exclude name="AvoidReassigningLoopVariables" />
</rule>

<rule ref="category/java/errorprone.xml">
<exclude name="AvoidLiteralsInIfCondition" />
<exclude name="DataflowAnomalyAnalysis" />
<exclude name="CloseResource" />
</rule>
<rule ref="category/java/errorprone.xml" />

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

<rule ref="category/java/errorprone.xml/EmptyCatchBlock">
<properties>
<property name="allowCommentedBlocks" value="true" />
<property name="allowExceptionNameRegex" value="^(ignored|expected)$" />
</properties>
<rule ref="category/java/performance.xml">
<exclude name="StringInstantiation" />
</rule>

<rule ref="category/java/performance.xml" />
<rule ref="category/java/security.xml" />

</ruleset>
4 changes: 2 additions & 2 deletions nameprep/src/main/java/com/ongres/nameprep/Nameprep.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@ProfileName("Nameprep")
public final class Nameprep implements Profile {

private final EnumSet<Option> nameprepProfile;
private final Set<Option> nameprepProfile;

/**
* Construct an instance of the {@code Nameprep} profile.
Expand All @@ -47,7 +47,7 @@ public Nameprep() {

@Override
public Set<Option> profile() {
return nameprepProfile.clone();
return nameprepProfile;
}

}
4 changes: 2 additions & 2 deletions saslprep/src/main/java/com/ongres/saslprep/SASLprep.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@ProfileName("SASLprep")
public final class SASLprep implements Profile {

private final EnumSet<Option> saslprepProfile;
private final Set<Option> saslprepProfile;

/**
* Construct an instance of the {@code SASLprep} profile.
Expand All @@ -50,7 +50,7 @@ public SASLprep() {

@Override
public Set<Option> profile() {
return saslprepProfile.clone();
return saslprepProfile;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.EnumSet;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
import java.util.function.IntPredicate;

/**
Expand Down Expand Up @@ -53,7 +54,7 @@ public final class Stringprep {
*/
Stringprep(Profile profile, boolean storedStrings) {
Objects.requireNonNull(profile);
EnumSet<Option> options = EnumSet.copyOf(Objects.requireNonNull(profile.profile()));
Set<Option> options = EnumSet.copyOf(Objects.requireNonNull(profile.profile()));
this.mapToNothing = options.contains(Option.MAP_TO_NOTHING);
this.additionalMapping = options.contains(Option.ADDITIONAL_MAPPING);
this.caseFoldNfkc = options.contains(Option.CASE_FOLD_NFKC);
Expand Down

0 comments on commit 61a7d21

Please sign in to comment.