From af6895f0e4751b2c8653ff2d81f13e6b8636bf5f Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Thu, 6 Mar 2025 22:37:38 +0100 Subject: [PATCH 01/51] [#12001] pmd initial setup pipeline --- .gitlab-ci.yml | 21 ++ pom.xml | 69 +++++ src/main/resources/checkstyle.xml | 440 +++++++++++++++++++++++++++++ src/main/resources/pmd-ruleset.xml | 323 +++++++++++++++++++++ 4 files changed, 853 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100644 src/main/resources/checkstyle.xml create mode 100644 src/main/resources/pmd-ruleset.xml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..4fab6a0 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,21 @@ +image: maven:3.9.6-eclipse-temurin-23 + +stages: + - pmd + +variables: + MAVEN_CLI_OPTS: "--batch-mode --errors --fail-fast --show-version" + MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository" + +cache: + paths: + - .m2/repository + +pmd_analysis: + stage: pmd + script: + - mvn $MAVEN_CLI_OPTS clean verify + artifacts: + paths: + - target/pmd-reports/ + expire_in: 1 week diff --git a/pom.xml b/pom.xml index c8be7dc..33182d0 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,76 @@ </excludes> </configuration> </plugin> + + <!-- Checkstyle Plugin --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>3.6.0</version> + <executions> + <execution> + <phase>verify</phase> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + <configuration> + <configLocation>checkstyle.xml</configLocation> + <consoleOutput>true</consoleOutput> + <failOnViolation>false</failOnViolation> + </configuration> + </plugin> + + <!-- PMD Plugin --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-pmd-plugin</artifactId> + <version>3.26.0</version> + <executions> + <execution> + <phase>verify</phase> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + <configuration> + <rulesets> + <ruleset>src/main/resources/pmd-ruleset.xml</ruleset> + </rulesets> + <failOnViolation>false</failOnViolation> <!-- Avoid build failures --> + <outputDirectory>target/pmd-reports</outputDirectory> + <format>html</format> <!-- Specify HTML format for detailed output --> + <linkXRef>true</linkXRef> <!-- Show link to repo on line number --> + </configuration> + </plugin> + + <!-- SpotBugs Plugin --> + <plugin> + <groupId>com.github.spotbugs</groupId> + <artifactId>spotbugs-maven-plugin</artifactId> + <version>4.9.2.0</version> + <executions> + <execution> + <phase>verify</phase> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> + <reporting> + <plugins> + <!-- JXR (Java Cross Reference) for PMD generating HTML --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jxr-plugin</artifactId> + <version>3.6.0</version> + </plugin> + </plugins> + </reporting> </project> diff --git a/src/main/resources/checkstyle.xml b/src/main/resources/checkstyle.xml new file mode 100644 index 0000000..7a48dbe --- /dev/null +++ b/src/main/resources/checkstyle.xml @@ -0,0 +1,440 @@ +<?xml version="1.0"?> +<!DOCTYPE module PUBLIC + "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" + "https://checkstyle.org/dtds/configuration_1_3.dtd"> + +<!-- + Checkstyle configuration that checks the Google coding conventions from Google Java Style + that can be found at https://google.github.io/styleguide/javaguide.html + + Checkstyle is very configurable. Be sure to read the documentation at + http://checkstyle.org (or in your downloaded distribution). + + To completely disable a check, just comment it out or delete it from the file. + To suppress certain violations please review suppression filters. + + Authors: Max Vetrenko, Mauryan Kansara, Ruslan Diachenko, Roman Ivanov. + --> + +<module name="Checker"> + + <property name="charset" value="UTF-8"/> + + <property name="severity" value="${org.checkstyle.google.severity}" default="warning"/> + + <property name="fileExtensions" value="java, properties, xml"/> + <!-- Excludes all 'module-info.java' files --> + <!-- See https://checkstyle.org/filefilters/index.html --> + <module name="BeforeExecutionExclusionFileFilter"> + <property name="fileNamePattern" value="module\-info\.java$"/> + </module> + + <module name="SuppressWarningsFilter"/> + + <!-- https://checkstyle.org/filters/suppressionfilter.html --> + <module name="SuppressionFilter"> + <property name="file" value="${org.checkstyle.google.suppressionfilter.config}" + default="checkstyle-suppressions.xml" /> + <property name="optional" value="true"/> + </module> + + <!-- https://checkstyle.org/filters/suppresswithnearbytextfilter.html --> + <module name="SuppressWithNearbyTextFilter"> + <property name="nearbyTextPattern" + value="CHECKSTYLE.SUPPRESS\: (\w+) for ([+-]\d+) lines"/> + <property name="checkPattern" value="$1"/> + <property name="lineRange" value="$2"/> + </module> + + <!-- Checks for whitespace --> + <!-- See http://checkstyle.org/checks/whitespace/index.html --> + <module name="FileTabCharacter"> + <property name="eachLine" value="true"/> + </module> + + <module name="LineLength"> + <property name="fileExtensions" value="java"/> + <property name="max" value="100"/> + <property name="ignorePattern" + value="^package.*|^import.*|href\s*=\s*"[^"]*"|http://|https://|ftp://"/> + </module> + + <module name="TreeWalker"> + <module name="OuterTypeFilename"/> + <module name="IllegalTokenText"> + <property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/> + <property name="format" + value="\\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/> + <property name="message" + value="Consider using special escape sequence instead of octal value or Unicode escaped value."/> + </module> + <module name="AvoidEscapedUnicodeCharacters"> + <property name="allowEscapesForControlCharacters" value="true"/> + <property name="allowByTailComment" value="true"/> + <property name="allowNonPrintableEscapes" value="true"/> + </module> + <module name="AvoidStarImport"/> + <module name="OneTopLevelClass"/> + <module name="NoLineWrap"> + <property name="tokens" value="PACKAGE_DEF, IMPORT, STATIC_IMPORT"/> + </module> + <module name="NeedBraces"> + <property name="tokens" + value="LITERAL_DO, LITERAL_ELSE, LITERAL_FOR, LITERAL_IF, LITERAL_WHILE"/> + </module> + <module name="LeftCurly"> + <property name="id" value="LeftCurlyEol"/> + <property name="tokens" + value="ANNOTATION_DEF, CLASS_DEF, CTOR_DEF, ENUM_CONSTANT_DEF, ENUM_DEF, + INTERFACE_DEF, LAMBDA, LITERAL_CATCH, + LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, + LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, METHOD_DEF, + OBJBLOCK, STATIC_INIT, RECORD_DEF, COMPACT_CTOR_DEF"/> + </module> + <module name="LeftCurly"> + <property name="id" value="LeftCurlyNl"/> + <property name="option" value="nl"/> + <property name="tokens" + value="LITERAL_CASE, LITERAL_DEFAULT"/> + </module> + <module name="SuppressionXpathSingleFilter"> + <!-- LITERAL_CASE, LITERAL_DEFAULT are reused in SWITCH_RULE --> + <property name="id" value="LeftCurlyNl"/> + <property name="query" value="//SWITCH_RULE/SLIST"/> + </module> + <module name="RightCurly"> + <property name="id" value="RightCurlySame"/> + <property name="tokens" + value="LITERAL_TRY, LITERAL_CATCH, LITERAL_IF, LITERAL_ELSE, + LITERAL_DO"/> + </module> + <module name="RightCurly"> + <property name="id" value="RightCurlyAlone"/> + <property name="option" value="alone"/> + <property name="tokens" + value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT, + INSTANCE_INIT, ANNOTATION_DEF, ENUM_DEF, INTERFACE_DEF, RECORD_DEF, + COMPACT_CTOR_DEF, LITERAL_SWITCH, LITERAL_CASE, LITERAL_FINALLY"/> + </module> + <module name="SuppressionXpathSingleFilter"> + <!-- suppression is required till https://github.com/checkstyle/checkstyle/issues/7541 --> + <property name="id" value="RightCurlyAlone"/> + <property name="query" value="//RCURLY[parent::SLIST[count(./*)=1] + or preceding-sibling::*[last()][self::LCURLY]]"/> + </module> + <module name="WhitespaceAfter"> + <property name="tokens" + value="COMMA, SEMI, TYPECAST, LITERAL_IF, LITERAL_ELSE, LITERAL_RETURN, + LITERAL_WHILE, LITERAL_DO, LITERAL_FOR, LITERAL_FINALLY, DO_WHILE, ELLIPSIS, + LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_CATCH, LAMBDA, + LITERAL_YIELD, LITERAL_CASE, LITERAL_WHEN"/> + </module> + <module name="WhitespaceAround"> + <property name="allowEmptyConstructors" value="true"/> + <property name="allowEmptyLambdas" value="true"/> + <property name="allowEmptyMethods" value="true"/> + <property name="allowEmptyTypes" value="true"/> + <property name="allowEmptyLoops" value="true"/> + <property name="allowEmptySwitchBlockStatements" value="true"/> + <property name="ignoreEnhancedForColon" value="false"/> + <property name="tokens" + value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, + BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, DO_WHILE, EQUAL, GE, GT, LAMBDA, LAND, + LCURLY, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, + LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, + LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, + NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, + SR_ASSIGN, STAR, STAR_ASSIGN, LITERAL_ASSERT, + TYPE_EXTENSION_AND, LITERAL_WHEN"/> + <message key="ws.notFollowed" + value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks + may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/> + <message key="ws.notPreceded" + value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/> + </module> + <module name="SuppressionXpathSingleFilter"> + <property name="checks" value="WhitespaceAround"/> + <property name="query" value="//*[self::LITERAL_IF or self::LITERAL_ELSE or self::STATIC_INIT + or self::LITERAL_TRY or self::LITERAL_CATCH]/SLIST[count(./*)=1] + | //*[self::STATIC_INIT or self::LITERAL_TRY or self::LITERAL_IF] + //*[self::RCURLY][parent::SLIST[count(./*)=1]]"/> + </module> + <module name="RegexpSinglelineJava"> + <property name="format" value="\{[ ]+\}"/> + <property name="message" value="Empty blocks should have no spaces. Empty blocks + may only be represented as '{}' when not part of a + multi-block statement (4.1.3)"/> + </module> + <module name="OneStatementPerLine"/> + <module name="MultipleVariableDeclarations"/> + <module name="ArrayTypeStyle"/> + <module name="MissingSwitchDefault"/> + <module name="FallThrough"/> + <module name="UpperEll"/> + <module name="ModifierOrder"/> + <module name="EmptyLineSeparator"> + <property name="tokens" + value="PACKAGE_DEF, IMPORT, STATIC_IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF, + STATIC_INIT, INSTANCE_INIT, METHOD_DEF, CTOR_DEF, VARIABLE_DEF, RECORD_DEF, + COMPACT_CTOR_DEF"/> + <property name="allowNoEmptyLineBetweenFields" value="true"/> + </module> + <module name="SeparatorWrap"> + <property name="id" value="SeparatorWrapDot"/> + <property name="tokens" value="DOT"/> + <property name="option" value="nl"/> + </module> + <module name="SeparatorWrap"> + <property name="id" value="SeparatorWrapComma"/> + <property name="tokens" value="COMMA"/> + <property name="option" value="EOL"/> + </module> + <module name="SeparatorWrap"> + <!-- ELLIPSIS is EOL until https://github.com/google/styleguide/issues/259 --> + <property name="id" value="SeparatorWrapEllipsis"/> + <property name="tokens" value="ELLIPSIS"/> + <property name="option" value="EOL"/> + </module> + <module name="SeparatorWrap"> + <!-- ARRAY_DECLARATOR is EOL until https://github.com/google/styleguide/issues/258 --> + <property name="id" value="SeparatorWrapArrayDeclarator"/> + <property name="tokens" value="ARRAY_DECLARATOR"/> + <property name="option" value="EOL"/> + </module> + <module name="SeparatorWrap"> + <property name="id" value="SeparatorWrapMethodRef"/> + <property name="tokens" value="METHOD_REF"/> + <property name="option" value="nl"/> + </module> + <module name="PackageName"> + <property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/> + <message key="name.invalidPattern" + value="Package name ''{0}'' must match pattern ''{1}''."/> + </module> + <module name="TypeName"> + <property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, + ANNOTATION_DEF, RECORD_DEF"/> + <message key="name.invalidPattern" + value="Type name ''{0}'' must match pattern ''{1}''."/> + </module> + <module name="MemberName"> + <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/> + <message key="name.invalidPattern" + value="Member name ''{0}'' must match pattern ''{1}''."/> + </module> + <module name="ParameterName"> + <property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/> + <message key="name.invalidPattern" + value="Parameter name ''{0}'' must match pattern ''{1}''."/> + </module> + <module name="LambdaParameterName"> + <property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/> + <message key="name.invalidPattern" + value="Lambda parameter name ''{0}'' must match pattern ''{1}''."/> + </module> + <module name="CatchParameterName"> + <property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/> + <message key="name.invalidPattern" + value="Catch parameter name ''{0}'' must match pattern ''{1}''."/> + </module> + <module name="LocalVariableName"> + <property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/> + <message key="name.invalidPattern" + value="Local variable name ''{0}'' must match pattern ''{1}''."/> + </module> + <module name="PatternVariableName"> + <property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/> + <message key="name.invalidPattern" + value="Pattern variable name ''{0}'' must match pattern ''{1}''."/> + </module> + <module name="ClassTypeParameterName"> + <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/> + <message key="name.invalidPattern" + value="Class type name ''{0}'' must match pattern ''{1}''."/> + </module> + <module name="RecordComponentName"> + <property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/> + <message key="name.invalidPattern" + value="Record component name ''{0}'' must match pattern ''{1}''."/> + </module> + <module name="RecordTypeParameterName"> + <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/> + <message key="name.invalidPattern" + value="Record type name ''{0}'' must match pattern ''{1}''."/> + </module> + <module name="MethodTypeParameterName"> + <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/> + <message key="name.invalidPattern" + value="Method type name ''{0}'' must match pattern ''{1}''."/> + </module> + <module name="InterfaceTypeParameterName"> + <property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/> + <message key="name.invalidPattern" + value="Interface type name ''{0}'' must match pattern ''{1}''."/> + </module> + <module name="NoFinalizer"/> + <module name="GenericWhitespace"> + <message key="ws.followed" + value="GenericWhitespace ''{0}'' is followed by whitespace."/> + <message key="ws.preceded" + value="GenericWhitespace ''{0}'' is preceded with whitespace."/> + <message key="ws.illegalFollow" + value="GenericWhitespace ''{0}'' should followed by whitespace."/> + <message key="ws.notPreceded" + value="GenericWhitespace ''{0}'' is not preceded with whitespace."/> + </module> + <module name="Indentation"> + <property name="basicOffset" value="2"/> + <property name="braceAdjustment" value="2"/> + <property name="caseIndent" value="2"/> + <property name="throwsIndent" value="4"/> + <property name="lineWrappingIndentation" value="4"/> + <property name="arrayInitIndent" value="2"/> + </module> + <!-- Suppression for block code until we find a way to detect them properly + until https://github.com/checkstyle/checkstyle/issues/15769 --> + <module name="SuppressionXpathSingleFilter"> + <property name="checks" value="Indentation"/> + <property name="query" value="//SLIST[not(parent::CASE_GROUP)]/SLIST + | //SLIST[not(parent::CASE_GROUP)]/SLIST/RCURLY"/> + </module> + <module name="AbbreviationAsWordInName"> + <property name="ignoreFinal" value="false"/> + <property name="allowedAbbreviationLength" value="0"/> + <property name="tokens" + value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF, + PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF, PATTERN_VARIABLE_DEF, RECORD_DEF, + RECORD_COMPONENT_DEF"/> + </module> + <module name="NoWhitespaceBeforeCaseDefaultColon"/> + <module name="OverloadMethodsDeclarationOrder"/> + <module name="ConstructorsDeclarationGrouping"/> + <module name="VariableDeclarationUsageDistance"/> + <module name="CustomImportOrder"> + <property name="sortImportsInGroupAlphabetically" value="true"/> + <property name="separateLineBetweenGroups" value="true"/> + <property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/> + <property name="tokens" value="IMPORT, STATIC_IMPORT, PACKAGE_DEF"/> + </module> + <module name="MethodParamPad"> + <property name="tokens" + value="CTOR_DEF, LITERAL_NEW, METHOD_CALL, METHOD_DEF, CTOR_CALL, + SUPER_CTOR_CALL, ENUM_CONSTANT_DEF, RECORD_DEF, RECORD_PATTERN_DEF"/> + </module> + <module name="NoWhitespaceBefore"> + <property name="tokens" + value="COMMA, SEMI, POST_INC, POST_DEC, DOT, + LABELED_STAT, METHOD_REF"/> + <property name="allowLineBreaks" value="true"/> + </module> + <module name="ParenPad"> + <property name="tokens" + value="ANNOTATION, ANNOTATION_FIELD_DEF, CTOR_CALL, CTOR_DEF, DOT, ENUM_CONSTANT_DEF, + EXPR, LITERAL_CATCH, LITERAL_DO, LITERAL_FOR, LITERAL_IF, LITERAL_NEW, + LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_WHILE, METHOD_CALL, + METHOD_DEF, QUESTION, RESOURCE_SPECIFICATION, SUPER_CTOR_CALL, LAMBDA, + RECORD_DEF, RECORD_PATTERN_DEF"/> + </module> + <module name="OperatorWrap"> + <property name="option" value="NL"/> + <property name="tokens" + value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, + LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR, METHOD_REF, + TYPE_EXTENSION_AND "/> + </module> + <module name="AnnotationLocation"> + <property name="id" value="AnnotationLocationMostCases"/> + <property name="tokens" + value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, + RECORD_DEF, COMPACT_CTOR_DEF"/> + </module> + <module name="AnnotationLocation"> + <property name="id" value="AnnotationLocationVariables"/> + <property name="tokens" value="VARIABLE_DEF"/> + <property name="allowSamelineMultipleAnnotations" value="true"/> + </module> + <module name="NonEmptyAtclauseDescription"/> + <module name="InvalidJavadocPosition"/> + <module name="JavadocTagContinuationIndentation"/> + <module name="SummaryJavadoc"> + <property name="forbiddenSummaryFragments" + value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/> + </module> + <module name="JavadocParagraph"> + <property name="allowNewlineParagraph" value="false"/> + </module> + <module name="RequireEmptyLineBeforeBlockTagGroup"/> + <module name="AtclauseOrder"> + <property name="tagOrder" value="@param, @return, @throws, @deprecated"/> + <property name="target" + value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/> + </module> + <module name="JavadocMethod"> + <property name="accessModifiers" value="public"/> + <property name="allowMissingParamTags" value="true"/> + <property name="allowMissingReturnTag" value="true"/> + <property name="allowedAnnotations" value="Override, Test"/> + <property name="tokens" value="METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF, COMPACT_CTOR_DEF"/> + </module> + <module name="MissingJavadocMethod"> + <property name="scope" value="protected"/> + <property name="allowMissingPropertyJavadoc" value="true"/> + <property name="allowedAnnotations" value="Override, Test"/> + <property name="tokens" value="METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF, + COMPACT_CTOR_DEF"/> + </module> + <module name="SuppressionXpathSingleFilter"> + <property name="checks" value="MissingJavadocMethod"/> + <property name="query" value="//*[self::METHOD_DEF or self::CTOR_DEF + or self::ANNOTATION_FIELD_DEF or self::COMPACT_CTOR_DEF] + [ancestor::*[self::INTERFACE_DEF or self::CLASS_DEF + or self::RECORD_DEF or self::ENUM_DEF] + [not(./MODIFIERS/LITERAL_PUBLIC)]]"/> + </module> + <module name="MissingJavadocType"> + <property name="scope" value="protected"/> + <property name="tokens" + value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, + RECORD_DEF, ANNOTATION_DEF"/> + <property name="excludeScope" value="nothing"/> + </module> + <module name="MethodName"> + <property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/> + <message key="name.invalidPattern" + value="Method name ''{0}'' must match pattern ''{1}''."/> + </module> + <module name="SuppressionXpathSingleFilter"> + <property name="checks" value="MethodName"/> + <property name="query" value="//METHOD_DEF[ + ./MODIFIERS/ANNOTATION//IDENT[contains(@text, 'Test')] + ]/IDENT"/> + <property name="message" value="'[a-z][a-z0-9][a-zA-Z0-9]*(?:_[a-z][a-z0-9][a-zA-Z0-9]*)*'"/> + </module> + <module name="SingleLineJavadoc"/> + <module name="EmptyCatchBlock"> + <property name="exceptionVariableName" value="expected"/> + </module> + <module name="CommentsIndentation"> + <property name="tokens" value="SINGLE_LINE_COMMENT, BLOCK_COMMENT_BEGIN"/> + </module> + <!-- https://checkstyle.org/filters/suppressionxpathfilter.html --> + <module name="SuppressionXpathFilter"> + <property name="file" value="${org.checkstyle.google.suppressionxpathfilter.config}" + default="checkstyle-xpath-suppressions.xml" /> + <property name="optional" value="true"/> + </module> + <module name="SuppressWarningsHolder" /> + <module name="SuppressionCommentFilter"> + <property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)" /> + <property name="onCommentFormat" value="CHECKSTYLE.ON\: ([\w\|]+)" /> + <property name="checkFormat" value="$1" /> + </module> + <module name="SuppressWithNearbyCommentFilter"> + <property name="commentFormat" value="CHECKSTYLE.SUPPRESS\: ([\w\|]+)"/> + <!-- $1 refers to the first match group in the regex defined in commentFormat --> + <property name="checkFormat" value="$1"/> + <!-- The check is suppressed in the next line of code after the comment --> + <property name="influenceFormat" value="1"/> + </module> + </module> +</module> diff --git a/src/main/resources/pmd-ruleset.xml b/src/main/resources/pmd-ruleset.xml new file mode 100644 index 0000000..43bcbf8 --- /dev/null +++ b/src/main/resources/pmd-ruleset.xml @@ -0,0 +1,323 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ruleset name="quickstart" + 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>Quickstart configuration of PMD. Includes the rules that are most likely to apply everywhere.</description> + + <!-- <rule ref="category/java/bestpractices.xml/AbstractClassWithoutAbstractMethod" /> --> + <!-- <rule ref="category/java/bestpractices.xml/AccessorClassGeneration" /> --> + <!-- <rule ref="category/java/bestpractices.xml/AccessorMethodGeneration" /> --> + <!-- <rule ref="category/java/bestpractices.xml/ArrayIsStoredDirectly" /> --> + <!-- <rule ref="category/java/bestpractices.xml/AvoidPrintStackTrace" /> --> + <!-- <rule ref="category/java/bestpractices.xml/AvoidReassigningCatchVariables" /> --> + <!-- <rule ref="category/java/bestpractices.xml/AvoidReassigningLoopVariables" /> --> + <!-- <rule ref="category/java/bestpractices.xml/AvoidReassigningParameters" /> --> + <rule ref="category/java/bestpractices.xml/AvoidMessageDigestField"/> + <rule ref="category/java/bestpractices.xml/AvoidStringBufferField"/> + <rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP"/> + <rule ref="category/java/bestpractices.xml/CheckResultSet"/> + <rule ref="category/java/bestpractices.xml/ConstantsInInterface"/> + <rule ref="category/java/bestpractices.xml/DefaultLabelNotLastInSwitch"/> + <rule ref="category/java/bestpractices.xml/DoubleBraceInitialization"/> + <!-- <rule ref="category/java/bestpractices.xml/ExhaustiveSwitchHasDefault"/> --> + <rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach"/> + <!-- <rule ref="category/java/bestpractices.xml/ForLoopVariableCount" /> --> + <rule ref="category/java/bestpractices.xml/GuardLogStatement"/> + <!-- <rule ref="category/java/bestpractices.xml/JUnit4SuitesShouldUseSuiteAnnotation" /> --> + <!-- <rule ref="category/java/bestpractices.xml/JUnit5TestShouldBePackagePrivate" /> --> + <!-- <rule ref="category/java/bestpractices.xml/JUnitUseExpected" /> --> + <rule ref="category/java/bestpractices.xml/LiteralsFirstInComparisons" /> + <rule ref="category/java/bestpractices.xml/LooseCoupling"/> + <!-- <rule ref="category/java/bestpractices.xml/MethodReturnsInternalArray" /> --> + <rule ref="category/java/bestpractices.xml/MissingOverride"/> + <rule ref="category/java/bestpractices.xml/NonExhaustiveSwitch"/> + <rule ref="category/java/bestpractices.xml/OneDeclarationPerLine"/> + <rule ref="category/java/bestpractices.xml/PrimitiveWrapperInstantiation"/> + <rule ref="category/java/bestpractices.xml/PreserveStackTrace"/> + <!-- <rule ref="category/java/bestpractices.xml/ReplaceEnumerationWithIterator" /> --> + <!-- <rule ref="category/java/bestpractices.xml/ReplaceHashtableWithMap" /> --> + <!-- <rule ref="category/java/bestpractices.xml/ReplaceVectorWithList" /> --> + <rule ref="category/java/bestpractices.xml/SimplifiableTestAssertion"/> + <!-- <rule ref="category/java/bestpractices.xml/SystemPrintln" /> --> + <!-- <rule ref="category/java/bestpractices.xml/UnitTestAssertionsShouldIncludeMessage" /> --> + <!-- <rule ref="category/java/bestpractices.xml/UnitTestContainsTooManyAsserts" /> --> + <!-- <rule ref="category/java/bestpractices.xml/UnitTestShouldIncludeAssert" /> --> + <!-- <rule ref="category/java/bestpractices.xml/UnitTestShouldUseAfterAnnotation" /> --> + <!-- <rule ref="category/java/bestpractices.xml/UnitTestShouldUseBeforeAnnotation" /> --> + <!-- <rule ref="category/java/bestpractices.xml/UnitTestShouldUseTestAnnotation" /> --> + <!-- <rule ref="category/java/bestpractices.xml/UnnecessaryVarargsArrayCreation" /> --> + <!-- <rule ref="category/java/bestpractices.xml/UnusedAssignment"/> --> + <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/UseCollectionIsEmpty"/> + <!-- <rule ref="category/java/bestpractices.xml/UseEnumCollections"/> --> + <rule ref="category/java/bestpractices.xml/UseStandardCharsets" /> + <!-- <rule ref="category/java/bestpractices.xml/UseTryWithResources" /> --> + <!-- <rule ref="category/java/bestpractices.xml/UseVarargs" /> --> + <!-- <rule ref="category/java/bestpractices.xml/WhileLoopWithLiteralBoolean" /> --> + + + <!-- NAMING CONVENTIONS --> + <rule ref="category/java/codestyle.xml/ClassNamingConventions"/> + <!--<rule ref="category/java/codestyle.xml/FieldNamingConventions" />--> + <rule ref="category/java/codestyle.xml/FormalParameterNamingConventions"/> + <rule ref="category/java/codestyle.xml/GenericsNaming"/> + <rule ref="category/java/codestyle.xml/LambdaCanBeMethodReference"/> + <!-- <rule ref="category/java/codestyle.xml/LinguisticNaming" /> --> + <rule ref="category/java/codestyle.xml/LocalVariableNamingConventions"/> + <!-- <rule ref="category/java/codestyle.xml/LongVariable" /> --> + <rule ref="category/java/codestyle.xml/MethodNamingConventions"/> + <rule ref="category/java/codestyle.xml/PackageCase"/> + <!-- <rule ref="category/java/codestyle.xml/ShortClassName" /> --> + <!-- <rule ref="category/java/codestyle.xml/ShortMethodName" /> --> + <!-- <rule ref="category/java/codestyle.xml/ShortVariable" /> --> + + <!-- <rule ref="category/java/codestyle.xml/LocalHomeNamingConvention" /> --> + <!-- <rule ref="category/java/codestyle.xml/LocalInterfaceSessionNamingConvention" /> --> + <!-- <rule ref="category/java/codestyle.xml/MDBAndSessionBeanNamingConvention" /> --> + <!-- <rule ref="category/java/codestyle.xml/RemoteInterfaceNamingConvention" /> --> + <!-- <rule ref="category/java/codestyle.xml/RemoteSessionInterfaceNamingConvention" /> --> + + <!-- OTHER --> + <!-- <rule ref="category/java/codestyle.xml/AtLeastOneConstructor" /> --> + <rule ref="category/java/codestyle.xml/AvoidDollarSigns"/> + <rule ref="category/java/codestyle.xml/AvoidProtectedFieldInFinalClass"/> + <rule ref="category/java/codestyle.xml/AvoidProtectedMethodInFinalClassNotExtending"/> + <!-- <rule ref="category/java/codestyle.xml/AvoidUsingNativeCode"/>--> + <!-- <rule ref="category/java/codestyle.xml/BooleanGetMethodName" /> --> + <!-- <rule ref="category/java/codestyle.xml/CallSuperInConstructor" /> --> + <!-- <rule ref="category/java/codestyle.xml/CommentDefaultAccessModifier" /> --> + <!-- <rule ref="category/java/codestyle.xml/ConfusingTernary" /> --> + <rule ref="category/java/codestyle.xml/ControlStatementBraces"/> + <!-- <rule ref="category/java/codestyle.xml/EmptyMethodInAbstractClassShouldBeAbstract" /> --> + <rule ref="category/java/codestyle.xml/ExtendsObject"/> + <!-- <rule ref="category/java/codestyle.xml/FieldDeclarationsShouldBeAtStartOfClass" /> --> + <rule ref="category/java/codestyle.xml/FinalParameterInAbstractMethod"/> + <rule ref="category/java/codestyle.xml/ForLoopShouldBeWhileLoop"/> + <rule ref="category/java/codestyle.xml/IdenticalCatchBranches"/> + <!-- <rule ref="category/java/codestyle.xml/LocalVariableCouldBeFinal" /> --> + <!-- <rule ref="category/java/codestyle.xml/MethodArgumentCouldBeFinal" /> --> + <rule ref="category/java/codestyle.xml/NoPackage"/> + <!-- <rule ref="category/java/codestyle.xml/UseExplicitTypes"/> --> + <!-- <rule ref="category/java/codestyle.xml/UseUnderscoresInNumericLiterals" /> --> + <!-- <rule ref="category/java/codestyle.xml/OnlyOneReturn" /> --> + <!-- <rule ref="category/java/codestyle.xml/PrematureDeclaration" /> --> + <!-- <rule ref="category/java/codestyle.xml/TooManyStaticImports" /> --> + <rule ref="category/java/codestyle.xml/UnnecessaryAnnotationValueElement"/> + <!-- <rule ref="category/java/codestyle.xml/UnnecessaryBoxing" /> --> + <!-- <rule ref="category/java/codestyle.xml/UnnecessaryCast" /> --> + <rule ref="category/java/codestyle.xml/UnnecessaryConstructor"/> + <rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName"/> + <rule ref="category/java/codestyle.xml/UnnecessaryImport" /> + <rule ref="category/java/codestyle.xml/UnnecessaryLocalBeforeReturn"/> + <rule ref="category/java/codestyle.xml/UnnecessaryModifier"/> + <rule ref="category/java/codestyle.xml/UnnecessaryReturn"/> + <!-- <rule ref="category/java/codestyle.xml/UseDiamondOperator" /> --> + <rule ref="category/java/codestyle.xml/UselessParentheses"/> + <rule ref="category/java/codestyle.xml/UselessQualifiedThis"/> + + + <rule ref="category/java/design.xml/AbstractClassWithoutAnyMethod"/> + <!-- <rule ref="category/java/design.xml/AvoidCatchingGenericException" /> --> + <!-- <rule ref="category/java/design.xml/AvoidDeeplyNestedIfStmts" /> --> + <!-- <rule ref="category/java/design.xml/AvoidRethrowingException" /> --> + <!-- <rule ref="category/java/design.xml/AvoidThrowingNewInstanceOfSameException" /> --> + <!--<rule ref="category/java/design.xml/AvoidThrowingNullPointerException" />--> + <!-- <rule ref="category/java/design.xml/AvoidThrowingRawExceptionTypes" /> --> + <!-- <rule ref="category/java/design.xml/AvoidUncheckedExceptionsInSignatures" /> --> + <rule ref="category/java/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal"/> + <!-- <rule ref="category/java/design.xml/CognitiveComplexity" /> --> + <!-- <rule ref="category/java/design.xml/CollapsibleIfStatements"/>--> + <!-- <rule ref="category/java/design.xml/CouplingBetweenObjects" /> --> + <!-- <rule ref="category/java/design.xml/CyclomaticComplexity" /> --> + <!-- <rule ref="category/java/design.xml/DataClass" /> --> + <rule ref="category/java/design.xml/DoNotExtendJavaLangError" /> + <!-- <rule ref="category/java/design.xml/ExceptionAsFlowControl" /> --> + <!-- <rule ref="category/java/design.xml/ExcessiveImports" /> --> + <!-- <rule ref="category/java/design.xml/ExcessiveParameterList" /> --> + <!-- <rule ref="category/java/design.xml/ExcessivePublicCount" /> --> + <rule ref="category/java/design.xml/FinalFieldCouldBeStatic"/> + <!-- <rule ref="category/java/design.xml/GodClass" /> --> + <!-- <rule ref="category/java/design.xml/ImmutableField" /> --> + <!-- <rule ref="category/java/design.xml/InvalidJavaBean">--> + <!-- <properties>--> + <!-- <property name="packages" value="org.example.beans" />--> + <!-- </properties>--> + <!-- </rule>--> + <!-- <rule ref="category/java/design.xml/LawOfDemeter" /> --> + <rule ref="category/java/design.xml/LogicInversion"/> + <!-- <rule ref="category/java/design.xml/LoosePackageCoupling"> --> + <!-- <properties> --> + <!-- <property name="packages" value="org.sample,org.sample2" /> --> + <!-- <property name="classes" value="org.sample.SampleInterface,org.sample2.SampleInterface" /> --> + <!-- </properties> --> + <!-- </rule> --> + <!-- <rule ref="category/java/design.xml/MutableStaticState" /> --> + <!-- <rule ref="category/java/design.xml/NcssCount" /> --> + <!-- <rule ref="category/java/design.xml/NPathComplexity" /> --> + <!-- <rule ref="category/java/design.xml/SignatureDeclareThrowsException" /> --> + <rule ref="category/java/design.xml/SimplifiedTernary"/> + <!-- <rule ref="category/java/design.xml/SimplifyBooleanExpressions" /> --> + <rule ref="category/java/design.xml/SimplifyBooleanReturns"/> + <rule ref="category/java/design.xml/SimplifyConditional"/> + <rule ref="category/java/design.xml/SingularField"/> + <!-- <rule ref="category/java/design.xml/SwitchDensity" /> --> + <!-- <rule ref="category/java/design.xml/TooManyFields" /> --> + <!-- <rule ref="category/java/design.xml/TooManyMethods" /> --> + <rule ref="category/java/design.xml/UselessOverridingMethod"/> + <!-- <rule ref="category/java/design.xml/UseObjectForClearerAPI" /> --> + <rule ref="category/java/design.xml/UseUtilityClass"/> + + + <!-- <rule ref="category/java/documentation.xml/CommentContent" /> --> + <!-- <rule ref="category/java/documentation.xml/CommentRequired" /> --> + <!-- <rule ref="category/java/documentation.xml/CommentSize" /> --> + <rule ref="category/java/documentation.xml/UncommentedEmptyConstructor"/> + <rule ref="category/java/documentation.xml/UncommentedEmptyMethodBody"/> + + + + <rule ref="category/java/errorprone.xml/AssignmentInOperand"> + <properties> + <property name="allowWhile" value="true"/> + </properties> + </rule> + <rule ref="category/java/errorprone.xml/AssignmentToNonFinalStatic"/> + <rule ref="category/java/errorprone.xml/AvoidAccessibilityAlteration"/> + <!-- <rule ref="category/java/errorprone.xml/AvoidAssertAsIdentifier" /> --> + <rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop"/> + <!-- <rule ref="category/java/errorprone.xml/AvoidCallingFinalize" /> --> + <!-- <rule ref="category/java/errorprone.xml/AvoidCatchingNPE" /> --> + <rule ref="category/java/errorprone.xml/AvoidCatchingThrowable"/> + <rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor"/> + <!-- <rule ref="category/java/errorprone.xml/AvoidDuplicateLiterals" /> --> + <!-- <rule ref="category/java/errorprone.xml/AvoidEnumAsIdentifier" /> --> + <!-- <rule ref="category/java/errorprone.xml/AvoidFieldNameMatchingMethodName" /> --> + <!-- <rule ref="category/java/errorprone.xml/AvoidFieldNameMatchingTypeName" /> --> + <rule ref="category/java/errorprone.xml/AvoidInstanceofChecksInCatchClause"/> + <!-- <rule ref="category/java/errorprone.xml/AvoidLiteralsInIfCondition" /> --> + <!-- <rule ref="category/java/errorprone.xml/AvoidLosingExceptionInformation" /> --> + <rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators"/> + <rule ref="category/java/errorprone.xml/AvoidUsingOctalValues"/> + <!-- <rule ref="category/java/errorprone.xml/BeanMembersShouldSerialize" /> --> + <rule ref="category/java/errorprone.xml/BrokenNullCheck"/> + <!-- <rule ref="category/java/errorprone.xml/CallSuperFirst" /> --> + <!-- <rule ref="category/java/errorprone.xml/CallSuperLast" /> --> + <rule ref="category/java/errorprone.xml/CheckSkipResult"/> + <rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray"/> + <rule ref="category/java/errorprone.xml/CloneMethodMustBePublic"/> + <rule ref="category/java/errorprone.xml/CloneMethodMustImplementCloneable"/> + <rule ref="category/java/errorprone.xml/CloneMethodReturnTypeMustMatchClassName"/> + <!-- <rule ref="category/java/errorprone.xml/CloneThrowsCloneNotSupportedException"/> deprecated since 6.35.0 --> + <rule ref="category/java/errorprone.xml/CloseResource"/> + <!-- <rule ref="category/java/errorprone.xml/ConfusingArgumentToVarargsMethod"/> --> + <rule ref="category/java/errorprone.xml/CompareObjectsWithEquals"/> + <rule ref="category/java/errorprone.xml/ComparisonWithNaN"/> + <!-- <rule ref="category/java/errorprone.xml/ConstructorCallsOverridableMethod" /> --> + <!-- <rule ref="category/java/errorprone.xml/DataflowAnomalyAnalysis" /> --> + <!-- <rule ref="category/java/errorprone.xml/DetachedTestCase" /> --> + <rule ref="category/java/errorprone.xml/DoNotCallGarbageCollectionExplicitly"/> + <!-- <rule ref="category/java/errorprone.xml/DoNotCallSystemExit" /> --> + <rule ref="category/java/errorprone.xml/DoNotExtendJavaLangThrowable"/> + <!-- <rule ref="category/java/errorprone.xml/DoNotHardCodeSDCard" /> --> + <!-- <rule ref="category/java/errorprone.xml/DoNotThrowExceptionInFinally" /> --> + <!--<rule ref="category/java/errorprone.xml/DontImportSun" />--> + <rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices"/> + <rule ref="category/java/errorprone.xml/EqualsNull"/> + <!-- <rule ref="category/java/errorprone.xml/FinalizeDoesNotCallSuperFinalize" /> --> + <!-- <rule ref="category/java/errorprone.xml/FinalizeOnlyCallsSuperFinalize" /> --> + <!-- <rule ref="category/java/errorprone.xml/FinalizeOverloaded" /> --> + <!-- <rule ref="category/java/errorprone.xml/FinalizeShouldBeProtected" /> --> + <rule ref="category/java/errorprone.xml/IdempotentOperations"/> + <rule ref="category/java/errorprone.xml/ImplicitSwitchFallThrough"/> + <rule ref="category/java/errorprone.xml/InstantiationToGetClass"/> + <!-- <rule ref="category/java/errorprone.xml/InvalidLogMessageFormat" /> --> + <rule ref="category/java/errorprone.xml/JumbledIncrementer"/> + <!-- <rule ref="category/java/errorprone.xml/JUnitSpelling" /> --> + <!-- <rule ref="category/java/errorprone.xml/JUnitStaticSuite" /> --> + <!-- <rule ref="category/java/errorprone.xml/LoggerIsNotStaticFinal" /> --> + <!-- <rule ref="category/java/errorprone.xml/MethodWithSameNameAsEnclosingClass" /> --> + <rule ref="category/java/errorprone.xml/MisplacedNullCheck"/> + <!-- <rule ref="category/java/errorprone.xml/MissingSerialVersionUID" /> --> + <rule ref="category/java/errorprone.xml/MissingStaticMethodInNonInstantiatableClass"/> + <!-- <rule ref="category/java/errorprone.xml/MoreThanOneLogger" /> --> + <rule ref="category/java/errorprone.xml/NonCaseLabelInSwitch"/> + <rule ref="category/java/errorprone.xml/NonStaticInitializer"/> + <!-- <rule ref="category/java/errorprone.xml/NullAssignment" /> --> + <rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode"/> + <rule ref="category/java/errorprone.xml/ProperCloneImplementation"/> + <rule ref="category/java/errorprone.xml/ProperLogger"/> + <rule ref="category/java/errorprone.xml/ReturnEmptyCollectionRatherThanNull"/> + <rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock"/> + <!-- <rule ref="category/java/errorprone.xml/SimpleDateFormatNeedsLocale" /> --> + <rule ref="category/java/errorprone.xml/SingleMethodSingleton"/> + <rule ref="category/java/errorprone.xml/SingletonClassReturningNewInstance"/> + <!-- <rule ref="category/java/errorprone.xml/StaticEJBFieldShouldBeFinal" /> --> + <!-- <rule ref="category/java/errorprone.xml/StringBufferInstantiationWithChar" /> --> + <rule ref="category/java/errorprone.xml/SuspiciousEqualsMethodName"/> + <rule ref="category/java/errorprone.xml/SuspiciousHashcodeMethodName"/> + <rule ref="category/java/errorprone.xml/SuspiciousOctalEscape"/> + <!-- <rule ref="category/java/errorprone.xml/TestClassWithoutTestCases" /> --> + <rule ref="category/java/errorprone.xml/UnconditionalIfStatement"/> + <!-- <rule ref="category/java/errorprone.xml/UnnecessaryBooleanAssertion" /> --> + <!-- <rule ref="category/java/errorprone.xml/UnnecessaryCaseChange" /> --> + <rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary"/> + <rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals"/> + <!-- <rule ref="category/java/errorprone.xml/UseCorrectExceptionLogging" /> --> + <rule ref="category/java/errorprone.xml/UseEqualsToCompareStrings"/> + <rule ref="category/java/errorprone.xml/UselessOperationOnImmutable"/> + <rule ref="category/java/errorprone.xml/UseLocaleWithCaseConversions"/> + <!-- <rule ref="category/java/errorprone.xml/UseProperClassLoader" /> --> + + <!-- Empty rules --> + <rule ref="category/java/codestyle.xml/EmptyControlStatement"/> + <rule ref="category/java/codestyle.xml/UnnecessarySemicolon"/> + <rule ref="category/java/errorprone.xml/EmptyCatchBlock"/> + <rule ref="category/java/errorprone.xml/EmptyFinalizer"/> + + + <!-- <rule ref="category/java/multithreading.xml/AvoidSynchronizedAtMethodLevel" /> --> + <!-- <rule ref="category/java/multithreading.xml/AvoidSynchronizedStatement" /> --> + <rule ref="category/java/multithreading.xml/AvoidThreadGroup"/> + <rule ref="category/java/multithreading.xml/AvoidUsingVolatile"/> + <!-- <rule ref="category/java/multithreading.xml/DoNotUseThreads" /> --> + <rule ref="category/java/multithreading.xml/DontCallThreadRun"/> + <rule ref="category/java/multithreading.xml/DoubleCheckedLocking"/> + <rule ref="category/java/multithreading.xml/NonThreadSafeSingleton"/> + <rule ref="category/java/multithreading.xml/UnsynchronizedStaticFormatter"/> + <!-- <rule ref="category/java/multithreading.xml/UseConcurrentHashMap" /> --> + <rule ref="category/java/multithreading.xml/UseNotifyAllInsteadOfNotify"/> + + + <!-- <rule ref="category/java/performance.xml/AddEmptyString" /> --> + <!-- <rule ref="category/java/performance.xml/AppendCharacterWithChar" /> --> + <!-- <rule ref="category/java/performance.xml/AvoidArrayLoops" /> --> + <!-- <rule ref="category/java/performance.xml/AvoidCalendarDateCreation" /> --> + <!-- <rule ref="category/java/performance.xml/AvoidFileStream" /> --> + <!-- <rule ref="category/java/performance.xml/AvoidInstantiatingObjectsInLoops" /> --> + <rule ref="category/java/performance.xml/BigIntegerInstantiation"/> + <!-- <rule ref="category/java/performance.xml/ConsecutiveAppendsShouldReuse" /> --> + <!-- <rule ref="category/java/performance.xml/ConsecutiveLiteralAppends" /> --> + <!-- <rule ref="category/java/performance.xml/InefficientEmptyStringCheck" /> --> + <!-- <rule ref="category/java/performance.xml/InefficientStringBuffering" /> --> + <!-- <rule ref="category/java/performance.xml/InsufficientStringBufferDeclaration" /> --> + <rule ref="category/java/performance.xml/OptimizableToArrayCall"/> + <!--<rule ref="category/java/performance.xml/RedundantFieldInitializer"/>--> + <!-- <rule ref="category/java/performance.xml/StringInstantiation" /> --> + <!-- <rule ref="category/java/performance.xml/StringToString" /> --> + <!-- <rule ref="category/java/performance.xml/TooFewBranchesForSwitch"/> --> + <!-- <rule ref="category/java/performance.xml/UseArrayListInsteadOfVector" /> --> + <!-- <rule ref="category/java/performance.xml/UseArraysAsList" /> --> + <!-- <rule ref="category/java/performance.xml/UseIndexOfChar" /> --> + <!-- <rule ref="category/java/performance.xml/UseIOStreamsWithApacheCommonsFileItem" /> --> + <!-- <rule ref="category/java/performance.xml/UselessStringValueOf" /> --> + <!-- <rule ref="category/java/performance.xml/UseStringBufferForStringAppends" /> --> + <!-- <rule ref="category/java/performance.xml/UseStringBufferLength" /> --> + + + <!-- <rule ref="category/java/security.xml/HardCodedCryptoKey" /> --> + <!-- <rule ref="category/java/security.xml/InsecureCryptoIv" /> --> +</ruleset> -- GitLab From 52cf443d070527b00b06955ae858a59b63627953 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Thu, 6 Mar 2025 22:44:11 +0100 Subject: [PATCH 02/51] [#12001] repair pipeline no. 1 --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4fab6a0..8e846c4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,7 @@ -image: maven:3.9.6-eclipse-temurin-23 +default: + image: maven:3.9.6-eclipse-temurin-23 + tags: + - shared stages: - pmd -- GitLab From 30032c023ab11c9c5f09436e8a9dff58ec875971 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Thu, 6 Mar 2025 23:14:32 +0100 Subject: [PATCH 03/51] [#12001] pipeline change of image --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8e846c4..b30762b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ default: - image: maven:3.9.6-eclipse-temurin-23 + image: maven:3.9.9-eclipse-temurin-23-alpine tags: - shared -- GitLab From f6b82ca466e86ef973351066c2cb7694a6c9b44b Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Thu, 6 Mar 2025 23:18:06 +0100 Subject: [PATCH 04/51] spusteni jen PMD --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b30762b..1f4bfc0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,8 +17,9 @@ cache: pmd_analysis: stage: pmd script: - - mvn $MAVEN_CLI_OPTS clean verify + - mvn $MAVEN_CLI_OPTS clean verify -DskipTests pmd:pmd artifacts: paths: - target/pmd-reports/ expire_in: 1 week + -- GitLab From 461fc1790684482a36fcbefcaccd9bca5c72ade0 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Thu, 6 Mar 2025 23:26:51 +0100 Subject: [PATCH 05/51] [#12001] repair pipeline mvn command --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1f4bfc0..e407b6c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,6 @@ stages: - pmd variables: - MAVEN_CLI_OPTS: "--batch-mode --errors --fail-fast --show-version" MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository" cache: @@ -17,7 +16,7 @@ cache: pmd_analysis: stage: pmd script: - - mvn $MAVEN_CLI_OPTS clean verify -DskipTests pmd:pmd + - mvn pmd:check artifacts: paths: - target/pmd-reports/ -- GitLab From 03e48ff043003bac2293efb8e2e8884a9a181ca4 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 10:29:55 +0100 Subject: [PATCH 06/51] cicd added violation-comments-to-gitlab-command-line --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e407b6c..5ff2e73 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,10 @@ cache: pmd_analysis: stage: pmd script: - - mvn pmd:check + - mvn pmd:check # Run PMD analysis + - apk add --no-cache npm # Install npm only + - npm install -g violation-comments-to-gitlab-command-line + - npx violation-comments-to-gitlab-command-line -at $CICD_BOT_TOKEN -gitlab-url "https://gitlab-vyuka.kiv.zcu.cz" -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" artifacts: paths: - target/pmd-reports/ -- GitLab From 8cae305ff27ab8e149f5a4b5556084c5f022f0e6 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 10:30:53 +0100 Subject: [PATCH 07/51] repair url --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5ff2e73..24f1ff1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,7 +19,7 @@ pmd_analysis: - mvn pmd:check # Run PMD analysis - apk add --no-cache npm # Install npm only - npm install -g violation-comments-to-gitlab-command-line - - npx violation-comments-to-gitlab-command-line -at $CICD_BOT_TOKEN -gitlab-url "https://gitlab-vyuka.kiv.zcu.cz" -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" + - npx violation-comments-to-gitlab-command-line -at $CICD_BOT_TOKEN -gitlab-url "https://gitlab.kiv.zcu.cz/" -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" artifacts: paths: - target/pmd-reports/ -- GitLab From 64f0192a92236c860a6300dec8216f3e46fe91e8 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 10:33:17 +0100 Subject: [PATCH 08/51] cicd removed redundant PMD attribute --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 24f1ff1..d11c054 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,7 +19,7 @@ pmd_analysis: - mvn pmd:check # Run PMD analysis - apk add --no-cache npm # Install npm only - npm install -g violation-comments-to-gitlab-command-line - - npx violation-comments-to-gitlab-command-line -at $CICD_BOT_TOKEN -gitlab-url "https://gitlab.kiv.zcu.cz/" -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" + - npx violation-comments-to-gitlab-command-line -at $CICD_BOT_TOKEN -gitlab-url "https://gitlab.kiv.zcu.cz/" -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" artifacts: paths: - target/pmd-reports/ -- GitLab From 34e467be902d68f6320fc280d611221a6dc65620 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 10:48:58 +0100 Subject: [PATCH 09/51] [#12001] Run script only if is MR --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d11c054..9465b80 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,4 +24,5 @@ pmd_analysis: paths: - target/pmd-reports/ expire_in: 1 week - + rules: + - if: $CI_MERGE_REQUEST_ID # Run only on merge requests -- GitLab From d1d37cc056c4b92980ad7a99fe452e2924d237ab Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 10:51:57 +0100 Subject: [PATCH 10/51] [#12001] auto PMD comment, added argument --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9465b80..ee5d19c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,7 +19,7 @@ pmd_analysis: - mvn pmd:check # Run PMD analysis - apk add --no-cache npm # Install npm only - npm install -g violation-comments-to-gitlab-command-line - - npx violation-comments-to-gitlab-command-line -at $CICD_BOT_TOKEN -gitlab-url "https://gitlab.kiv.zcu.cz/" -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" + - npx violation-comments-to-gitlab-command-line -at $CICD_BOT_TOKEN -gitlab-url "https://gitlab.kiv.zcu.cz/" -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" artifacts: paths: - target/pmd-reports/ -- GitLab From d17c07db9276586a3a814949ed627004ca9a0b6d Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 10:58:05 +0100 Subject: [PATCH 11/51] [#12001] PMD auto-comment, all also previous problems --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ee5d19c..1a70c96 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,7 +19,7 @@ pmd_analysis: - mvn pmd:check # Run PMD analysis - apk add --no-cache npm # Install npm only - npm install -g violation-comments-to-gitlab-command-line - - npx violation-comments-to-gitlab-command-line -at $CICD_BOT_TOKEN -gitlab-url "https://gitlab.kiv.zcu.cz/" -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" + - npx violation-comments-to-gitlab-command-line comment-only-changed-files false -at $CICD_BOT_TOKEN -gitlab-url "https://gitlab.kiv.zcu.cz/" -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" artifacts: paths: - target/pmd-reports/ -- GitLab From c17952de6f8dfe322b61ea7d880f2f27ef1b1f72 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 10:59:46 +0100 Subject: [PATCH 12/51] [#12001] PMD comment all problems --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1a70c96..c4cfa6e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,7 +19,7 @@ pmd_analysis: - mvn pmd:check # Run PMD analysis - apk add --no-cache npm # Install npm only - npm install -g violation-comments-to-gitlab-command-line - - npx violation-comments-to-gitlab-command-line comment-only-changed-files false -at $CICD_BOT_TOKEN -gitlab-url "https://gitlab.kiv.zcu.cz/" -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" + - npx violation-comments-to-gitlab-command-line -comment-only-changed-files false -at $CICD_BOT_TOKEN -gitlab-url "https://gitlab.kiv.zcu.cz/" -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" artifacts: paths: - target/pmd-reports/ -- GitLab From 49d3984bb00f1aa49975b22eb18c3a5cee4560d8 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 11:04:28 +0100 Subject: [PATCH 13/51] [#12001] CICD, auto comment all files --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c4cfa6e..3323e0a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,7 +19,7 @@ pmd_analysis: - mvn pmd:check # Run PMD analysis - apk add --no-cache npm # Install npm only - npm install -g violation-comments-to-gitlab-command-line - - npx violation-comments-to-gitlab-command-line -comment-only-changed-files false -at $CICD_BOT_TOKEN -gitlab-url "https://gitlab.kiv.zcu.cz/" -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" + - npx violation-comments-to-gitlab-command-line -comment-only-changed-content false -comment-only-changed-files false -at $CICD_BOT_TOKEN -gitlab-url "https://gitlab.kiv.zcu.cz/" -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" artifacts: paths: - target/pmd-reports/ -- GitLab From 9c7ddc7c5b61e03d43024f5da7ede0ffdd1bcc33 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 13:26:10 +0100 Subject: [PATCH 14/51] [#12001] pmd gitlab summary --- .gitlab-ci.yml | 2 ++ scripts/generate_pmd_summary.sh | 50 +++++++++++++++++++++++++++++++++ scripts/post_gitlab_comments.sh | 42 +++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 scripts/generate_pmd_summary.sh create mode 100644 scripts/post_gitlab_comments.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3323e0a..decc337 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,6 +20,8 @@ pmd_analysis: - apk add --no-cache npm # Install npm only - npm install -g violation-comments-to-gitlab-command-line - npx violation-comments-to-gitlab-command-line -comment-only-changed-content false -comment-only-changed-files false -at $CICD_BOT_TOKEN -gitlab-url "https://gitlab.kiv.zcu.cz/" -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" + - bash ./scripts/generate_pmd_summary.sh target/pmd.xml > pmd_report.md + - bash ./scripts/generate_pmd_summary.sh pmd_report.md artifacts: paths: - target/pmd-reports/ diff --git a/scripts/generate_pmd_summary.sh b/scripts/generate_pmd_summary.sh new file mode 100644 index 0000000..47c127b --- /dev/null +++ b/scripts/generate_pmd_summary.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# Function to generate the PMD summary report +generate_pmd_summary() { + # Parameters + PMD_REPORT_PATH=$1 + + # Ensure the PMD report exists + if [ ! -f "$PMD_REPORT_PATH" ]; then + echo "PMD report not found at $PMD_REPORT_PATH!" + exit 1 + fi + + # Generate the total count of violations using the local-name() function to ignore the namespace + total_violations=$(xmllint --xpath "count(//*[local-name()='violation'])" $PMD_REPORT_PATH) + + # Generate counts for each severity (assuming severity is defined in PMD report as priority) + high_violations=$(xmllint --xpath "count(//*[local-name()='violation'][@priority='1'])" $PMD_REPORT_PATH) + medium_violations=$(xmllint --xpath "count(//*[local-name()='violation'][@priority='2'])" $PMD_REPORT_PATH) + low_violations=$(xmllint --xpath "count(//*[local-name()='violation'][@priority='3'])" $PMD_REPORT_PATH) + + # Create badges for the severity levels using shields.io + high_badge="" + medium_badge="" + low_badge="" + + # Generate the styled overview report in Markdown format + overview_report="### PMD Violations Overview Report + +**Total Violations:** $total_violations +$high_badge +$medium_badge +$low_badge + +--- + +*Generated by CI/CD Pipeline*" + + # Output the overview report to standard output (can be piped to a file or another command) + echo -e "$overview_report" +} + +# Validate script arguments +if [ "$#" -lt 1 ]; then + echo "Usage: $0 <path-to-pmd-report>" + exit 1 +fi + +# Call the function with arguments +generate_pmd_summary "$1" diff --git a/scripts/post_gitlab_comments.sh b/scripts/post_gitlab_comments.sh new file mode 100644 index 0000000..4cdc27c --- /dev/null +++ b/scripts/post_gitlab_comments.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# Ensure that the necessary environment variable is set +if [ -z "$CICD_BOT_TOKEN" ]; then + echo "CICD_BOT_TOKEN environment variable is not set!" + exit 1 +fi + +# Ensure the required file parameter is provided +if [ -z "$1" ]; then + echo "No file provided for comment body!" + exit 1 +fi + +# Path to the file containing the comment content +COMMENT_FILE="$1" + +# Check if the file exists +if [ ! -f "$COMMENT_FILE" ]; then + echo "File not found: $COMMENT_FILE" + exit 1 +fi + +# Read the content of the file into the comment body +COMMENT_BODY=$(cat "$COMMENT_FILE") + +# GitLab API URL +GITLAB_API_URL="$GITLAB_BASE_URL/api/v4/projects/$CI_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID/notes" + +# Send the HTTP POST request to create a comment +http POST $GITLAB_API_URL \ + PRIVATE-TOKEN:$CICD_BOT_TOKEN \ + Content-Type:application/json \ + body="$COMMENT_BODY" + +# Check if the request was successful +if [ $? -eq 0 ]; then + echo "Comment successfully posted to Merge Request #$CI_MERGE_REQUEST_IID." +else + echo "Failed to post the comment." + exit 1 +fi -- GitLab From 7ed0500cdd0d370a59bad5d1cad65b18da9ee8d3 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 13:29:56 +0100 Subject: [PATCH 15/51] [#12001] install deps for CICD scripts --- .gitlab-ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index decc337..3698c46 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,13 +18,11 @@ pmd_analysis: script: - mvn pmd:check # Run PMD analysis - apk add --no-cache npm # Install npm only + - apk add --no-cache libxml2-utils # Install xmllint + - apk add --no-cache httpie # Install httpie - npm install -g violation-comments-to-gitlab-command-line - npx violation-comments-to-gitlab-command-line -comment-only-changed-content false -comment-only-changed-files false -at $CICD_BOT_TOKEN -gitlab-url "https://gitlab.kiv.zcu.cz/" -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" - bash ./scripts/generate_pmd_summary.sh target/pmd.xml > pmd_report.md - bash ./scripts/generate_pmd_summary.sh pmd_report.md - artifacts: - paths: - - target/pmd-reports/ - expire_in: 1 week rules: - if: $CI_MERGE_REQUEST_ID # Run only on merge requests -- GitLab From 92d7c62d3033c6cfb20f990b498af0ab95ca4ca0 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 13:32:20 +0100 Subject: [PATCH 16/51] [#12001] post MR comment CICD script --- .gitlab-ci.yml | 2 +- scripts/{post_gitlab_comments.sh => post_gitlab_mr_comment.sh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename scripts/{post_gitlab_comments.sh => post_gitlab_mr_comment.sh} (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3698c46..2d508a8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,6 +23,6 @@ pmd_analysis: - npm install -g violation-comments-to-gitlab-command-line - npx violation-comments-to-gitlab-command-line -comment-only-changed-content false -comment-only-changed-files false -at $CICD_BOT_TOKEN -gitlab-url "https://gitlab.kiv.zcu.cz/" -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" - bash ./scripts/generate_pmd_summary.sh target/pmd.xml > pmd_report.md - - bash ./scripts/generate_pmd_summary.sh pmd_report.md + - bash ./scripts/post_gitlab_mr_comment.sh pmd_report.md rules: - if: $CI_MERGE_REQUEST_ID # Run only on merge requests diff --git a/scripts/post_gitlab_comments.sh b/scripts/post_gitlab_mr_comment.sh similarity index 100% rename from scripts/post_gitlab_comments.sh rename to scripts/post_gitlab_mr_comment.sh -- GitLab From f1cc11252f56cefcce531192677e4088407265c6 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 13:35:24 +0100 Subject: [PATCH 17/51] [#12001] repair no. 1 post MR comment CICD script --- scripts/post_gitlab_mr_comment.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/post_gitlab_mr_comment.sh b/scripts/post_gitlab_mr_comment.sh index 4cdc27c..6bfea59 100644 --- a/scripts/post_gitlab_mr_comment.sh +++ b/scripts/post_gitlab_mr_comment.sh @@ -31,7 +31,7 @@ GITLAB_API_URL="$GITLAB_BASE_URL/api/v4/projects/$CI_PROJECT_ID/merge_requests/$ http POST $GITLAB_API_URL \ PRIVATE-TOKEN:$CICD_BOT_TOKEN \ Content-Type:application/json \ - body="$COMMENT_BODY" + body:="$COMMENT_BODY" --ignore-stdin # Check if the request was successful if [ $? -eq 0 ]; then -- GitLab From 9a2d0afae24b9b4a997f440c4304df3fb9188d7a Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 13:54:00 +0100 Subject: [PATCH 18/51] [#12001] repair no. 2 post MR comment CICD script --- scripts/generate_pmd_summary.sh | 2 +- scripts/post_gitlab_mr_comment.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/generate_pmd_summary.sh b/scripts/generate_pmd_summary.sh index 47c127b..d0c5eba 100644 --- a/scripts/generate_pmd_summary.sh +++ b/scripts/generate_pmd_summary.sh @@ -25,7 +25,7 @@ generate_pmd_summary() { low_badge="" # Generate the styled overview report in Markdown format - overview_report="### PMD Violations Overview Report + overview_report="### PMD Overview Report **Total Violations:** $total_violations $high_badge diff --git a/scripts/post_gitlab_mr_comment.sh b/scripts/post_gitlab_mr_comment.sh index 6bfea59..4cdc27c 100644 --- a/scripts/post_gitlab_mr_comment.sh +++ b/scripts/post_gitlab_mr_comment.sh @@ -31,7 +31,7 @@ GITLAB_API_URL="$GITLAB_BASE_URL/api/v4/projects/$CI_PROJECT_ID/merge_requests/$ http POST $GITLAB_API_URL \ PRIVATE-TOKEN:$CICD_BOT_TOKEN \ Content-Type:application/json \ - body:="$COMMENT_BODY" --ignore-stdin + body="$COMMENT_BODY" # Check if the request was successful if [ $? -eq 0 ]; then -- GitLab From a39db965a9e577f7bb567d8a2689d0e7f94de889 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 13:56:22 +0100 Subject: [PATCH 19/51] [#12001] repair no. 3 post MR comment CICD script --- scripts/post_gitlab_mr_comment.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/post_gitlab_mr_comment.sh b/scripts/post_gitlab_mr_comment.sh index 4cdc27c..cca7ff2 100644 --- a/scripts/post_gitlab_mr_comment.sh +++ b/scripts/post_gitlab_mr_comment.sh @@ -31,7 +31,8 @@ GITLAB_API_URL="$GITLAB_BASE_URL/api/v4/projects/$CI_PROJECT_ID/merge_requests/$ http POST $GITLAB_API_URL \ PRIVATE-TOKEN:$CICD_BOT_TOKEN \ Content-Type:application/json \ - body="$COMMENT_BODY" + body="$COMMENT_BODY" \ + --ignore-stdin # Check if the request was successful if [ $? -eq 0 ]; then -- GitLab From df3bc9a5377b5b6f74c575c4c332a2c3ed09e013 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 14:33:40 +0100 Subject: [PATCH 20/51] [#12001] added report PMD to artifactory --- .gitlab-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2d508a8..1a28e10 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,5 +24,10 @@ pmd_analysis: - npx violation-comments-to-gitlab-command-line -comment-only-changed-content false -comment-only-changed-files false -at $CICD_BOT_TOKEN -gitlab-url "https://gitlab.kiv.zcu.cz/" -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" - bash ./scripts/generate_pmd_summary.sh target/pmd.xml > pmd_report.md - bash ./scripts/post_gitlab_mr_comment.sh pmd_report.md + artifacts: + paths: + - target/pmd.xml + - pmd-reports/ + expire_in: 1 week rules: - if: $CI_MERGE_REQUEST_ID # Run only on merge requests -- GitLab From a55b6e214b517d426a5e67f879a2ed5feef05a6b Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 18:00:33 +0100 Subject: [PATCH 21/51] [#12001] spotbugs auto comment --- .gitlab-ci.yml | 22 ++++++++++++++----- pom.xml | 18 ++++++++++++++- .../pump/repository/ArtifactRepository.java | 6 +++-- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1a28e10..d62c70a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,17 +17,27 @@ pmd_analysis: stage: pmd script: - mvn pmd:check # Run PMD analysis + - mvn site:site + - mvn spotbugs:check + - mvn pmd:check - apk add --no-cache npm # Install npm only - apk add --no-cache libxml2-utils # Install xmllint - apk add --no-cache httpie # Install httpie - npm install -g violation-comments-to-gitlab-command-line - - npx violation-comments-to-gitlab-command-line -comment-only-changed-content false -comment-only-changed-files false -at $CICD_BOT_TOKEN -gitlab-url "https://gitlab.kiv.zcu.cz/" -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" + - npx violation-comments-to-gitlab-command-line \ + -comment-only-changed-content false \ + -comment-only-changed-files false \ + -at $CICD_BOT_TOKEN \ + -gitlab-url "https://gitlab.kiv.zcu.cz/" \ + -pi $CI_PROJECT_ID \ + -mr-iid $CI_MERGE_REQUEST_IID \ + -v "PMD,SpotBugs" \ + "." \ + ".*target/pmd.*\.xml$" \ + "PMD" \ + ".*target/spotbugs.*\.xml$" \ + "SpotBugs" - bash ./scripts/generate_pmd_summary.sh target/pmd.xml > pmd_report.md - bash ./scripts/post_gitlab_mr_comment.sh pmd_report.md - artifacts: - paths: - - target/pmd.xml - - pmd-reports/ - expire_in: 1 week rules: - if: $CI_MERGE_REQUEST_ID # Run only on merge requests diff --git a/pom.xml b/pom.xml index 33182d0..663eb87 100644 --- a/pom.xml +++ b/pom.xml @@ -96,7 +96,7 @@ </execution> </executions> <configuration> - <configLocation>checkstyle.xml</configLocation> + <configLocation>src/main/resources/checkstyle.xml</configLocation> <consoleOutput>true</consoleOutput> <failOnViolation>false</failOnViolation> </configuration> @@ -135,10 +135,20 @@ <execution> <phase>verify</phase> <goals> + <goal>spotbugs</goal> <goal>check</goal> </goals> </execution> </executions> + <configuration> + <xmlOutput>true</xmlOutput> + <htmlOutput>true</htmlOutput> + <effort>Default</effort> <!-- Effort levels: Min, Default, Max --> + <threshold>Medium</threshold> <!-- Thresholds: Low, Medium, High --> + <failOnError>true</failOnError> <!-- Fail build if issues are found --> + <xmlOutput>true</xmlOutput> <!-- Output in XML format --> + <outputDirectory>${project.build.directory}/spotbugs-reports</outputDirectory> + </configuration> </plugin> </plugins> </build> @@ -151,6 +161,12 @@ <version>3.6.0</version> </plugin> + <!-- SpotBugs --> + <plugin> + <groupId>com.github.spotbugs</groupId> + <artifactId>spotbugs-maven-plugin</artifactId> + <version>4.9.2.0</version> + </plugin> </plugins> </reporting> </project> diff --git a/src/main/java/com/pump/repository/ArtifactRepository.java b/src/main/java/com/pump/repository/ArtifactRepository.java index c6adfa9..d2763c8 100644 --- a/src/main/java/com/pump/repository/ArtifactRepository.java +++ b/src/main/java/com/pump/repository/ArtifactRepository.java @@ -4,5 +4,7 @@ import com.pump.entity.Artifact; import org.springframework.data.jpa.repository.JpaRepository; public interface ArtifactRepository extends JpaRepository<Artifact, Long> { - -} \ No newline at end of file + default void printNull() { + System.out.println(null.toString()); // This should trigger a SpotBugs warning + } +} -- GitLab From 9d4bd73f91cf6b935588a5f3930970d25b69b10d Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 18:11:06 +0100 Subject: [PATCH 22/51] [#12001] split pipeline spotbugs and pmd --- .gitlab-ci.yml | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d62c70a..60de634 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,6 +5,8 @@ default: stages: - pmd + - spotbugs + - static_analysis_summary variables: MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository" @@ -13,14 +15,35 @@ cache: paths: - .m2/repository +# PMD Analysis pmd_analysis: stage: pmd script: - - mvn pmd:check # Run PMD analysis + - mvn pmd:check # Run PMD analysis - mvn site:site - - mvn spotbugs:check - - mvn pmd:check - - apk add --no-cache npm # Install npm only + artifacts: + paths: + - target/pmd.xml # Store PMD report as artifact + rules: + - if: $CI_MERGE_REQUEST_ID # Run only on merge requests + +# SpotBugs Analysis +spotbugs_analysis: + stage: spotbugs + script: + - mvn spotbugs:check || true # Run SpotBugs, don't fail the build on errors + - mvn site:site + artifacts: + paths: + - target/spotbugs.xml # Store SpotBugs report as artifact + rules: + - if: $CI_MERGE_REQUEST_ID # Run only on merge requests + +# Run violation-comments-to-gitlab-command-line +static_analysis_summary: + stage: static_analysis_summary + image: node:23-alpine + script: - apk add --no-cache libxml2-utils # Install xmllint - apk add --no-cache httpie # Install httpie - npm install -g violation-comments-to-gitlab-command-line @@ -28,7 +51,7 @@ pmd_analysis: -comment-only-changed-content false \ -comment-only-changed-files false \ -at $CICD_BOT_TOKEN \ - -gitlab-url "https://gitlab.kiv.zcu.cz/" \ + -gitlab-url $GITLAB_BASE_URL \ -pi $CI_PROJECT_ID \ -mr-iid $CI_MERGE_REQUEST_IID \ -v "PMD,SpotBugs" \ @@ -39,5 +62,8 @@ pmd_analysis: "SpotBugs" - bash ./scripts/generate_pmd_summary.sh target/pmd.xml > pmd_report.md - bash ./scripts/post_gitlab_mr_comment.sh pmd_report.md + dependencies: + - pmd_analysis + - spotbugs_analysis rules: - - if: $CI_MERGE_REQUEST_ID # Run only on merge requests + - if: $CI_MERGE_REQUEST_ID # Run only on merge requests -- GitLab From 2b95c8a80f5ff31717e77bab3f2e35edf74411f6 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 18:14:31 +0100 Subject: [PATCH 23/51] [#12001] pipeline stages run in parralel --- .gitlab-ci.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 60de634..6aba391 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,8 +4,7 @@ default: - shared stages: - - pmd - - spotbugs + - static_analysis - static_analysis_summary variables: @@ -16,11 +15,10 @@ cache: - .m2/repository # PMD Analysis -pmd_analysis: - stage: pmd +pmd: + stage: static_analysis script: - mvn pmd:check # Run PMD analysis - - mvn site:site artifacts: paths: - target/pmd.xml # Store PMD report as artifact @@ -28,8 +26,8 @@ pmd_analysis: - if: $CI_MERGE_REQUEST_ID # Run only on merge requests # SpotBugs Analysis -spotbugs_analysis: - stage: spotbugs +spotbugs: + stage: static_analysis script: - mvn spotbugs:check || true # Run SpotBugs, don't fail the build on errors - mvn site:site -- GitLab From 9d9ac966ce210c92daafff49ce811371e23f8d40 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 18:15:49 +0100 Subject: [PATCH 24/51] [#12001] pipeline repair syntax --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6aba391..898322a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -61,7 +61,6 @@ static_analysis_summary: - bash ./scripts/generate_pmd_summary.sh target/pmd.xml > pmd_report.md - bash ./scripts/post_gitlab_mr_comment.sh pmd_report.md dependencies: - - pmd_analysis - - spotbugs_analysis + - static_analysis rules: - if: $CI_MERGE_REQUEST_ID # Run only on merge requests -- GitLab From 0f203faf5325208825d5f74c93f5699de8df4424 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 18:17:02 +0100 Subject: [PATCH 25/51] [#12001] pipeline bad names --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 898322a..9784b9c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -61,6 +61,7 @@ static_analysis_summary: - bash ./scripts/generate_pmd_summary.sh target/pmd.xml > pmd_report.md - bash ./scripts/post_gitlab_mr_comment.sh pmd_report.md dependencies: - - static_analysis + - pmd + - spotbugs rules: - if: $CI_MERGE_REQUEST_ID # Run only on merge requests -- GitLab From 3b43788158339cf8a1c47afbae1c6fa2ff469e23 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 18:24:34 +0100 Subject: [PATCH 26/51] [#12001] spotbugs cicd repair --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9784b9c..e930993 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,8 +29,8 @@ pmd: spotbugs: stage: static_analysis script: + - mvn site:site || true - mvn spotbugs:check || true # Run SpotBugs, don't fail the build on errors - - mvn site:site artifacts: paths: - target/spotbugs.xml # Store SpotBugs report as artifact -- GitLab From de834eddd0e7f780f0cde96f5ee37c1755ffc018 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 18:29:31 +0100 Subject: [PATCH 27/51] [#12001] added java for npm package violation-comments-to-gitlab-command-line --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e930993..f1d5fe0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,12 +40,12 @@ spotbugs: # Run violation-comments-to-gitlab-command-line static_analysis_summary: stage: static_analysis_summary - image: node:23-alpine script: + - apk add --no-cache npm # Install npm only - apk add --no-cache libxml2-utils # Install xmllint - apk add --no-cache httpie # Install httpie - npm install -g violation-comments-to-gitlab-command-line - - npx violation-comments-to-gitlab-command-line \ + - npx violation-comments-to-gitlab-command-line \ # Needs Java -comment-only-changed-content false \ -comment-only-changed-files false \ -at $CICD_BOT_TOKEN \ -- GitLab From 8adb463bca64a58e965f9adc2548a8bd00de8ffc Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 18:33:14 +0100 Subject: [PATCH 28/51] [#12001] cicd invalid syntax --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f1d5fe0..27e7d1e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,7 +45,7 @@ static_analysis_summary: - apk add --no-cache libxml2-utils # Install xmllint - apk add --no-cache httpie # Install httpie - npm install -g violation-comments-to-gitlab-command-line - - npx violation-comments-to-gitlab-command-line \ # Needs Java + - npx violation-comments-to-gitlab-command-line \ -comment-only-changed-content false \ -comment-only-changed-files false \ -at $CICD_BOT_TOKEN \ -- GitLab From c114cfe0e56b94f581f24a0c658da93974415c19 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 18:37:00 +0100 Subject: [PATCH 29/51] [#12001] cicd pipeline --- .gitlab-ci.yml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 27e7d1e..1ec58c8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,19 +45,7 @@ static_analysis_summary: - apk add --no-cache libxml2-utils # Install xmllint - apk add --no-cache httpie # Install httpie - npm install -g violation-comments-to-gitlab-command-line - - npx violation-comments-to-gitlab-command-line \ - -comment-only-changed-content false \ - -comment-only-changed-files false \ - -at $CICD_BOT_TOKEN \ - -gitlab-url $GITLAB_BASE_URL \ - -pi $CI_PROJECT_ID \ - -mr-iid $CI_MERGE_REQUEST_IID \ - -v "PMD,SpotBugs" \ - "." \ - ".*target/pmd.*\.xml$" \ - "PMD" \ - ".*target/spotbugs.*\.xml$" \ - "SpotBugs" + - npx violation-comments-to-gitlab-command-line -at $CICD_BOT_TOKEN -gitlab-url $GITLAB_BASE_URL -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD,SpotBugs" "." ".*target/pmd.*\.xml$" "PMD" ".*target/spotbugs.*\.xml$" "SpotBugs" - bash ./scripts/generate_pmd_summary.sh target/pmd.xml > pmd_report.md - bash ./scripts/post_gitlab_mr_comment.sh pmd_report.md dependencies: -- GitLab From bdd2743541ea9133c9f717b6c66914a9e908287d Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 19:01:26 +0100 Subject: [PATCH 30/51] [#12001] repair run violation-comments-to-gitlab-command-line --- .gitlab-ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1ec58c8..899bdb7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,7 +45,12 @@ static_analysis_summary: - apk add --no-cache libxml2-utils # Install xmllint - apk add --no-cache httpie # Install httpie - npm install -g violation-comments-to-gitlab-command-line - - npx violation-comments-to-gitlab-command-line -at $CICD_BOT_TOKEN -gitlab-url $GITLAB_BASE_URL -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD,SpotBugs" "." ".*target/pmd.*\.xml$" "PMD" ".*target/spotbugs.*\.xml$" "SpotBugs" + - npx violation-comments-to-gitlab-command-line \ + -at $CICD_BOT_TOKEN -gitlab-url $GITLAB_BASE_URL \ + -pi $CI_PROJECT_ID \ + -mr-iid $CI_MERGE_REQUEST_IID \ + -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" \ + -v "FINDBUGS" "." ".*target/spotbugs.*\.xml$" "SpotBugs" - bash ./scripts/generate_pmd_summary.sh target/pmd.xml > pmd_report.md - bash ./scripts/post_gitlab_mr_comment.sh pmd_report.md dependencies: -- GitLab From 7eee79ce59f6678f526343dee661b0bc7ad89baa Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 19:05:21 +0100 Subject: [PATCH 31/51] [#12001] pipeline repair tabs --- .gitlab-ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 899bdb7..30cd53d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,11 +46,11 @@ static_analysis_summary: - apk add --no-cache httpie # Install httpie - npm install -g violation-comments-to-gitlab-command-line - npx violation-comments-to-gitlab-command-line \ - -at $CICD_BOT_TOKEN -gitlab-url $GITLAB_BASE_URL \ - -pi $CI_PROJECT_ID \ - -mr-iid $CI_MERGE_REQUEST_IID \ - -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" \ - -v "FINDBUGS" "." ".*target/spotbugs.*\.xml$" "SpotBugs" + -at $CICD_BOT_TOKEN -gitlab-url $GITLAB_BASE_URL \ + -pi $CI_PROJECT_ID \ + -mr-iid $CI_MERGE_REQUEST_IID \ + -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" \ + -v "FINDBUGS" "." ".*target/spotbugs.*\.xml$" "SpotBugs" - bash ./scripts/generate_pmd_summary.sh target/pmd.xml > pmd_report.md - bash ./scripts/post_gitlab_mr_comment.sh pmd_report.md dependencies: -- GitLab From 0d5cf686855675184df8ecf8c8d8fbede8c22221 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 19:08:53 +0100 Subject: [PATCH 32/51] [#12001] repair cicd by making it oneliner --- .gitlab-ci.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 30cd53d..c1ae067 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -45,12 +45,7 @@ static_analysis_summary: - apk add --no-cache libxml2-utils # Install xmllint - apk add --no-cache httpie # Install httpie - npm install -g violation-comments-to-gitlab-command-line - - npx violation-comments-to-gitlab-command-line \ - -at $CICD_BOT_TOKEN -gitlab-url $GITLAB_BASE_URL \ - -pi $CI_PROJECT_ID \ - -mr-iid $CI_MERGE_REQUEST_IID \ - -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" \ - -v "FINDBUGS" "." ".*target/spotbugs.*\.xml$" "SpotBugs" + - npx violation-comments-to-gitlab-command-line -at $CICD_BOT_TOKEN -gitlab-url $GITLAB_BASE_URL -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" -v "FINDBUGS" "." ".*target/spotbugs.*\.xml$" "SpotBugs" - bash ./scripts/generate_pmd_summary.sh target/pmd.xml > pmd_report.md - bash ./scripts/post_gitlab_mr_comment.sh pmd_report.md dependencies: -- GitLab From 855307393800ea5768a74590841c38a08527096f Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 19:19:56 +0100 Subject: [PATCH 33/51] [#12001] split analysis_summary --- .gitlab-ci.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c1ae067..a15c73e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,18 +38,29 @@ spotbugs: - if: $CI_MERGE_REQUEST_ID # Run only on merge requests # Run violation-comments-to-gitlab-command-line -static_analysis_summary: +violation-comments: stage: static_analysis_summary script: - apk add --no-cache npm # Install npm only - - apk add --no-cache libxml2-utils # Install xmllint - - apk add --no-cache httpie # Install httpie - npm install -g violation-comments-to-gitlab-command-line - npx violation-comments-to-gitlab-command-line -at $CICD_BOT_TOKEN -gitlab-url $GITLAB_BASE_URL -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" -v "FINDBUGS" "." ".*target/spotbugs.*\.xml$" "SpotBugs" + dependencies: + - pmd + - spotbugs + rules: + - if: $CI_MERGE_REQUEST_ID # Run only on merge requests + +# Run violation-comments-to-gitlab-command-line +static_summary: + image: node:22-alpine + stage: static_analysis_summary + script: + - apk add --no-cache libxml2-utils # Install xmllint + - apk add --no-cache httpie # Install httpie - bash ./scripts/generate_pmd_summary.sh target/pmd.xml > pmd_report.md - bash ./scripts/post_gitlab_mr_comment.sh pmd_report.md dependencies: - pmd - spotbugs rules: - - if: $CI_MERGE_REQUEST_ID # Run only on merge requests + - if: $CI_MERGE_REQUEST_ID # Run only on merge requests \ No newline at end of file -- GitLab From 781b83c3b419666b27bfe10d82ee964726410856 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 19:35:50 +0100 Subject: [PATCH 34/51] [#12001] alpine add missing bash --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a15c73e..96c6285 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,8 +32,10 @@ spotbugs: - mvn site:site || true - mvn spotbugs:check || true # Run SpotBugs, don't fail the build on errors artifacts: + name: spotbugs.xml paths: - target/spotbugs.xml # Store SpotBugs report as artifact + expire_in: 1 min rules: - if: $CI_MERGE_REQUEST_ID # Run only on merge requests @@ -55,6 +57,7 @@ static_summary: image: node:22-alpine stage: static_analysis_summary script: + - apk add --no-cache bash # Install bash - apk add --no-cache libxml2-utils # Install xmllint - apk add --no-cache httpie # Install httpie - bash ./scripts/generate_pmd_summary.sh target/pmd.xml > pmd_report.md -- GitLab From 519dfc2e2179537ca6fb8a5d3e2296b5fb37962c Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sat, 8 Mar 2025 19:53:26 +0100 Subject: [PATCH 35/51] [#12001] upload pmd code climate to gitlab --- .gitlab-ci.yml | 8 ++++++-- pom.xml | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 96c6285..2381518 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,8 +20,12 @@ pmd: script: - mvn pmd:check # Run PMD analysis artifacts: + name: pmd + reports: + codequality: target/pmd.json paths: - target/pmd.xml # Store PMD report as artifact + expire_in: 10 hours rules: - if: $CI_MERGE_REQUEST_ID # Run only on merge requests @@ -32,10 +36,10 @@ spotbugs: - mvn site:site || true - mvn spotbugs:check || true # Run SpotBugs, don't fail the build on errors artifacts: - name: spotbugs.xml + name: spotbugs paths: - target/spotbugs.xml # Store SpotBugs report as artifact - expire_in: 1 min + expire_in: 10 hours rules: - if: $CI_MERGE_REQUEST_ID # Run only on merge requests diff --git a/pom.xml b/pom.xml index 663eb87..e6fb1c9 100644 --- a/pom.xml +++ b/pom.xml @@ -121,7 +121,7 @@ </rulesets> <failOnViolation>false</failOnViolation> <!-- Avoid build failures --> <outputDirectory>target/pmd-reports</outputDirectory> - <format>html</format> <!-- Specify HTML format for detailed output --> + <format>net.sourceforge.pmd.renderers.CodeClimateRenderer</format> <!-- Specify HTML format for detailed output --> <linkXRef>true</linkXRef> <!-- Show link to repo on line number --> </configuration> </plugin> -- GitLab From 717897465f0853bf727378a7ebe8ed4ad3c1be1e Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sun, 9 Mar 2025 16:09:18 +0100 Subject: [PATCH 36/51] [#12001] MR report comment link to details --- .gitlab-ci.yml | 26 +++++++++++++------ scripts/generate_pmd_summary.sh | 4 +++ .../gitlab_get_current_job_artifact_url.sh | 11 ++++++++ ...r_comment.sh => gitlab_mr_post_comment.sh} | 0 4 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 scripts/gitlab_get_current_job_artifact_url.sh rename scripts/{post_gitlab_mr_comment.sh => gitlab_mr_post_comment.sh} (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2381518..8f8769d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,10 +22,12 @@ pmd: artifacts: name: pmd reports: - codequality: target/pmd.json + codequality: target/pmd.json # This however not works in Free Gitlab paths: + - target/pmd-reports + - target/pmd.json - target/pmd.xml # Store PMD report as artifact - expire_in: 10 hours + expire_in: 1 hour rules: - if: $CI_MERGE_REQUEST_ID # Run only on merge requests @@ -38,8 +40,10 @@ spotbugs: artifacts: name: spotbugs paths: + - target/spotbugs-reports + - target/spotbugsXml.xml - target/spotbugs.xml # Store SpotBugs report as artifact - expire_in: 10 hours + expire_in: 1 hour rules: - if: $CI_MERGE_REQUEST_ID # Run only on merge requests @@ -49,7 +53,7 @@ violation-comments: script: - apk add --no-cache npm # Install npm only - npm install -g violation-comments-to-gitlab-command-line - - npx violation-comments-to-gitlab-command-line -at $CICD_BOT_TOKEN -gitlab-url $GITLAB_BASE_URL -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" -v "FINDBUGS" "." ".*target/spotbugs.*\.xml$" "SpotBugs" + - npx violation-comments-to-gitlab-command-line -at $CICD_BOT_TOKEN -gitlab-url $GITLAB_BASE_URL -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" -v "FINDBUGS" "." ".*target/spotbugs*\.xml$" "SpotBugs" dependencies: - pmd - spotbugs @@ -61,11 +65,17 @@ static_summary: image: node:22-alpine stage: static_analysis_summary script: - - apk add --no-cache bash # Install bash - - apk add --no-cache libxml2-utils # Install xmllint - - apk add --no-cache httpie # Install httpie + - apk add --no-cache bash libxml2-utils httpie - bash ./scripts/generate_pmd_summary.sh target/pmd.xml > pmd_report.md - - bash ./scripts/post_gitlab_mr_comment.sh pmd_report.md + - bash ./scripts/gitlab_mr_post_comment.sh pmd_report.md + - mkdir -p pmd && cp target/pmd.xml target/pmd.json -r target/pmd-reports pmd + - mkdir -p spotbugs && cp target/spotbugs.xml target/spotbugsXml.xml -r target/spotbugs-reports spotbugs + artifacts: + name: static_analysis + paths: + - pmd + - spotbugs + expire_in: 7 days dependencies: - pmd - spotbugs diff --git a/scripts/generate_pmd_summary.sh b/scripts/generate_pmd_summary.sh index d0c5eba..93b35b3 100644 --- a/scripts/generate_pmd_summary.sh +++ b/scripts/generate_pmd_summary.sh @@ -24,9 +24,13 @@ generate_pmd_summary() { medium_badge="" low_badge="" + ARTIFACT_URL=$(bash artifact_url.sh) + # Generate the styled overview report in Markdown format overview_report="### PMD Overview Report +[Download full detail reports]($ARTIFACT_URL) + **Total Violations:** $total_violations $high_badge $medium_badge diff --git a/scripts/gitlab_get_current_job_artifact_url.sh b/scripts/gitlab_get_current_job_artifact_url.sh new file mode 100644 index 0000000..6f2d2c5 --- /dev/null +++ b/scripts/gitlab_get_current_job_artifact_url.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +NAMESPACE="$CI_PROJECT_NAMESPACE" +PROJECT="$CI_PROJECT_NAME" +JOB_ID="$CI_JOB_ID" + +# Construct the full URL for downloading the artifact +FULL_URL="${GITLAB_URL}/${NAMESPACE}/${PROJECT}/-/jobs/${JOB_ID}/artifacts/download" + +# Output the full URL +echo $FULL_URL \ No newline at end of file diff --git a/scripts/post_gitlab_mr_comment.sh b/scripts/gitlab_mr_post_comment.sh similarity index 100% rename from scripts/post_gitlab_mr_comment.sh rename to scripts/gitlab_mr_post_comment.sh -- GitLab From ce5bfd38cf0e19ed6060a74b5a365de79ddaf9b7 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sun, 9 Mar 2025 16:17:34 +0100 Subject: [PATCH 37/51] [#12001] cicd repair artifact url path --- scripts/gitlab_get_current_job_artifact_url.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/scripts/gitlab_get_current_job_artifact_url.sh b/scripts/gitlab_get_current_job_artifact_url.sh index 6f2d2c5..5eb27c3 100644 --- a/scripts/gitlab_get_current_job_artifact_url.sh +++ b/scripts/gitlab_get_current_job_artifact_url.sh @@ -1,11 +1,6 @@ #!/bin/bash -NAMESPACE="$CI_PROJECT_NAMESPACE" -PROJECT="$CI_PROJECT_NAME" -JOB_ID="$CI_JOB_ID" - -# Construct the full URL for downloading the artifact -FULL_URL="${GITLAB_URL}/${NAMESPACE}/${PROJECT}/-/jobs/${JOB_ID}/artifacts/download" +ARTIFACT_URL="${CI_JOB_URL}/artifacts/download" # Output the full URL -echo $FULL_URL \ No newline at end of file +echo ARTIFACT_URL \ No newline at end of file -- GitLab From 81e5c0b32310a70539c83c646384ff39fe10ed36 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sun, 9 Mar 2025 16:21:12 +0100 Subject: [PATCH 38/51] [#12001] cicd script repair artifact url path --- scripts/generate_pmd_summary.sh | 2 +- scripts/gitlab_get_current_job_artifact_url.sh | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 scripts/gitlab_get_current_job_artifact_url.sh diff --git a/scripts/generate_pmd_summary.sh b/scripts/generate_pmd_summary.sh index 93b35b3..d37a54d 100644 --- a/scripts/generate_pmd_summary.sh +++ b/scripts/generate_pmd_summary.sh @@ -24,7 +24,7 @@ generate_pmd_summary() { medium_badge="" low_badge="" - ARTIFACT_URL=$(bash artifact_url.sh) + ARTIFACT_URL="${CI_JOB_URL}/artifacts/download" # Generate the styled overview report in Markdown format overview_report="### PMD Overview Report diff --git a/scripts/gitlab_get_current_job_artifact_url.sh b/scripts/gitlab_get_current_job_artifact_url.sh deleted file mode 100644 index 5eb27c3..0000000 --- a/scripts/gitlab_get_current_job_artifact_url.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -ARTIFACT_URL="${CI_JOB_URL}/artifacts/download" - -# Output the full URL -echo ARTIFACT_URL \ No newline at end of file -- GitLab From 18f7b2c4c06b24741d6739b67eff4a4a58e5a7a3 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Sun, 9 Mar 2025 16:27:11 +0100 Subject: [PATCH 39/51] [#12001] added unique artifact name --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8f8769d..adf2fe9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -71,7 +71,7 @@ static_summary: - mkdir -p pmd && cp target/pmd.xml target/pmd.json -r target/pmd-reports pmd - mkdir -p spotbugs && cp target/spotbugs.xml target/spotbugsXml.xml -r target/spotbugs-reports spotbugs artifacts: - name: static_analysis + name: "static_analysis_${CI_MERGE_REQUEST_ID:-${CI_COMMIT_SHORT_SHA}}" paths: - pmd - spotbugs -- GitLab From 87eaf219e3484ae5ce9f2ed7a9975cb43c7900e1 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Mon, 10 Mar 2025 11:58:51 +0100 Subject: [PATCH 40/51] [#12001] removed checkstyle plugin from maven --- pom.xml | 309 ++++++++++++++++++++++++++------------------------------ 1 file changed, 145 insertions(+), 164 deletions(-) diff --git a/pom.xml b/pom.xml index e6fb1c9..5e024c5 100644 --- a/pom.xml +++ b/pom.xml @@ -1,172 +1,153 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-parent</artifactId> - <version>3.4.2</version> - <relativePath/> <!-- lookup parent from repository --> - </parent> - <groupId>com.pump</groupId> - <artifactId>Pump</artifactId> - <version>0.0.1-SNAPSHOT</version> - <name>Pump</name> - <properties> - <java.version>23</java.version> - </properties> - <dependencies> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-web</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-data-jpa</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-docker-compose</artifactId> - <scope>runtime</scope> - <optional>true</optional> - </dependency> - <dependency> - <groupId>com.mysql</groupId> - <artifactId>mysql-connector-j</artifactId> - <scope>runtime</scope> - </dependency> - <dependency> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - <optional>true</optional> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-test</artifactId> - <scope>test</scope> - </dependency> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>3.4.2</version> + <relativePath/> <!-- lookup parent from repository --> + </parent> + <groupId>com.pump</groupId> + <artifactId>Pump</artifactId> + <version>0.0.1-SNAPSHOT</version> + <name>Pump</name> + <properties> + <java.version>23</java.version> + </properties> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-data-jpa</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-docker-compose</artifactId> + <scope>runtime</scope> + <optional>true</optional> + </dependency> + <dependency> + <groupId>com.mysql</groupId> + <artifactId>mysql-connector-j</artifactId> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <optional>true</optional> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> - <!-- https://mvnrepository.com/artifact/org.kohsuke/github-api --> - <dependency> - <groupId>org.kohsuke</groupId> - <artifactId>github-api</artifactId> - <version>1.326</version> - </dependency> - </dependencies> + <!-- https://mvnrepository.com/artifact/org.kohsuke/github-api --> + <dependency> + <groupId>org.kohsuke</groupId> + <artifactId>github-api</artifactId> + <version>1.326</version> + </dependency> + </dependencies> - <build> - <finalName>Pump</finalName> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <annotationProcessorPaths> - <path> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - </path> - </annotationProcessorPaths> - </configuration> - </plugin> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <configuration> - <excludes> - <exclude> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - </exclude> - </excludes> - </configuration> - </plugin> + <build> + <finalName>Pump</finalName> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <annotationProcessorPaths> + <path> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <configuration> + <excludes> + <exclude> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + </exclude> + </excludes> + </configuration> + </plugin> - <!-- Checkstyle Plugin --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-checkstyle-plugin</artifactId> - <version>3.6.0</version> - <executions> - <execution> - <phase>verify</phase> - <goals> - <goal>check</goal> - </goals> - </execution> - </executions> - <configuration> - <configLocation>src/main/resources/checkstyle.xml</configLocation> - <consoleOutput>true</consoleOutput> - <failOnViolation>false</failOnViolation> - </configuration> - </plugin> + <!-- PMD Plugin --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-pmd-plugin</artifactId> + <version>3.26.0</version> + <executions> + <execution> + <phase>verify</phase> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + <configuration> + <rulesets> + <ruleset>src/main/resources/pmd-ruleset.xml</ruleset> + </rulesets> + <failOnViolation>false</failOnViolation> <!-- Avoid build failures --> + <outputDirectory>target/pmd-reports</outputDirectory> + <format>net.sourceforge.pmd.renderers.CodeClimateRenderer + </format> <!-- Specify HTML format for detailed output --> + <linkXRef>true</linkXRef> <!-- Show link to repo on line number --> + </configuration> + </plugin> - <!-- PMD Plugin --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-pmd-plugin</artifactId> - <version>3.26.0</version> - <executions> - <execution> - <phase>verify</phase> - <goals> - <goal>check</goal> - </goals> - </execution> - </executions> - <configuration> - <rulesets> - <ruleset>src/main/resources/pmd-ruleset.xml</ruleset> - </rulesets> - <failOnViolation>false</failOnViolation> <!-- Avoid build failures --> - <outputDirectory>target/pmd-reports</outputDirectory> - <format>net.sourceforge.pmd.renderers.CodeClimateRenderer</format> <!-- Specify HTML format for detailed output --> - <linkXRef>true</linkXRef> <!-- Show link to repo on line number --> - </configuration> - </plugin> + <!-- SpotBugs Plugin --> + <plugin> + <groupId>com.github.spotbugs</groupId> + <artifactId>spotbugs-maven-plugin</artifactId> + <version>4.9.2.0</version> + <executions> + <execution> + <phase>verify</phase> + <goals> + <goal>spotbugs</goal> + <goal>check</goal> + </goals> + </execution> + </executions> + <configuration> + <xmlOutput>true</xmlOutput> + <htmlOutput>true</htmlOutput> + <effort>Default</effort> <!-- Effort levels: Min, Default, Max --> + <threshold>Medium</threshold> <!-- Thresholds: Low, Medium, High --> + <failOnError>true</failOnError> <!-- Fail build if issues are found --> + <xmlOutput>true</xmlOutput> <!-- Output in XML format --> + <outputDirectory>${project.build.directory}/spotbugs-reports</outputDirectory> + </configuration> + </plugin> + </plugins> + </build> + <reporting> + <plugins> + <!-- JXR (Java Cross Reference) for PMD generating HTML --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jxr-plugin</artifactId> + <version>3.6.0</version> + </plugin> - <!-- SpotBugs Plugin --> - <plugin> - <groupId>com.github.spotbugs</groupId> - <artifactId>spotbugs-maven-plugin</artifactId> - <version>4.9.2.0</version> - <executions> - <execution> - <phase>verify</phase> - <goals> - <goal>spotbugs</goal> - <goal>check</goal> - </goals> - </execution> - </executions> - <configuration> - <xmlOutput>true</xmlOutput> - <htmlOutput>true</htmlOutput> - <effort>Default</effort> <!-- Effort levels: Min, Default, Max --> - <threshold>Medium</threshold> <!-- Thresholds: Low, Medium, High --> - <failOnError>true</failOnError> <!-- Fail build if issues are found --> - <xmlOutput>true</xmlOutput> <!-- Output in XML format --> - <outputDirectory>${project.build.directory}/spotbugs-reports</outputDirectory> - </configuration> - </plugin> - </plugins> - </build> - <reporting> - <plugins> - <!-- JXR (Java Cross Reference) for PMD generating HTML --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jxr-plugin</artifactId> - <version>3.6.0</version> - </plugin> - - <!-- SpotBugs --> - <plugin> - <groupId>com.github.spotbugs</groupId> - <artifactId>spotbugs-maven-plugin</artifactId> - <version>4.9.2.0</version> - </plugin> - </plugins> - </reporting> + <!-- SpotBugs --> + <plugin> + <groupId>com.github.spotbugs</groupId> + <artifactId>spotbugs-maven-plugin</artifactId> + <version>4.9.2.0</version> + </plugin> + </plugins> + </reporting> </project> -- GitLab From 9392b30c12191a98f89078fc7458021faf8204c5 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Mon, 10 Mar 2025 13:29:52 +0100 Subject: [PATCH 41/51] [#12001] downgrade spotbugs maven library --- pom.xml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 5e024c5..388a613 100644 --- a/pom.xml +++ b/pom.xml @@ -111,24 +111,22 @@ <plugin> <groupId>com.github.spotbugs</groupId> <artifactId>spotbugs-maven-plugin</artifactId> - <version>4.9.2.0</version> + <version>4.8.6.6</version> <executions> <execution> - <phase>verify</phase> <goals> - <goal>spotbugs</goal> <goal>check</goal> </goals> </execution> </executions> <configuration> - <xmlOutput>true</xmlOutput> - <htmlOutput>true</htmlOutput> - <effort>Default</effort> <!-- Effort levels: Min, Default, Max --> - <threshold>Medium</threshold> <!-- Thresholds: Low, Medium, High --> <failOnError>true</failOnError> <!-- Fail build if issues are found --> + <htmlOutput>true</htmlOutput> <xmlOutput>true</xmlOutput> <!-- Output in XML format --> <outputDirectory>${project.build.directory}/spotbugs-reports</outputDirectory> + + <effort>Default</effort> <!-- Effort levels: Min, Default, Max --> + <threshold>Medium</threshold> <!-- Thresholds: Low, Medium, High --> </configuration> </plugin> </plugins> @@ -146,7 +144,7 @@ <plugin> <groupId>com.github.spotbugs</groupId> <artifactId>spotbugs-maven-plugin</artifactId> - <version>4.9.2.0</version> + <version>4.8.6.6</version> </plugin> </plugins> </reporting> -- GitLab From df71ca661251808e5d84f51e0d6ff686ba53f494 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Mon, 10 Mar 2025 13:38:19 +0100 Subject: [PATCH 42/51] [#12001] summary report of spotbugs test --- .gitlab-ci.yml | 4 +- scripts/generate_pmd_summary.sh | 7 +--- scripts/generate_spotbugs_summary.sh | 47 +++++++++++++++++++++++ scripts/generate_static_header_summary.sh | 6 +++ 4 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 scripts/generate_spotbugs_summary.sh create mode 100644 scripts/generate_static_header_summary.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index adf2fe9..b180536 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -66,7 +66,9 @@ static_summary: stage: static_analysis_summary script: - apk add --no-cache bash libxml2-utils httpie - - bash ./scripts/generate_pmd_summary.sh target/pmd.xml > pmd_report.md + - bash ./scripts/generate_static_header_summary.sh target/pmd.xml > pmd_report.md + - bash ./scripts/generate_pmd_summary.sh target/pmd.xml >> pmd_report.md + - bash ./scripts/generate_spotbugs_summary.sh target/pmd.xml >> pmd_report.md - bash ./scripts/gitlab_mr_post_comment.sh pmd_report.md - mkdir -p pmd && cp target/pmd.xml target/pmd.json -r target/pmd-reports pmd - mkdir -p spotbugs && cp target/spotbugs.xml target/spotbugsXml.xml -r target/spotbugs-reports spotbugs diff --git a/scripts/generate_pmd_summary.sh b/scripts/generate_pmd_summary.sh index d37a54d..38ca595 100644 --- a/scripts/generate_pmd_summary.sh +++ b/scripts/generate_pmd_summary.sh @@ -24,8 +24,6 @@ generate_pmd_summary() { medium_badge="" low_badge="" - ARTIFACT_URL="${CI_JOB_URL}/artifacts/download" - # Generate the styled overview report in Markdown format overview_report="### PMD Overview Report @@ -35,10 +33,7 @@ generate_pmd_summary() { $high_badge $medium_badge $low_badge - ---- - -*Generated by CI/CD Pipeline*" +" # Output the overview report to standard output (can be piped to a file or another command) echo -e "$overview_report" diff --git a/scripts/generate_spotbugs_summary.sh b/scripts/generate_spotbugs_summary.sh new file mode 100644 index 0000000..8285927 --- /dev/null +++ b/scripts/generate_spotbugs_summary.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Function to generate the SpotBugs summary report +generate_spotbugs_summary() { + # Parameters + SPOTBUGS_REPORT_PATH=$1 + + # Ensure the SpotBugs report exists + if [ ! -f "$SPOTBUGS_REPORT_PATH" ]; then + echo "SpotBugs report not found at $SPOTBUGS_REPORT_PATH!" + exit 1 + fi + + # Generate the total count of bugs + total_bugs=$(xmllint --xpath "count(//*[local-name()='BugInstance'])" $SPOTBUGS_REPORT_PATH) + + # Generate counts for each severity level + high_bugs=$(xmllint --xpath "count(//*[local-name()='BugInstance'][@priority='1'])" $SPOTBUGS_REPORT_PATH) + medium_bugs=$(xmllint --xpath "count(//*[local-name()='BugInstance'][@priority='2'])" $SPOTBUGS_REPORT_PATH) + low_bugs=$(xmllint --xpath "count(//*[local-name()='BugInstance'][@priority='3'])" $SPOTBUGS_REPORT_PATH) + + # Create badges for the severity levels using shields.io + high_badge="" + medium_badge="" + low_badge="" + + # Generate the styled overview report in Markdown format + overview_report="### SpotBugs Overview Report + +**Total Bugs:** $total_bugs +$high_badge +$medium_badge +$low_badge +" + + # Output the overview report to standard output (can be piped to a file or another command) + echo -e "$overview_report" +} + +# Validate script arguments +if [ "$#" -lt 1 ]; then + echo "Usage: $0 <path-to-spotbugs-report>" + exit 1 +fi + +# Call the function with arguments +generate_spotbugs_summary "$1" diff --git a/scripts/generate_static_header_summary.sh b/scripts/generate_static_header_summary.sh new file mode 100644 index 0000000..748f32b --- /dev/null +++ b/scripts/generate_static_header_summary.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +ARTIFACT_URL="${CI_JOB_URL}/artifacts/download" + +echo "# Static Analysis Summary" +echo "[Download full detail reports]($ARTIFACT_URL)" -- GitLab From 03f47d03a0dca98faf1cb771d6f4ec25740f9d11 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Mon, 10 Mar 2025 13:42:59 +0100 Subject: [PATCH 43/51] [#12001] repair cicd invalid spotbugs summary path --- .gitlab-ci.yml | 2 +- scripts/generate_spotbugs_summary.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b180536..5525db8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -68,7 +68,7 @@ static_summary: - apk add --no-cache bash libxml2-utils httpie - bash ./scripts/generate_static_header_summary.sh target/pmd.xml > pmd_report.md - bash ./scripts/generate_pmd_summary.sh target/pmd.xml >> pmd_report.md - - bash ./scripts/generate_spotbugs_summary.sh target/pmd.xml >> pmd_report.md + - bash ./scripts/generate_spotbugs_summary.sh target/spotbugsXml.xml >> pmd_report.md - bash ./scripts/gitlab_mr_post_comment.sh pmd_report.md - mkdir -p pmd && cp target/pmd.xml target/pmd.json -r target/pmd-reports pmd - mkdir -p spotbugs && cp target/spotbugs.xml target/spotbugsXml.xml -r target/spotbugs-reports spotbugs diff --git a/scripts/generate_spotbugs_summary.sh b/scripts/generate_spotbugs_summary.sh index 8285927..7d46a19 100644 --- a/scripts/generate_spotbugs_summary.sh +++ b/scripts/generate_spotbugs_summary.sh @@ -28,9 +28,13 @@ generate_spotbugs_summary() { overview_report="### SpotBugs Overview Report **Total Bugs:** $total_bugs + $high_badge + $medium_badge + $low_badge + " # Output the overview report to standard output (can be piped to a file or another command) -- GitLab From dbc1a1552ededdc71965df1d562d68672f070fc3 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Mon, 10 Mar 2025 13:54:03 +0100 Subject: [PATCH 44/51] [#12001] renamed artifactory --- .gitlab-ci.yml | 2 +- scripts/generate_pmd_summary.sh | 6 +++--- scripts/generate_spotbugs_summary.sh | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5525db8..05d3629 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -73,7 +73,7 @@ static_summary: - mkdir -p pmd && cp target/pmd.xml target/pmd.json -r target/pmd-reports pmd - mkdir -p spotbugs && cp target/spotbugs.xml target/spotbugsXml.xml -r target/spotbugs-reports spotbugs artifacts: - name: "static_analysis_${CI_MERGE_REQUEST_ID:-${CI_COMMIT_SHORT_SHA}}" + name: "static_analysis-$CI_JOB_NAME-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA" paths: - pmd - spotbugs diff --git a/scripts/generate_pmd_summary.sh b/scripts/generate_pmd_summary.sh index 38ca595..b317ca5 100644 --- a/scripts/generate_pmd_summary.sh +++ b/scripts/generate_pmd_summary.sh @@ -27,12 +27,12 @@ generate_pmd_summary() { # Generate the styled overview report in Markdown format overview_report="### PMD Overview Report -[Download full detail reports]($ARTIFACT_URL) +**Total Violations:** $total_violations -**Total Violations:** $total_violations $high_badge -$medium_badge +$medium_badge $low_badge + " # Output the overview report to standard output (can be piped to a file or another command) diff --git a/scripts/generate_spotbugs_summary.sh b/scripts/generate_spotbugs_summary.sh index 7d46a19..6f6b476 100644 --- a/scripts/generate_spotbugs_summary.sh +++ b/scripts/generate_spotbugs_summary.sh @@ -30,9 +30,7 @@ generate_spotbugs_summary() { **Total Bugs:** $total_bugs $high_badge - $medium_badge - $low_badge " -- GitLab From bb31e9b5a7e36089e0c0bb1e1b816a29f69ea6df Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Mon, 10 Mar 2025 14:10:57 +0100 Subject: [PATCH 45/51] [#12001] renamed name artifactory --- .gitlab-ci.yml | 40 ++++++++++++++-------------- scripts/generate_pmd_summary.sh | 4 +-- scripts/generate_spotbugs_summary.sh | 5 ++-- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 05d3629..f5d6928 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,8 +4,8 @@ default: - shared stages: - - static_analysis - - static_analysis_summary + - static-analyse + - static-analyse-processing variables: MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository" @@ -16,54 +16,54 @@ cache: # PMD Analysis pmd: - stage: static_analysis + stage: static-analyse script: - - mvn pmd:check # Run PMD analysis + - mvn pmd:check artifacts: name: pmd reports: - codequality: target/pmd.json # This however not works in Free Gitlab + codequality: target/pmd.json # However all features cant be used in Free Gitlab CE paths: - target/pmd-reports - target/pmd.json - - target/pmd.xml # Store PMD report as artifact + - target/pmd.xml expire_in: 1 hour rules: - - if: $CI_MERGE_REQUEST_ID # Run only on merge requests + - if: $CI_MERGE_REQUEST_ID # SpotBugs Analysis spotbugs: - stage: static_analysis + stage: static-analyse script: - mvn site:site || true - - mvn spotbugs:check || true # Run SpotBugs, don't fail the build on errors + - mvn spotbugs:check || true artifacts: name: spotbugs paths: - target/spotbugs-reports - target/spotbugsXml.xml - - target/spotbugs.xml # Store SpotBugs report as artifact + - target/spotbugs.xml expire_in: 1 hour rules: - - if: $CI_MERGE_REQUEST_ID # Run only on merge requests + - if: $CI_MERGE_REQUEST_ID -# Run violation-comments-to-gitlab-command-line +# Add violation comments to gitlab MR as comments violation-comments: - stage: static_analysis_summary + stage: static-analyse-processing script: - - apk add --no-cache npm # Install npm only + - apk add --no-cache npm - npm install -g violation-comments-to-gitlab-command-line - npx violation-comments-to-gitlab-command-line -at $CICD_BOT_TOKEN -gitlab-url $GITLAB_BASE_URL -pi $CI_PROJECT_ID -mr-iid $CI_MERGE_REQUEST_IID -v "PMD" "." ".*target/pmd.*\.xml$" "PMD" -v "FINDBUGS" "." ".*target/spotbugs*\.xml$" "SpotBugs" dependencies: - pmd - spotbugs rules: - - if: $CI_MERGE_REQUEST_ID # Run only on merge requests + - if: $CI_MERGE_REQUEST_ID -# Run violation-comments-to-gitlab-command-line -static_summary: +# Generate summary comment to MR +summary: image: node:22-alpine - stage: static_analysis_summary + stage: static-analyse-processing script: - apk add --no-cache bash libxml2-utils httpie - bash ./scripts/generate_static_header_summary.sh target/pmd.xml > pmd_report.md @@ -73,7 +73,7 @@ static_summary: - mkdir -p pmd && cp target/pmd.xml target/pmd.json -r target/pmd-reports pmd - mkdir -p spotbugs && cp target/spotbugs.xml target/spotbugsXml.xml -r target/spotbugs-reports spotbugs artifacts: - name: "static_analysis-$CI_JOB_NAME-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA" + name: "STaT-${CI_COMMIT_REF_NAME}-${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}" paths: - pmd - spotbugs @@ -82,4 +82,4 @@ static_summary: - pmd - spotbugs rules: - - if: $CI_MERGE_REQUEST_ID # Run only on merge requests \ No newline at end of file + - if: $CI_MERGE_REQUEST_ID diff --git a/scripts/generate_pmd_summary.sh b/scripts/generate_pmd_summary.sh index b317ca5..68fc364 100644 --- a/scripts/generate_pmd_summary.sh +++ b/scripts/generate_pmd_summary.sh @@ -29,8 +29,8 @@ generate_pmd_summary() { **Total Violations:** $total_violations -$high_badge -$medium_badge +$high_badge <br> +$medium_badge <br> $low_badge " diff --git a/scripts/generate_spotbugs_summary.sh b/scripts/generate_spotbugs_summary.sh index 6f6b476..b5ad720 100644 --- a/scripts/generate_spotbugs_summary.sh +++ b/scripts/generate_spotbugs_summary.sh @@ -29,13 +29,12 @@ generate_spotbugs_summary() { **Total Bugs:** $total_bugs -$high_badge -$medium_badge +$high_badge <br> +$medium_badge <br> $low_badge " - # Output the overview report to standard output (can be piped to a file or another command) echo -e "$overview_report" } -- GitLab From b1996fb989e3c6536ca17c4094c166d7b45ee072 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Mon, 10 Mar 2025 14:19:42 +0100 Subject: [PATCH 46/51] [#12001] cicd reduce number of folders in artifacts --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f5d6928..39cc464 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -70,10 +70,10 @@ summary: - bash ./scripts/generate_pmd_summary.sh target/pmd.xml >> pmd_report.md - bash ./scripts/generate_spotbugs_summary.sh target/spotbugsXml.xml >> pmd_report.md - bash ./scripts/gitlab_mr_post_comment.sh pmd_report.md - - mkdir -p pmd && cp target/pmd.xml target/pmd.json -r target/pmd-reports pmd - - mkdir -p spotbugs && cp target/spotbugs.xml target/spotbugsXml.xml -r target/spotbugs-reports spotbugs + - mkdir -p pmd && cp target/pmd.xml target/pmd.json target/pmd-reports/* pmd + - mkdir -p spotbugs && cp target/spotbugs.xml target/spotbugsXml.xml target/spotbugs-reports/* spotbugs artifacts: - name: "STaT-${CI_COMMIT_REF_NAME}-${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}" + name: "STaT-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}" paths: - pmd - spotbugs -- GitLab From f9a3baac011fdd9600b4203a10641d24f19fa492 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Mon, 10 Mar 2025 14:23:58 +0100 Subject: [PATCH 47/51] [#12001] repair recursive copy artifacts --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 39cc464..df92f8d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -70,8 +70,8 @@ summary: - bash ./scripts/generate_pmd_summary.sh target/pmd.xml >> pmd_report.md - bash ./scripts/generate_spotbugs_summary.sh target/spotbugsXml.xml >> pmd_report.md - bash ./scripts/gitlab_mr_post_comment.sh pmd_report.md - - mkdir -p pmd && cp target/pmd.xml target/pmd.json target/pmd-reports/* pmd - - mkdir -p spotbugs && cp target/spotbugs.xml target/spotbugsXml.xml target/spotbugs-reports/* spotbugs + - mkdir -p pmd && cp -r target/pmd.xml target/pmd.json target/pmd-reports/* pmd + - mkdir -p spotbugs && cp -r target/spotbugs.xml target/spotbugsXml.xml target/spotbugs-reports/* spotbugs artifacts: name: "STaT-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}" paths: -- GitLab From 7278f03eb33da1a8be626284f3ac330c3734f3fc Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Mon, 10 Mar 2025 14:30:44 +0100 Subject: [PATCH 48/51] [#12001] revert ArtifactRepository.java --- .../java/com/pump/repository/ArtifactRepository.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/pump/repository/ArtifactRepository.java b/src/main/java/com/pump/repository/ArtifactRepository.java index d2763c8..9afe6c5 100644 --- a/src/main/java/com/pump/repository/ArtifactRepository.java +++ b/src/main/java/com/pump/repository/ArtifactRepository.java @@ -1,10 +1,5 @@ -package com.pump.repository; - -import com.pump.entity.Artifact; import org.springframework.data.jpa.repository.JpaRepository; public interface ArtifactRepository extends JpaRepository<Artifact, Long> { - default void printNull() { - System.out.println(null.toString()); // This should trigger a SpotBugs warning - } -} + +} \ No newline at end of file -- GitLab From 650ed574f64648b87e9c04b62c554603968b5181 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Mon, 10 Mar 2025 14:32:22 +0100 Subject: [PATCH 49/51] [#12001] revert ArtifactRepository.java no 2 --- src/main/java/com/pump/repository/ArtifactRepository.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/pump/repository/ArtifactRepository.java b/src/main/java/com/pump/repository/ArtifactRepository.java index 9afe6c5..c6adfa9 100644 --- a/src/main/java/com/pump/repository/ArtifactRepository.java +++ b/src/main/java/com/pump/repository/ArtifactRepository.java @@ -1,3 +1,6 @@ +package com.pump.repository; + +import com.pump.entity.Artifact; import org.springframework.data.jpa.repository.JpaRepository; public interface ArtifactRepository extends JpaRepository<Artifact, Long> { -- GitLab From caf6318a264073c10343c5b34381c0ae097c6627 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Mon, 10 Mar 2025 16:10:37 +0100 Subject: [PATCH 50/51] [#12001] rename static analysis scripts --- .gitlab-ci.yml | 6 +++--- ...atic_header_summary.sh => stat-get-header-md-summary.sh} | 0 .../{generate_pmd_summary.sh => stat-pmd-to-md-summary.sh} | 0 ...e_spotbugs_summary.sh => stat-spotbugs-to-md-summary.sh} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename scripts/{generate_static_header_summary.sh => stat-get-header-md-summary.sh} (100%) rename scripts/{generate_pmd_summary.sh => stat-pmd-to-md-summary.sh} (100%) rename scripts/{generate_spotbugs_summary.sh => stat-spotbugs-to-md-summary.sh} (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index df92f8d..a9aa60c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -66,9 +66,9 @@ summary: stage: static-analyse-processing script: - apk add --no-cache bash libxml2-utils httpie - - bash ./scripts/generate_static_header_summary.sh target/pmd.xml > pmd_report.md - - bash ./scripts/generate_pmd_summary.sh target/pmd.xml >> pmd_report.md - - bash ./scripts/generate_spotbugs_summary.sh target/spotbugsXml.xml >> pmd_report.md + - bash ./scripts/stat-get-header-md-summary.sh target/pmd.xml > pmd_report.md + - bash ./scripts/stat-pmd-to-md-summary.sh target/pmd.xml >> pmd_report.md + - bash ./scripts/stat-spotbugs-to-md-summary.sh target/spotbugsXml.xml >> pmd_report.md - bash ./scripts/gitlab_mr_post_comment.sh pmd_report.md - mkdir -p pmd && cp -r target/pmd.xml target/pmd.json target/pmd-reports/* pmd - mkdir -p spotbugs && cp -r target/spotbugs.xml target/spotbugsXml.xml target/spotbugs-reports/* spotbugs diff --git a/scripts/generate_static_header_summary.sh b/scripts/stat-get-header-md-summary.sh similarity index 100% rename from scripts/generate_static_header_summary.sh rename to scripts/stat-get-header-md-summary.sh diff --git a/scripts/generate_pmd_summary.sh b/scripts/stat-pmd-to-md-summary.sh similarity index 100% rename from scripts/generate_pmd_summary.sh rename to scripts/stat-pmd-to-md-summary.sh diff --git a/scripts/generate_spotbugs_summary.sh b/scripts/stat-spotbugs-to-md-summary.sh similarity index 100% rename from scripts/generate_spotbugs_summary.sh rename to scripts/stat-spotbugs-to-md-summary.sh -- GitLab From b35d11cc3bdbd47aad1118749f0134c18dd02442 Mon Sep 17 00:00:00 2001 From: Frantisek Urban <fandau1@gmail.com> Date: Mon, 10 Mar 2025 16:18:59 +0100 Subject: [PATCH 51/51] [#12001] add comments --- scripts/stat-pmd-to-md-summary.sh | 7 +++---- scripts/stat-spotbugs-to-md-summary.sh | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/scripts/stat-pmd-to-md-summary.sh b/scripts/stat-pmd-to-md-summary.sh index 68fc364..9fb5f0a 100644 --- a/scripts/stat-pmd-to-md-summary.sh +++ b/scripts/stat-pmd-to-md-summary.sh @@ -1,20 +1,19 @@ #!/bin/bash -# Function to generate the PMD summary report generate_pmd_summary() { # Parameters PMD_REPORT_PATH=$1 # Ensure the PMD report exists if [ ! -f "$PMD_REPORT_PATH" ]; then - echo "PMD report not found at $PMD_REPORT_PATH!" + echo "PMD report (expected extension *.xml) not found at $PMD_REPORT_PATH!" exit 1 fi - # Generate the total count of violations using the local-name() function to ignore the namespace + # Generate the total count of violations total_violations=$(xmllint --xpath "count(//*[local-name()='violation'])" $PMD_REPORT_PATH) - # Generate counts for each severity (assuming severity is defined in PMD report as priority) + # Generate counts for each severity high_violations=$(xmllint --xpath "count(//*[local-name()='violation'][@priority='1'])" $PMD_REPORT_PATH) medium_violations=$(xmllint --xpath "count(//*[local-name()='violation'][@priority='2'])" $PMD_REPORT_PATH) low_violations=$(xmllint --xpath "count(//*[local-name()='violation'][@priority='3'])" $PMD_REPORT_PATH) diff --git a/scripts/stat-spotbugs-to-md-summary.sh b/scripts/stat-spotbugs-to-md-summary.sh index b5ad720..4646067 100644 --- a/scripts/stat-spotbugs-to-md-summary.sh +++ b/scripts/stat-spotbugs-to-md-summary.sh @@ -1,13 +1,12 @@ #!/bin/bash -# Function to generate the SpotBugs summary report generate_spotbugs_summary() { # Parameters SPOTBUGS_REPORT_PATH=$1 # Ensure the SpotBugs report exists if [ ! -f "$SPOTBUGS_REPORT_PATH" ]; then - echo "SpotBugs report not found at $SPOTBUGS_REPORT_PATH!" + echo "SpotBugs report (expected extension *.xml) not found at $SPOTBUGS_REPORT_PATH!" exit 1 fi -- GitLab