Add coding standards and quality enforcement tooling

- docs/coding-standards.md: Comprehensive Java coding standards
- CLAUDE.md: AI assistant instructions for the project
- .editorconfig: Editor configuration for consistent formatting
- pom.xml: Updated with quality plugins (Checkstyle, SpotBugs, PMD, JaCoCo)
- config/checkstyle/: Checkstyle configuration (Google Java Style based)
- config/spotbugs/: SpotBugs exclusions
- config/pmd/: PMD ruleset
- .githooks/pre-commit: Pre-commit hook for local quality checks
- .github/workflows/lint.yml: CI workflow for automated quality checks
- docs/development.md: Updated for Java/Maven toolchain

Quality enforcement:
- Checkstyle runs on validate phase
- SpotBugs and PMD run on verify phase
- JaCoCo enforces 80% line coverage, 70% branch coverage
- Pre-commit hook runs all checks before allowing commits
- CI runs all checks on push and PR

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Daniel SamsonandClaude Opus 4.5 committed 2026-01-21 12:22:06 +00:00
1 parent cf750b6eb5
commit 3c09ea978d
12 files changed
+2241 -92

No files matched your search

+264
View File
@@ -0,0 +1,264 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<!--
Checkstyle configuration for Barn.
Based on Google Java Style Guide with modifications for Java 21+.
-->
<module name="Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/>
<property name="fileExtensions" value="java"/>
<!-- Suppressions -->
<module name="SuppressionFilter">
<property name="file" value="${config_loc}/suppressions.xml"/>
<property name="optional" value="true"/>
</module>
<!-- File Length -->
<module name="FileLength">
<property name="max" value="500"/>
</module>
<!-- Line Length -->
<module name="LineLength">
<property name="max" value="120"/>
<property name="ignorePattern" value="^package.*|^import.*|a]+ href|href|http://|https://|ftp://"/>
</module>
<!-- No Tab Characters -->
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
<!-- Trailing Whitespace -->
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="message" value="Line has trailing spaces."/>
</module>
<!-- Newline at End of File -->
<module name="NewlineAtEndOfFile"/>
<module name="TreeWalker">
<!-- =============================================================== -->
<!-- NAMING CONVENTIONS -->
<!-- =============================================================== -->
<module name="PackageName">
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
</module>
<module name="TypeName">
<property name="format" value="^[A-Z][a-zA-Z0-9]*$"/>
</module>
<module name="MethodName">
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
</module>
<module name="MemberName">
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
</module>
<module name="ParameterName">
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
</module>
<module name="LocalVariableName">
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
</module>
<module name="ConstantName">
<property name="format" value="^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
</module>
<module name="StaticVariableName">
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
</module>
<!-- =============================================================== -->
<!-- IMPORTS -->
<!-- =============================================================== -->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports"/>
<module name="ImportOrder">
<property name="groups" value="/^java\./,javax,org,com"/>
<property name="ordered" value="true"/>
<property name="separated" value="true"/>
<property name="option" value="top"/>
<property name="sortStaticImportsAlphabetically" value="true"/>
</module>
<!-- =============================================================== -->
<!-- WHITESPACE -->
<!-- =============================================================== -->
<module name="GenericWhitespace"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter">
<property name="tokens" value="AT,INC,DEC,UNARY_MINUS,UNARY_PLUS,BNOT,LNOT,DOT,ARRAY_DECLARATOR,INDEX_OP"/>
</module>
<module name="NoWhitespaceBefore"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround">
<property name="allowEmptyConstructors" value="true"/>
<property name="allowEmptyMethods" value="true"/>
<property name="allowEmptyTypes" value="true"/>
<property name="allowEmptyLoops" value="true"/>
</module>
<module name="EmptyLineSeparator">
<property name="allowNoEmptyLineBetweenFields" value="true"/>
<property name="allowMultipleEmptyLines" value="false"/>
<property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
</module>
<module name="Indentation">
<property name="basicOffset" value="4"/>
<property name="caseIndent" value="4"/>
<property name="arrayInitIndent" value="4"/>
</module>
<!-- =============================================================== -->
<!-- BRACES -->
<!-- =============================================================== -->
<module name="LeftCurly"/>
<module name="RightCurly"/>
<module name="NeedBraces"/>
<!-- =============================================================== -->
<!-- CODING -->
<!-- =============================================================== -->
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="HiddenField">
<property name="ignoreConstructorParameter" value="true"/>
<property name="ignoreSetter" value="true"/>
</module>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MissingSwitchDefault"/>
<module name="MultipleVariableDeclarations"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<module name="StringLiteralEquality"/>
<module name="OneStatementPerLine"/>
<module name="OverloadMethodsDeclarationOrder"/>
<module name="VariableDeclarationUsageDistance"/>
<module name="DefaultComesLast"/>
<module name="FallThrough"/>
<module name="UnnecessaryParentheses"/>
<module name="UnnecessarySemicolonAfterTypeMemberDeclaration"/>
<module name="UnnecessarySemicolonInEnumeration"/>
<module name="UnnecessarySemicolonInTryWithResources"/>
<!-- =============================================================== -->
<!-- DESIGN -->
<!-- =============================================================== -->
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="OneTopLevelClass"/>
<module name="VisibilityModifier">
<property name="allowPublicFinalFields" value="true"/>
<property name="protectedAllowed" value="true"/>
</module>
<!-- =============================================================== -->
<!-- JAVADOC -->
<!-- =============================================================== -->
<module name="InvalidJavadocPosition"/>
<module name="JavadocMethod">
<property name="accessModifiers" value="public"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
</module>
<module name="JavadocType">
<property name="scope" value="public"/>
</module>
<module name="JavadocStyle">
<property name="checkFirstSentence" value="false"/>
</module>
<module name="MissingJavadocMethod">
<property name="scope" value="public"/>
<property name="minLineCount" value="2"/>
<property name="allowedAnnotations" value="Override, Test, BeforeEach, AfterEach, BeforeAll, AfterAll"/>
</module>
<module name="MissingJavadocType">
<property name="scope" value="public"/>
<property name="skipAnnotations" value="Generated"/>
</module>
<!-- =============================================================== -->
<!-- MISCELLANEOUS -->
<!-- =============================================================== -->
<module name="ArrayTypeStyle"/>
<module name="CommentsIndentation"/>
<module name="UpperEll"/>
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<!-- Suppress warnings with @SuppressWarnings annotation -->
<module name="SuppressWarningsHolder"/>
</module>
<module name="SuppressWarningsFilter"/>
</module>
+21
View File
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<!-- Suppress Javadoc requirements for test classes -->
<suppress checks="MissingJavadocType" files=".*Test\.java$"/>
<suppress checks="MissingJavadocMethod" files=".*Test\.java$"/>
<suppress checks="JavadocMethod" files=".*Test\.java$"/>
<suppress checks="JavadocType" files=".*Test\.java$"/>
<!-- Suppress magic number checks in tests -->
<suppress checks="MagicNumber" files=".*Test\.java$"/>
<!-- Allow longer lines in test files -->
<suppress checks="LineLength" files=".*Test\.java$"/>
<!-- Suppress for generated code -->
<suppress checks=".*" files=".*[\\/]generated[\\/].*"/>
</suppressions>
+160
View File
@@ -0,0 +1,160 @@
<?xml version="1.0"?>
<ruleset name="Barn PMD Ruleset"
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>
PMD ruleset for Barn project.
Based on PMD best practices with adjustments for modern Java.
</description>
<!-- ================================================================== -->
<!-- BEST PRACTICES -->
<!-- ================================================================== -->
<rule ref="category/java/bestpractices.xml">
<!-- Allow JUnit 5 assertions -->
<exclude name="JUnitTestContainsTooManyAsserts"/>
<exclude name="JUnitAssertionsShouldIncludeMessage"/>
<!-- We use Mockito, not JUnit 4 -->
<exclude name="JUnit4TestShouldUseTestAnnotation"/>
<exclude name="JUnit4TestShouldUseBeforeAnnotation"/>
<exclude name="JUnit4TestShouldUseAfterAnnotation"/>
</rule>
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod">
<properties>
<property name="ignoredAnnotations" value="jakarta.annotation.PostConstruct|javax.annotation.PostConstruct"/>
</properties>
</rule>
<!-- ================================================================== -->
<!-- CODE STYLE -->
<!-- ================================================================== -->
<rule ref="category/java/codestyle.xml">
<!-- We prefer explicit imports -->
<exclude name="OnlyOneReturn"/>
<!-- Allow short variable names like 'id', 'in', 'out' -->
<exclude name="ShortVariable"/>
<!-- Allow longer method names for clarity -->
<exclude name="LongVariable"/>
<!-- Allow static imports for test utilities -->
<exclude name="TooManyStaticImports"/>
<!-- We have our own formatting rules -->
<exclude name="AtLeastOneConstructor"/>
<!-- Allow default package for CLI commands -->
<exclude name="CommentDefaultAccessModifier"/>
<!-- Java 21+ has useful implicit classes -->
<exclude name="UnnecessaryFullyQualifiedName"/>
</rule>
<rule ref="category/java/codestyle.xml/ClassNamingConventions">
<properties>
<property name="utilityClassPattern" value="[A-Z][a-zA-Z0-9]+(Utils?|Helper|Constants)"/>
</properties>
</rule>
<rule ref="category/java/codestyle.xml/MethodNamingConventions">
<properties>
<property name="methodPattern" value="[a-z][a-zA-Z0-9]*"/>
<property name="nativePattern" value="[a-z][a-zA-Z0-9]*"/>
</properties>
</rule>
<!-- ================================================================== -->
<!-- DESIGN -->
<!-- ================================================================== -->
<rule ref="category/java/design.xml">
<!-- Modern Java allows reasonable complexity -->
<exclude name="LawOfDemeter"/>
<!-- Allow data classes with many fields -->
<exclude name="TooManyFields"/>
<!-- Exclude for builders and configs -->
<exclude name="ExcessivePublicCount"/>
<!-- Allow reasonable method size -->
<exclude name="ExcessiveMethodLength"/>
<!-- Allow reasonable class size -->
<exclude name="ExcessiveClassLength"/>
<!-- Too strict for modern patterns -->
<exclude name="AvoidCatchingGenericException"/>
</rule>
<rule ref="category/java/design.xml/CyclomaticComplexity">
<properties>
<property name="classReportLevel" value="80"/>
<property name="methodReportLevel" value="15"/>
</properties>
</rule>
<rule ref="category/java/design.xml/NPathComplexity">
<properties>
<property name="reportLevel" value="200"/>
</properties>
</rule>
<rule ref="category/java/design.xml/TooManyMethods">
<properties>
<property name="maxmethods" value="25"/>
</properties>
</rule>
<!-- ================================================================== -->
<!-- DOCUMENTATION -->
<!-- ================================================================== -->
<rule ref="category/java/documentation.xml">
<exclude name="CommentRequired"/>
<exclude name="CommentSize"/>
</rule>
<!-- ================================================================== -->
<!-- ERROR PRONE -->
<!-- ================================================================== -->
<rule ref="category/java/errorprone.xml">
<!-- Allow null assignments in cleanup -->
<exclude name="NullAssignment"/>
<!-- Allow close in finally for legacy code -->
<exclude name="CloseResource"/>
<!-- We validate beans differently -->
<exclude name="BeanMembersShouldSerialize"/>
<!-- Too strict -->
<exclude name="DataflowAnomalyAnalysis"/>
</rule>
<rule ref="category/java/errorprone.xml/AvoidLiteralsInIfCondition">
<properties>
<property name="ignoreMagicNumbers" value="-1,0,1,2"/>
<property name="ignoreExpressions" value="true"/>
</properties>
</rule>
<!-- ================================================================== -->
<!-- MULTITHREADING -->
<!-- ================================================================== -->
<rule ref="category/java/multithreading.xml">
<!-- We use modern concurrency utilities -->
<exclude name="UseConcurrentHashMap"/>
<exclude name="DoNotUseThreads"/>
</rule>
<!-- ================================================================== -->
<!-- PERFORMANCE -->
<!-- ================================================================== -->
<rule ref="category/java/performance.xml">
<!-- Modern JVM handles this well -->
<exclude name="AvoidInstantiatingObjectsInLoops"/>
</rule>
<!-- ================================================================== -->
<!-- SECURITY -->
<!-- ================================================================== -->
<rule ref="category/java/security.xml"/>
</ruleset>
+49
View File
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter
xmlns="https://github.com/spotbugs/filter/3.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">
<!-- Exclude test classes from certain checks -->
<Match>
<Source name="~.*Test\.java"/>
<Or>
<Bug pattern="DM_DEFAULT_ENCODING"/>
<Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"/>
</Or>
</Match>
<!-- Exclude generated code -->
<Match>
<Source name="~.*[\\/]generated[\\/].*"/>
</Match>
<!-- Allow System.exit in Main class -->
<Match>
<Class name="com.samsonmedia.barn.Main"/>
<Bug pattern="DM_EXIT"/>
</Match>
<!-- Allow command execution in specific classes -->
<Match>
<Or>
<Class name="~.*ProcessExecutor.*"/>
<Class name="~.*CommandRunner.*"/>
</Or>
<Bug pattern="COMMAND_INJECTION"/>
</Match>
<!-- Exclude false positives for try-with-resources -->
<Match>
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE"/>
</Match>
<!-- Allow serialization without serialVersionUID for internal classes -->
<Match>
<Bug pattern="SE_NO_SERIALVERSIONID"/>
<Not>
<Class name="~.*Exception"/>
</Not>
</Match>
</FindBugsFilter>