From d14d513a7e744290686e5a54748063ca944bbd52 Mon Sep 17 00:00:00 2001 From: James Welch Date: Wed, 14 Aug 2024 12:32:30 +0100 Subject: [PATCH] - Add codenarc config - Remove Jenkins Pipeline file - Update build to correctly publish to snapshot repository --- build.gradle | 23 +- config/codenarc/codenarc.groovy | 452 ++++++++++++++++++++++++++++++++ mdm-bom/build.gradle | 10 + 3 files changed, 472 insertions(+), 13 deletions(-) create mode 100644 config/codenarc/codenarc.groovy diff --git a/build.gradle b/build.gradle index ba4342b47..2dedf2037 100644 --- a/build.gradle +++ b/build.gradle @@ -288,6 +288,16 @@ subprojects { } } } + repositories { + maven { + name = "MauroSnapshotRepository" + url = "https://mauro-repository.com/libs-snapshot-local" + credentials(PasswordCredentials) + authentication { + basic(BasicAuthentication) + } + } + } } } } @@ -340,16 +350,3 @@ FileCollection findNonParallelTestFiles(Project project) { f.text.find(/@Tag\('non-parallel'\)/) } } - -publishing { - repositories { - maven { - name = "MauroSnapshotRepository" - url = "https://mauro-repository.com/libs-snapshot-local" - credentials(PasswordCredentials) - authentication { - basic(BasicAuthentication) - } - } - } -} diff --git a/config/codenarc/codenarc.groovy b/config/codenarc/codenarc.groovy new file mode 100644 index 000000000..0b256901a --- /dev/null +++ b/config/codenarc/codenarc.groovy @@ -0,0 +1,452 @@ +ruleset { + + description ''' + A Sample Groovy RuleSet containing all CodeNarc Rules, grouped by category. + You can use this as a template for your own custom RuleSet. + Just delete the rules that you don't want to include. + ''' + + // rulesets/basic.xml + AssertWithinFinallyBlock + AssignmentInConditional + BigDecimalInstantiation + BitwiseOperatorInConditional + BooleanGetBoolean + BrokenNullCheck + BrokenOddnessCheck + ClassForName + ComparisonOfTwoConstants + ComparisonWithSelf + ConstantAssertExpression + ConstantIfExpression + ConstantTernaryExpression + DeadCode + DoubleNegative + DuplicateCaseStatement + DuplicateMapKey + DuplicateSetValue + EmptyCatchBlock + EmptyClass + EmptyElseBlock + EmptyFinallyBlock + EmptyForStatement + EmptyIfStatement + EmptyInstanceInitializer + EmptyMethod + EmptyStaticInitializer + EmptySwitchStatement + EmptySynchronizedStatement + EmptyTryBlock + EmptyWhileStatement + EqualsAndHashCode + EqualsOverloaded + ExplicitGarbageCollection + ForLoopShouldBeWhileLoop + HardCodedWindowsFileSeparator + HardCodedWindowsRootDirectory + IntegerGetInteger + MultipleUnaryOperators + ParameterAssignmentInFilterClosure + RandomDoubleCoercedToZero + RemoveAllOnSelf + ReturnFromFinallyBlock + ThrowExceptionFromFinallyBlock + + // rulesets/braces.xml + ElseBlockBraces + ForStatementBraces + IfStatementBraces + WhileStatementBraces + + // rulesets/comments.xml + ClassJavadoc + JavadocConsecutiveEmptyLines + JavadocEmptyAuthorTag + JavadocEmptyExceptionTag + JavadocEmptyFirstLine + JavadocEmptyLastLine + JavadocEmptyParamTag + JavadocEmptyReturnTag + JavadocEmptySeeTag + JavadocEmptySinceTag + JavadocEmptyThrowsTag + JavadocEmptyVersionTag + JavadocMissingExceptionDescription + JavadocMissingParamDescription + JavadocMissingThrowsDescription + // SpaceAfterCommentDelimiter -- No such rule? + // SpaceBeforeCommentDelimiter -- No such rule? + + // rulesets/concurrency.xml + BusyWait + DoubleCheckedLocking + InconsistentPropertyLocking + InconsistentPropertySynchronization + NestedSynchronization + // NoScriptBindings -- No such rule? + StaticCalendarField + StaticConnection + StaticDateFormatField + StaticMatcherField + StaticSimpleDateFormatField + SynchronizedMethod + SynchronizedOnBoxedPrimitive + SynchronizedOnGetClass + SynchronizedOnReentrantLock + SynchronizedOnString + SynchronizedOnThis + SynchronizedReadObjectMethod + SystemRunFinalizersOnExit + ThisReferenceEscapesConstructor + ThreadGroup + ThreadLocalNotStaticFinal + ThreadYield + UseOfNotifyMethod + VolatileArrayField + VolatileLongOrDoubleField + WaitOutsideOfWhileLoop + + // rulesets/convention.xml + CompileStatic + ConfusingTernary + CouldBeElvis + CouldBeSwitchStatement + FieldTypeRequired + HashtableIsObsolete + IfStatementCouldBeTernary + //ImplicitClosureParameter - use of 'it' can be cleaner than inventing a new parameter name + //ImplicitReturnStatement - we might do this occasionally + InvertedCondition + InvertedIfElse + LongLiteralWithLowerCaseL + MethodParameterTypeRequired + MethodReturnTypeRequired + NoDef + NoDouble + NoFloat + NoJavaUtilDate + NoTabCharacter + ParameterReassignment + PublicMethodsBeforeNonPublicMethods + StaticFieldsBeforeInstanceFields + //StaticMethodsBeforeInstanceMethods - DSL methods may appear in a block after the otherwise useful methods + TernaryCouldBeElvis + TrailingComma + VariableTypeRequired + VectorIsObsolete + + // rulesets/design.xml + AbstractClassWithPublicConstructor + // AbstractClassWithoutAbstractMethod - TODO: commented out because I think abstract is more explicit than a protected constructor + AssignmentToStaticFieldFromInstanceMethod + BooleanMethodReturnsNull + BuilderMethodWithSideEffects + CloneableWithoutClone + CloseWithoutCloseable + CompareToWithoutComparable + ConstantsOnlyInterface + EmptyMethodInAbstractClass + FinalClassWithProtectedMember + ImplementationAsType + Instanceof + LocaleSetDefault + NestedForLoop + OptionalCollectionReturnType + OptionalField + OptionalMethodParameter + PrivateFieldCouldBeFinal + PublicInstanceField + ReturnsNullInsteadOfEmptyArray + ReturnsNullInsteadOfEmptyCollection + SimpleDateFormatMissingLocale + StatelessSingleton + ToStringReturnsNull + + // rulesets/dry.xml + DuplicateListLiteral + DuplicateMapLiteral + DuplicateNumberLiteral + DuplicateStringLiteral + + // rulesets/enhanced.xml + // CloneWithoutCloneable + // JUnitAssertEqualsConstantActualValue + // MissingOverrideAnnotation + // UnsafeImplementationAsMap + + // rulesets/exceptions.xml + CatchArrayIndexOutOfBoundsException + CatchError + CatchException + CatchIllegalMonitorStateException + CatchIndexOutOfBoundsException + CatchNullPointerException + CatchRuntimeException + CatchThrowable + ConfusingClassNamedException + ExceptionExtendsError + ExceptionExtendsThrowable + ExceptionNotThrown + MissingNewInThrowStatement + ReturnNullFromCatchBlock + SwallowThreadDeath + ThrowError + ThrowException + ThrowNullPointerException + ThrowRuntimeException + ThrowThrowable + + // rulesets/formatting.xml + BlankLineBeforePackage + BlockEndsWithBlankLine + BlockStartsWithBlankLine + BracesForClass + BracesForForLoop + BracesForIfElse + BracesForMethod + BracesForTryCatchFinally + //ClassEndsWithBlankLine + //ClassStartsWithBlankLine + ClosureStatementOnOpeningLineOfMultipleLineClosure + ConsecutiveBlankLines + //FileEndsWithoutNewline + Indentation + LineLength + MissingBlankLineAfterImports + MissingBlankLineAfterPackage + MissingBlankLineBeforeAnnotatedField + SpaceAfterCatch + SpaceAfterClosingBrace + SpaceAfterComma + SpaceAfterFor + SpaceAfterIf + SpaceAfterMethodCallName + SpaceAfterMethodDeclarationName + SpaceAfterNotOperator + SpaceAfterOpeningBrace + SpaceAfterSemicolon + SpaceAfterSwitch + SpaceAfterWhile + SpaceAroundClosureArrow + // SpaceAroundMapEntryColon - Not sure I agree with this one + SpaceAroundOperator + SpaceBeforeClosingBrace + SpaceBeforeOpeningBrace + SpaceInsideParentheses + TrailingWhitespace + + // rulesets/generic.xml + IllegalClassMember + IllegalClassReference + IllegalPackageReference + IllegalRegex + IllegalString + IllegalSubclass + RequiredRegex + RequiredString + StatelessClass + + // rulesets/grails.xml + GrailsDomainGormMethods + GrailsDomainHasEquals + GrailsDomainHasToString + GrailsDomainReservedSqlKeywordName + GrailsDomainStringPropertyMaxSize + GrailsDomainWithServiceReference + GrailsDuplicateConstraint + GrailsDuplicateMapping + GrailsMassAssignment + GrailsPublicControllerMethod + GrailsServletContextReference + GrailsStatelessService + + // rulesets/groovyism.xml + AssignCollectionSort + AssignCollectionUnique + ClosureAsLastMethodParameter + CollectAllIsDeprecated + ConfusingMultipleReturns + ExplicitArrayListInstantiation + ExplicitCallToAndMethod + ExplicitCallToCompareToMethod + ExplicitCallToDivMethod + ExplicitCallToEqualsMethod + ExplicitCallToGetAtMethod + ExplicitCallToLeftShiftMethod + ExplicitCallToMinusMethod + ExplicitCallToModMethod + ExplicitCallToMultiplyMethod + ExplicitCallToOrMethod + ExplicitCallToPlusMethod + ExplicitCallToPowerMethod + ExplicitCallToPutAtMethod + ExplicitCallToRightShiftMethod + ExplicitCallToXorMethod + ExplicitHashMapInstantiation + ExplicitHashSetInstantiation + ExplicitLinkedHashMapInstantiation + ExplicitLinkedListInstantiation + ExplicitStackInstantiation + ExplicitTreeSetInstantiation + GStringAsMapKey + GStringExpressionWithinString + GetterMethodCouldBeProperty + GroovyLangImmutable + UseCollectMany + UseCollectNested + + // rulesets/imports.xml + DuplicateImport + ImportFromSamePackage + ImportFromSunPackages + MisorderedStaticImports + NoWildcardImports + UnnecessaryGroovyImport + UnusedImport + + // rulesets/jdbc.xml + DirectConnectionManagement + JdbcConnectionReference + JdbcResultSetReference + JdbcStatementReference + + // rulesets/junit.xml + ChainedTest + CoupledTestCase + JUnitAssertAlwaysFails + JUnitAssertAlwaysSucceeds + JUnitFailWithoutMessage + JUnitLostTest + JUnitPublicField + JUnitPublicNonTestMethod + JUnitPublicProperty + JUnitSetUpCallsSuper + JUnitStyleAssertions + JUnitTearDownCallsSuper + JUnitTestMethodWithoutAssert + JUnitUnnecessarySetUp + JUnitUnnecessaryTearDown + JUnitUnnecessaryThrowsException + SpockIgnoreRestUsed + // SpockMissingAssert -- No such rule? + UnnecessaryFail + UseAssertEqualsInsteadOfAssertTrue + UseAssertFalseInsteadOfNegation + UseAssertNullInsteadOfAssertEquals + UseAssertSameInsteadOfAssertTrue + UseAssertTrueInsteadOfAssertEquals + UseAssertTrueInsteadOfNegation + + // rulesets/logging.xml + LoggerForDifferentClass + LoggerWithWrongModifiers + LoggingSwallowsStacktrace + MultipleLoggers + PrintStackTrace + Println + SystemErrPrint + SystemOutPrint + + // rulesets/naming.xml + AbstractClassName + ClassName + ClassNameSameAsFilename + ClassNameSameAsSuperclass + // ConfusingMethodName - DSL methods are deliberately named the same as properties + // FactoryMethodName - We use "createdBy" as a property name all over the place + FieldName + InterfaceName + InterfaceNameSameAsSuperInterface + MethodName + ObjectOverrideMisspelledMethodName + PackageName + PackageNameMatchesFilePath + ParameterName + PropertyName + VariableName + + // rulesets/security.xml + FileCreateTempFile + InsecureRandom + JavaIoPackageAccess + NonFinalPublicField + NonFinalSubclassOfSensitiveInterface + ObjectFinalize + PublicFinalizeMethod + SystemExit + UnsafeArrayDeclaration + + // rulesets/serialization.xml + EnumCustomSerializationIgnored + SerialPersistentFields + SerialVersionUID + SerializableClassMustDefineSerialVersionUID + + // rulesets/size.xml + // AbcMetric // Requires the GMetrics jar - TODO: commented out for now because it's not currently helpful. + ClassSize + CrapMetric // Requires the GMetrics jar and a Cobertura coverage file + CyclomaticComplexity // Requires the GMetrics jar + MethodCount + MethodSize + NestedBlockDepth + ParameterCount + + // rulesets/unnecessary.xml + AddEmptyString + ConsecutiveLiteralAppends + ConsecutiveStringConcatenation + UnnecessaryBigDecimalInstantiation + UnnecessaryBigIntegerInstantiation + UnnecessaryBooleanExpression + UnnecessaryBooleanInstantiation + UnnecessaryCallForLastElement + UnnecessaryCallToSubstring + UnnecessaryCast + UnnecessaryCatchBlock + // UnnecessaryCollectCall - Not sure * is always easier to read. + UnnecessaryCollectionCall + UnnecessaryConstructor + UnnecessaryDefInFieldDeclaration + UnnecessaryDefInMethodDeclaration + UnnecessaryDefInVariableDeclaration + UnnecessaryDotClass + UnnecessaryDoubleInstantiation + UnnecessaryElseStatement + UnnecessaryFinalOnPrivateMethod + UnnecessaryFloatInstantiation + UnnecessaryGString + UnnecessaryGetter + UnnecessaryIfStatement + UnnecessaryInstanceOfCheck + UnnecessaryInstantiationToGetClass + UnnecessaryIntegerInstantiation + UnnecessaryLongInstantiation + UnnecessaryModOne + UnnecessaryNullCheck + UnnecessaryNullCheckBeforeInstanceOf + UnnecessaryObjectReferences + UnnecessaryOverridingMethod + UnnecessaryPackageReference + UnnecessaryParenthesesForMethodCallWithClosure + UnnecessaryPublicModifier + // UnnecessaryReturnKeyword - We might do this occasionally + UnnecessarySafeNavigationOperator + UnnecessarySelfAssignment + UnnecessarySemicolon + UnnecessarySetter + UnnecessaryStringInstantiation + UnnecessaryTernaryExpression + UnnecessaryToString + UnnecessaryTransientModifier + + // rulesets/unused.xml + UnusedArray + UnusedMethodParameter + UnusedObject + UnusedPrivateField + UnusedPrivateMethod + UnusedPrivateMethodParameter + UnusedVariable + +} \ No newline at end of file diff --git a/mdm-bom/build.gradle b/mdm-bom/build.gradle index 4b265d2e1..1e8382e1f 100644 --- a/mdm-bom/build.gradle +++ b/mdm-bom/build.gradle @@ -29,6 +29,16 @@ repositories { } publishing { + repositories { + maven { + name = "MauroSnapshotRepository" + url = "https://mauro-repository.com/libs-snapshot-local" + credentials(PasswordCredentials) + authentication { + basic(BasicAuthentication) + } + } + } publications { mdmPlatform(MavenPublication) { from components.javaPlatform