PMD: слияние новых правил (bestpractices/design/errorprone/multithreading) + правка нарушений без подавлений
PR checks / web (pull_request) Successful in 1m9s
PR checks / java (pull_request) Successful in 1m17s
Main: tests, deploy, autotests / web (push) Successful in 34s
Main: tests, deploy, autotests / images-web (push) Successful in 38s
Main: tests, deploy, autotests / java (push) Successful in 2m36s
Main: tests, deploy, autotests / images-app (push) Successful in 42s
Main: tests, deploy, autotests / deploy (push) Successful in 2m7s
Main: tests, deploy, autotests / autotests (push) Successful in 45s
Main: tests, deploy, autotests / rollback (push) Has been skipped

This commit was merged in pull request #106.
This commit is contained in:
Pjandro
2026-11-13 01:24:25 +03:00
parent d8eda0a2e4
commit 0b2dda8caa
12 changed files with 97 additions and 57 deletions
+37 -19
View File
@@ -2,8 +2,11 @@
<ruleset name="WordPDF code style" 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>Код-стиль java-word-pdf: codestyle без opinionated-правил + unused-правила + NPE-safe equals</description>
<description>Код-стиль java-word-pdf: codestyle без opinionated-правил, unused-правила,
NPE-safe сравнения, гигиена ошибок/ресурсов/многопоточности. Нарушения чинятся
кодом — подавление @SuppressWarnings("PMD…") и // NOPMD запрещены.</description>
<!-- ==================== codestyle ==================== -->
<rule ref="category/java/codestyle.xml">
<!-- opinionated/шумные, намеренно выключены -->
<exclude name="AtLeastOneConstructor"/>
@@ -23,6 +26,8 @@
<!-- переопределены ниже -->
<exclude name="MethodNamingConventions"/>
<exclude name="TooManyStaticImports"/>
<exclude name="ControlStatementBraces"/>
<exclude name="UnnecessaryImport"/>
</rule>
<!-- регрессионные тесты репо именуются объект_условие (AGENTS.md) -->
@@ -39,31 +44,35 @@
</properties>
</rule>
<!-- PMD 7 удалил EqualsAvoidsNull; NPE-safe порядок операндов: литерал слева -->
<rule name="LiteralFirstInEquals" language="java"
message="NPE-safe сравнение строк: строковый литерал должен стоять слева: &quot;lit&quot;.equals(x)"
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<priority>3</priority>
<rule ref="category/java/codestyle.xml/UnnecessaryImport"/>
<!-- case без скобок — норма для этого стиля; true, если строже -->
<rule ref="category/java/codestyle.xml/ControlStatementBraces">
<properties>
<property name="xpath">
<value><![CDATA[
//MethodCall[
(@MethodName = 'equals' or @MethodName = 'equalsIgnoreCase')
and ArgumentList/StringLiteral
and not(*[1][self::StringLiteral
or (self::VariableAccess and @CompileTimeConstant = true())])
]
]]></value>
</property>
<property name="checkCaseStmt" value="false"/>
</properties>
</rule>
<!-- ==================== bestpractices ==================== -->
<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/ForLoopCanBeForeach">
<priority>2</priority>
</rule>
<rule ref="category/java/bestpractices.xml/AvoidPrintStackTrace"/>
<rule ref="category/java/bestpractices.xml/SystemPrintln"/>
<!-- NPE-safe порядок операндов: литерал/константа слева. Заменило кастомное
XPath-правило LiteralFirstInEquals: штатное правило строго шире (константа
справа — тоже нарушение, плюс ==/!= по строкам). -->
<rule ref="category/java/bestpractices.xml/LiteralsFirstInComparisons"/>
<!-- ==================== design ==================== -->
<rule ref="category/java/design.xml/ExceptionAsFlowControl"/>
<!-- ==================== errorprone ==================== -->
<!-- null вместо пустой коллекции запрещён (priority 1 по умолчанию — валит verify) -->
<rule ref="category/java/errorprone.xml/ReturnEmptyCollectionRatherThanNull"/>
<!-- литералы в условиях if — только именованными константами -->
@@ -71,7 +80,16 @@
<rule ref="category/java/errorprone.xml/EmptyCatchBlock">
<priority>2</priority>
</rule>
<rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach">
<priority>2</priority>
</rule>
<rule ref="category/java/errorprone.xml/EqualsNull"/>
<rule ref="category/java/errorprone.xml/CloseResource"/>
<rule ref="category/java/errorprone.xml/BrokenNullCheck"/>
<rule ref="category/java/errorprone.xml/AvoidCatchingNPE"/>
<rule ref="category/java/errorprone.xml/AssignmentToNonFinalStatic"/>
<rule ref="category/java/errorprone.xml/DoNotCallGarbageCollectionExplicitly"/>
<rule ref="category/java/errorprone.xml/CompareObjectsWithEquals"/>
<rule ref="category/java/errorprone.xml/MisplacedNullCheck"/>
<rule ref="category/java/errorprone.xml/ImplicitSwitchFallThrough"/>
<!-- ==================== multithreading ==================== -->
<rule ref="category/java/multithreading.xml/UnsynchronizedStaticFormatter"/>
</ruleset>