├── .checkstyle ├── .fbprefs ├── .gitignore ├── .pmd ├── .settings ├── org.eclipse.core.resources.prefs ├── org.eclipse.jdt.core.prefs ├── org.eclipse.jdt.ui.prefs ├── org.eclipse.m2e.core.prefs └── org.moreunit.prefs ├── Jenkinsfile ├── License.txt ├── PMD-Icons-license.txt ├── README.md ├── debug.sh ├── german.sh ├── go.sh ├── pmd.iml ├── pom.xml ├── release.sh └── src ├── main ├── java │ └── hudson │ │ └── plugins │ │ └── pmd │ │ ├── MavenPmdResultAction.java │ │ ├── PmdAnnotationsAggregator.java │ │ ├── PmdColumn.java │ │ ├── PmdDescriptor.java │ │ ├── PmdHealthDescriptor.java │ │ ├── PmdMavenResult.java │ │ ├── PmdMavenResultAction.java │ │ ├── PmdPlugin.java │ │ ├── PmdProjectAction.java │ │ ├── PmdPublisher.java │ │ ├── PmdReporter.java │ │ ├── PmdReporterDescriptor.java │ │ ├── PmdReporterResult.java │ │ ├── PmdResult.java │ │ ├── PmdResultAction.java │ │ ├── dashboard │ │ ├── WarningsNewVersusFixedGraphPortlet.java │ │ ├── WarningsPriorityGraphPortlet.java │ │ ├── WarningsTablePortlet.java │ │ ├── WarningsTotalsGraphPortlet.java │ │ └── WarningsUserGraphPortlet.java │ │ ├── parser │ │ ├── Bug.java │ │ ├── File.java │ │ ├── Pmd.java │ │ ├── PmdMessages.java │ │ ├── PmdParser.java │ │ └── Violation.java │ │ └── tokens │ │ ├── FixedPmdWarningsTokenMacro.java │ │ ├── NewPmdWarningsTokenMacro.java │ │ ├── PmdResultTokenMacro.java │ │ └── PmdWarningCountTokenMacro.java ├── resources │ ├── hudson │ │ └── plugins │ │ │ └── pmd │ │ │ ├── Messages.properties │ │ │ ├── Messages_de.properties │ │ │ ├── Messages_fr.properties │ │ │ ├── Messages_ja.properties │ │ │ ├── Messages_nl.properties │ │ │ ├── Messages_zh_TW.properties │ │ │ ├── PmdPublisher │ │ │ ├── config.jelly │ │ │ ├── config.properties │ │ │ ├── config_de.properties │ │ │ ├── config_ja.properties │ │ │ ├── config_zh_TW.properties │ │ │ └── global.jelly │ │ │ ├── PmdReporter │ │ │ ├── config.jelly │ │ │ └── global.jelly │ │ │ └── tokens │ │ │ ├── FixedPmdWarningsTokenMacro │ │ │ └── help.jelly │ │ │ ├── NewPmdWarningsTokenMacro │ │ │ └── help.jelly │ │ │ ├── PmdResultTokenMacro │ │ │ └── help.jelly │ │ │ └── PmdWarningCountTokenMacro │ │ │ └── help.jelly │ └── index.jelly └── webapp │ ├── help-m2.html │ ├── help-m2_de.html │ ├── help-m2_zh_TW.html │ ├── help.html │ ├── help_de.html │ ├── help_zh_TW.html │ └── icons │ ├── LICENSE.txt │ ├── pmd-24x24.png │ └── pmd-48x48.png └── test ├── java └── hudson │ └── plugins │ └── pmd │ ├── PmdHealthDescriptorTest.java │ ├── PmdResultTest.java │ ├── PmdWorkflowTest.java │ └── parser │ ├── BugSerializeModelTest.java │ ├── BugsDifferencerTest.java │ ├── PmdMessagesTest.java │ └── PmdParserTest.java └── resources └── hudson └── plugins └── pmd └── parser ├── 4-pmd-warnings.xml ├── empty.xml ├── equals-test.xml ├── issue12801.xml ├── otherfile.xml ├── pmd.xml ├── project.ser ├── project.ser.xml └── warning-message-with-dot.xml /.checkstyle: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.fbprefs: -------------------------------------------------------------------------------- 1 | #FindBugs User Preferences 2 | #Fri Jul 13 08:53:48 CEST 2012 3 | cloud_id=edu.umd.cs.findbugs.cloud.doNothingCloud 4 | detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true 5 | detectorAtomicityProblem=AtomicityProblem|true 6 | detectorBadAppletConstructor=BadAppletConstructor|false 7 | detectorBadResultSetAccess=BadResultSetAccess|true 8 | detectorBadSyntaxForRegularExpression=BadSyntaxForRegularExpression|true 9 | detectorBadUseOfReturnValue=BadUseOfReturnValue|true 10 | detectorBadlyOverriddenAdapter=BadlyOverriddenAdapter|true 11 | detectorBooleanReturnNull=BooleanReturnNull|true 12 | detectorCallToUnsupportedMethod=CallToUnsupportedMethod|false 13 | detectorCheckExpectedWarnings=CheckExpectedWarnings|false 14 | detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true 15 | detectorCheckTypeQualifiers=CheckTypeQualifiers|true 16 | detectorCloneIdiom=CloneIdiom|true 17 | detectorComparatorIdiom=ComparatorIdiom|true 18 | detectorConfusedInheritance=ConfusedInheritance|true 19 | detectorConfusionBetweenInheritedAndOuterMethod=ConfusionBetweenInheritedAndOuterMethod|true 20 | detectorCrossSiteScripting=CrossSiteScripting|true 21 | detectorDefaultEncodingDetector=DefaultEncodingDetector|true 22 | detectorDoInsideDoPrivileged=DoInsideDoPrivileged|true 23 | detectorDontCatchIllegalMonitorStateException=DontCatchIllegalMonitorStateException|true 24 | detectorDontIgnoreResultOfPutIfAbsent=DontIgnoreResultOfPutIfAbsent|true 25 | detectorDontUseEnum=DontUseEnum|true 26 | detectorDroppedException=DroppedException|true 27 | detectorDumbMethodInvocations=DumbMethodInvocations|true 28 | detectorDumbMethods=DumbMethods|true 29 | detectorDuplicateBranches=DuplicateBranches|true 30 | detectorEmptyZipFileEntry=EmptyZipFileEntry|true 31 | detectorEqualsOperandShouldHaveClassCompatibleWithThis=EqualsOperandShouldHaveClassCompatibleWithThis|true 32 | detectorExplicitSerialization=ExplicitSerialization|true 33 | detectorFinalizerNullsFields=FinalizerNullsFields|true 34 | detectorFindBadCast2=FindBadCast2|true 35 | detectorFindBadForLoop=FindBadForLoop|true 36 | detectorFindCircularDependencies=FindCircularDependencies|true 37 | detectorFindDeadLocalStores=FindDeadLocalStores|true 38 | detectorFindDoubleCheck=FindDoubleCheck|true 39 | detectorFindEmptySynchronizedBlock=FindEmptySynchronizedBlock|true 40 | detectorFindFieldSelfAssignment=FindFieldSelfAssignment|true 41 | detectorFindFinalizeInvocations=FindFinalizeInvocations|true 42 | detectorFindFloatEquality=FindFloatEquality|true 43 | detectorFindHEmismatch=FindHEmismatch|true 44 | detectorFindInconsistentSync2=FindInconsistentSync2|true 45 | detectorFindJSR166LockMonitorenter=FindJSR166LockMonitorenter|true 46 | detectorFindLocalSelfAssignment2=FindLocalSelfAssignment2|true 47 | detectorFindMaskedFields=FindMaskedFields|true 48 | detectorFindMismatchedWaitOrNotify=FindMismatchedWaitOrNotify|true 49 | detectorFindNakedNotify=FindNakedNotify|true 50 | detectorFindNonSerializableStoreIntoSession=FindNonSerializableStoreIntoSession|true 51 | detectorFindNonSerializableValuePassedToWriteObject=FindNonSerializableValuePassedToWriteObject|true 52 | detectorFindNonShortCircuit=FindNonShortCircuit|true 53 | detectorFindNullDeref=FindNullDeref|true 54 | detectorFindNullDerefsInvolvingNonShortCircuitEvaluation=FindNullDerefsInvolvingNonShortCircuitEvaluation|true 55 | detectorFindOpenStream=FindOpenStream|true 56 | detectorFindPuzzlers=FindPuzzlers|true 57 | detectorFindRefComparison=FindRefComparison|true 58 | detectorFindReturnRef=FindReturnRef|true 59 | detectorFindRunInvocations=FindRunInvocations|true 60 | detectorFindSelfComparison=FindSelfComparison|true 61 | detectorFindSelfComparison2=FindSelfComparison2|true 62 | detectorFindSleepWithLockHeld=FindSleepWithLockHeld|true 63 | detectorFindSpinLoop=FindSpinLoop|true 64 | detectorFindSqlInjection=FindSqlInjection|true 65 | detectorFindTwoLockWait=FindTwoLockWait|true 66 | detectorFindUncalledPrivateMethods=FindUncalledPrivateMethods|true 67 | detectorFindUnconditionalWait=FindUnconditionalWait|true 68 | detectorFindUninitializedGet=FindUninitializedGet|true 69 | detectorFindUnrelatedTypesInGenericContainer=FindUnrelatedTypesInGenericContainer|true 70 | detectorFindUnreleasedLock=FindUnreleasedLock|true 71 | detectorFindUnsatisfiedObligation=FindUnsatisfiedObligation|true 72 | detectorFindUnsyncGet=FindUnsyncGet|true 73 | detectorFindUseOfNonSerializableValue=FindUseOfNonSerializableValue|true 74 | detectorFindUselessControlFlow=FindUselessControlFlow|true 75 | detectorFormatStringChecker=FormatStringChecker|true 76 | detectorHugeSharedStringConstants=HugeSharedStringConstants|true 77 | detectorIDivResultCastToDouble=IDivResultCastToDouble|true 78 | detectorIncompatMask=IncompatMask|true 79 | detectorInconsistentAnnotations=InconsistentAnnotations|true 80 | detectorInefficientMemberAccess=InefficientMemberAccess|false 81 | detectorInefficientToArray=InefficientToArray|true 82 | detectorInfiniteLoop=InfiniteLoop|true 83 | detectorInfiniteRecursiveLoop=InfiniteRecursiveLoop|true 84 | detectorInfiniteRecursiveLoop2=InfiniteRecursiveLoop2|false 85 | detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true 86 | detectorInitializationChain=InitializationChain|true 87 | detectorInstantiateStaticClass=InstantiateStaticClass|true 88 | detectorIntCast2LongAsInstant=IntCast2LongAsInstant|true 89 | detectorInvalidJUnitTest=InvalidJUnitTest|true 90 | detectorIteratorIdioms=IteratorIdioms|true 91 | detectorLazyInit=LazyInit|true 92 | detectorLoadOfKnownNullValue=LoadOfKnownNullValue|true 93 | detectorLostLoggerDueToWeakReference=LostLoggerDueToWeakReference|true 94 | detectorMethodReturnCheck=MethodReturnCheck|true 95 | detectorMultithreadedInstanceAccess=MultithreadedInstanceAccess|true 96 | detectorMutableLock=MutableLock|true 97 | detectorMutableStaticFields=MutableStaticFields|true 98 | detectorNaming=Naming|true 99 | detectorNoteUnconditionalParamDerefs=NoteUnconditionalParamDerefs|true 100 | detectorNumberConstructor=NumberConstructor|true 101 | detectorOverridingEqualsNotSymmetrical=OverridingEqualsNotSymmetrical|true 102 | detectorPreferZeroLengthArrays=PreferZeroLengthArrays|true 103 | detectorPublicSemaphores=PublicSemaphores|false 104 | detectorQuestionableBooleanAssignment=QuestionableBooleanAssignment|true 105 | detectorReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass=ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass|true 106 | detectorReadReturnShouldBeChecked=ReadReturnShouldBeChecked|true 107 | detectorRedundantInterfaces=RedundantInterfaces|true 108 | detectorRepeatedConditionals=RepeatedConditionals|true 109 | detectorRuntimeExceptionCapture=RuntimeExceptionCapture|true 110 | detectorSerializableIdiom=SerializableIdiom|true 111 | detectorStartInConstructor=StartInConstructor|true 112 | detectorStaticCalendarDetector=StaticCalendarDetector|true 113 | detectorStringConcatenation=StringConcatenation|true 114 | detectorSuperfluousInstanceOf=SuperfluousInstanceOf|true 115 | detectorSuspiciousThreadInterrupted=SuspiciousThreadInterrupted|true 116 | detectorSwitchFallthrough=SwitchFallthrough|true 117 | detectorSynchronizeAndNullCheckField=SynchronizeAndNullCheckField|true 118 | detectorSynchronizeOnClassLiteralNotGetClass=SynchronizeOnClassLiteralNotGetClass|true 119 | detectorSynchronizingOnContentsOfFieldToProtectField=SynchronizingOnContentsOfFieldToProtectField|true 120 | detectorURLProblems=URLProblems|true 121 | detectorUncallableMethodOfAnonymousClass=UncallableMethodOfAnonymousClass|true 122 | detectorUnnecessaryMath=UnnecessaryMath|true 123 | detectorUnreadFields=UnreadFields|true 124 | detectorUseObjectEquals=UseObjectEquals|true 125 | detectorUselessSubclassMethod=UselessSubclassMethod|true 126 | detectorVarArgsProblems=VarArgsProblems|true 127 | detectorVolatileUsage=VolatileUsage|true 128 | detectorWaitInLoop=WaitInLoop|true 129 | detectorWrongMapIterator=WrongMapIterator|true 130 | detectorXMLFactoryBypass=XMLFactoryBypass|true 131 | detector_threshold=3 132 | effort=max 133 | excludefilter0=../analysis-config/etc/findbugs-exclusion-filter.xml|true 134 | filter_settings=Low|BAD_PRACTICE,CORRECTNESS,EXPERIMENTAL,I18N,MALICIOUS_CODE,MT_CORRECTNESS,PERFORMANCE,SECURITY,STYLE|false|20 135 | filter_settings_neg=NOISE| 136 | run_at_full_build=true 137 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | work -------------------------------------------------------------------------------- /.pmd: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | ../analysis-config/etc/pmd-configuration.xml 5 | false 6 | false 7 | true 8 | 9 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=ISO-8859-1 3 | encoding//src/main/resources=ISO-8859-1 4 | encoding//src/test/java=ISO-8859-1 5 | encoding//src/test/resources=ISO-8859-1 6 | encoding/=ISO-8859-1 7 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.codeComplete.argumentPrefixes= 3 | org.eclipse.jdt.core.codeComplete.argumentSuffixes= 4 | org.eclipse.jdt.core.codeComplete.fieldPrefixes= 5 | org.eclipse.jdt.core.codeComplete.fieldSuffixes= 6 | org.eclipse.jdt.core.codeComplete.localPrefixes= 7 | org.eclipse.jdt.core.codeComplete.localSuffixes= 8 | org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= 9 | org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= 10 | org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= 11 | org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= 12 | org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore 13 | org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull 14 | org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault 15 | org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable 16 | org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled 17 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 18 | org.eclipse.jdt.core.compiler.compliance=1.5 19 | org.eclipse.jdt.core.compiler.doc.comment.support=enabled 20 | org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning 21 | org.eclipse.jdt.core.compiler.problem.autoboxing=ignore 22 | org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning 23 | org.eclipse.jdt.core.compiler.problem.deadCode=warning 24 | org.eclipse.jdt.core.compiler.problem.deprecation=warning 25 | org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled 26 | org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled 27 | org.eclipse.jdt.core.compiler.problem.discouragedReference=warning 28 | org.eclipse.jdt.core.compiler.problem.emptyStatement=warning 29 | org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore 30 | org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning 31 | org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled 32 | org.eclipse.jdt.core.compiler.problem.fieldHiding=warning 33 | org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning 34 | org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning 35 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 36 | org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning 37 | org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled 38 | org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning 39 | org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning 40 | org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning 41 | org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning 42 | org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled 43 | org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled 44 | org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled 45 | org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private 46 | org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning 47 | org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning 48 | org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore 49 | org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning 50 | org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled 51 | org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore 52 | org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning 53 | org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled 54 | org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected 55 | org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag 56 | org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning 57 | org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled 58 | org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled 59 | org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private 60 | org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning 61 | org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled 62 | org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning 63 | org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore 64 | org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning 65 | org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning 66 | org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore 67 | org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning 68 | org.eclipse.jdt.core.compiler.problem.nullReference=warning 69 | org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning 70 | org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning 71 | org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning 72 | org.eclipse.jdt.core.compiler.problem.parameterAssignment=warning 73 | org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning 74 | org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning 75 | org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore 76 | org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning 77 | org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning 78 | org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning 79 | org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore 80 | org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore 81 | org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore 82 | org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore 83 | org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled 84 | org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning 85 | org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled 86 | org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled 87 | org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore 88 | org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning 89 | org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled 90 | org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning 91 | org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning 92 | org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning 93 | org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore 94 | org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore 95 | org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning 96 | org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore 97 | org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning 98 | org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled 99 | org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled 100 | org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled 101 | org.eclipse.jdt.core.compiler.problem.unusedImport=warning 102 | org.eclipse.jdt.core.compiler.problem.unusedLabel=warning 103 | org.eclipse.jdt.core.compiler.problem.unusedLocal=warning 104 | org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore 105 | org.eclipse.jdt.core.compiler.problem.unusedParameter=warning 106 | org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled 107 | org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled 108 | org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled 109 | org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning 110 | org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning 111 | org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning 112 | org.eclipse.jdt.core.compiler.source=1.5 113 | org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled 114 | org.eclipse.jdt.core.compiler.taskPriorities=HIGH,NORMAL 115 | org.eclipse.jdt.core.compiler.taskTags=FIXME,TODO 116 | org.eclipse.jdt.core.formatter.align_type_members_on_columns=false 117 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 118 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 119 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 120 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 121 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 122 | org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 123 | org.eclipse.jdt.core.formatter.alignment_for_assignment=0 124 | org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 125 | org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 126 | org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 127 | org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 128 | org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 129 | org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 130 | org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 131 | org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 132 | org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 133 | org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 134 | org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 135 | org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 136 | org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 137 | org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 138 | org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 139 | org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 140 | org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 141 | org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 142 | org.eclipse.jdt.core.formatter.blank_lines_after_package=1 143 | org.eclipse.jdt.core.formatter.blank_lines_before_field=0 144 | org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 145 | org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 146 | org.eclipse.jdt.core.formatter.blank_lines_before_member_type=0 147 | org.eclipse.jdt.core.formatter.blank_lines_before_method=1 148 | org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 149 | org.eclipse.jdt.core.formatter.blank_lines_before_package=0 150 | org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 151 | org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 152 | org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line 153 | org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line 154 | org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line 155 | org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line 156 | org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line 157 | org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line 158 | org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line 159 | org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line 160 | org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line 161 | org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line 162 | org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line 163 | org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true 164 | org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true 165 | org.eclipse.jdt.core.formatter.comment.format_block_comments=true 166 | org.eclipse.jdt.core.formatter.comment.format_header=false 167 | org.eclipse.jdt.core.formatter.comment.format_html=true 168 | org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true 169 | org.eclipse.jdt.core.formatter.comment.format_line_comments=true 170 | org.eclipse.jdt.core.formatter.comment.format_source_code=true 171 | org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true 172 | org.eclipse.jdt.core.formatter.comment.indent_root_tags=true 173 | org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert 174 | org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert 175 | org.eclipse.jdt.core.formatter.comment.line_length=120 176 | org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true 177 | org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true 178 | org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false 179 | org.eclipse.jdt.core.formatter.compact_else_if=true 180 | org.eclipse.jdt.core.formatter.continuation_indentation=2 181 | org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 182 | org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off 183 | org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on 184 | org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false 185 | org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true 186 | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true 187 | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true 188 | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true 189 | org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true 190 | org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true 191 | org.eclipse.jdt.core.formatter.indent_empty_lines=true 192 | org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true 193 | org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true 194 | org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true 195 | org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true 196 | org.eclipse.jdt.core.formatter.indentation.size=4 197 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert 198 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert 199 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert 200 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert 201 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert 202 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert 203 | org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert 204 | org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert 205 | org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert 206 | org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert 207 | org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert 208 | org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert 209 | org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert 210 | org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert 211 | org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert 212 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert 213 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert 214 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=do not insert 215 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert 216 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert 217 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert 218 | org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert 219 | org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert 220 | org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert 221 | org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert 222 | org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert 223 | org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert 224 | org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert 225 | org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert 226 | org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert 227 | org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=do not insert 228 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert 229 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert 230 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert 231 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert 232 | org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert 233 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert 234 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert 235 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=do not insert 236 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert 237 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert 238 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert 239 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert 240 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert 241 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert 242 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert 243 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert 244 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert 245 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert 246 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert 247 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert 248 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert 249 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert 250 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert 251 | org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert 252 | org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert 253 | org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert 254 | org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert 255 | org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert 256 | org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert 257 | org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert 258 | org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert 259 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert 260 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert 261 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert 262 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert 263 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert 264 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert 265 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert 266 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert 267 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert 268 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert 269 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert 270 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert 271 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert 272 | org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert 273 | org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert 274 | org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert 275 | org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert 276 | org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert 277 | org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert 278 | org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert 279 | org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert 280 | org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=do not insert 281 | org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert 282 | org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert 283 | org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert 284 | org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert 285 | org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert 286 | org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert 287 | org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert 288 | org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert 289 | org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert 290 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert 291 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert 292 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert 293 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert 294 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert 295 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert 296 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert 297 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert 298 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert 299 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert 300 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert 301 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert 302 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert 303 | org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert 304 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert 305 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert 306 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert 307 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert 308 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert 309 | org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert 310 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert 311 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert 312 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert 313 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert 314 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert 315 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert 316 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert 317 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert 318 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert 319 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert 320 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert 321 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert 322 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert 323 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert 324 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert 325 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert 326 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert 327 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert 328 | org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert 329 | org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert 330 | org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert 331 | org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert 332 | org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert 333 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert 334 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert 335 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=do not insert 336 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert 337 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert 338 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert 339 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert 340 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert 341 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert 342 | org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert 343 | org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert 344 | org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert 345 | org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert 346 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert 347 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert 348 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert 349 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert 350 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert 351 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert 352 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert 353 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert 354 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert 355 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert 356 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert 357 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert 358 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert 359 | org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert 360 | org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert 361 | org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert 362 | org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert 363 | org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert 364 | org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert 365 | org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert 366 | org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert 367 | org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert 368 | org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert 369 | org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert 370 | org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert 371 | org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert 372 | org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert 373 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert 374 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert 375 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert 376 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert 377 | org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert 378 | org.eclipse.jdt.core.formatter.join_lines_in_comments=true 379 | org.eclipse.jdt.core.formatter.join_wrapped_lines=true 380 | org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false 381 | org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false 382 | org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false 383 | org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false 384 | org.eclipse.jdt.core.formatter.lineSplit=120 385 | org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false 386 | org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false 387 | org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 388 | org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 389 | org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true 390 | org.eclipse.jdt.core.formatter.tabulation.char=space 391 | org.eclipse.jdt.core.formatter.tabulation.size=4 392 | org.eclipse.jdt.core.formatter.use_on_off_tags=false 393 | org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false 394 | org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true 395 | org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true 396 | org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true 397 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.ui.prefs: -------------------------------------------------------------------------------- 1 | cleanup.add_default_serial_version_id=true 2 | cleanup.add_generated_serial_version_id=false 3 | cleanup.add_missing_annotations=true 4 | cleanup.add_missing_deprecated_annotations=true 5 | cleanup.add_missing_methods=false 6 | cleanup.add_missing_nls_tags=false 7 | cleanup.add_missing_override_annotations=true 8 | cleanup.add_missing_override_annotations_interface_methods=true 9 | cleanup.add_serial_version_id=false 10 | cleanup.always_use_blocks=true 11 | cleanup.always_use_parentheses_in_expressions=false 12 | cleanup.always_use_this_for_non_static_field_access=false 13 | cleanup.always_use_this_for_non_static_method_access=false 14 | cleanup.convert_to_enhanced_for_loop=false 15 | cleanup.correct_indentation=false 16 | cleanup.format_comment=true 17 | cleanup.format_javadoc=true 18 | cleanup.format_multi_line_comment=true 19 | cleanup.format_single_line_comment=false 20 | cleanup.format_source_code=false 21 | cleanup.format_source_code_changes_only=false 22 | cleanup.make_local_variable_final=false 23 | cleanup.make_parameters_final=true 24 | cleanup.make_private_fields_final=true 25 | cleanup.make_type_abstract_if_missing_method=false 26 | cleanup.make_variable_declarations_final=true 27 | cleanup.never_use_blocks=false 28 | cleanup.never_use_parentheses_in_expressions=true 29 | cleanup.organize_imports=true 30 | cleanup.qualify_static_field_accesses_with_declaring_class=false 31 | cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true 32 | cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true 33 | cleanup.qualify_static_member_accesses_with_declaring_class=true 34 | cleanup.qualify_static_method_accesses_with_declaring_class=false 35 | cleanup.remove_private_constructors=true 36 | cleanup.remove_trailing_whitespaces=true 37 | cleanup.remove_trailing_whitespaces_all=true 38 | cleanup.remove_trailing_whitespaces_ignore_empty=false 39 | cleanup.remove_unnecessary_casts=true 40 | cleanup.remove_unnecessary_nls_tags=true 41 | cleanup.remove_unused_imports=true 42 | cleanup.remove_unused_local_variables=false 43 | cleanup.remove_unused_private_fields=true 44 | cleanup.remove_unused_private_members=false 45 | cleanup.remove_unused_private_methods=true 46 | cleanup.remove_unused_private_types=true 47 | cleanup.sort_members=false 48 | cleanup.sort_members_all=false 49 | cleanup.use_blocks=true 50 | cleanup.use_blocks_only_for_return_and_throw=false 51 | cleanup.use_parentheses_in_expressions=false 52 | cleanup.use_this_for_non_static_field_access=true 53 | cleanup.use_this_for_non_static_field_access_only_if_necessary=true 54 | cleanup.use_this_for_non_static_method_access=true 55 | cleanup.use_this_for_non_static_method_access_only_if_necessary=true 56 | cleanup_profile=_Ulli 57 | cleanup_settings_version=2 58 | eclipse.preferences.version=1 59 | editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true 60 | formatter_profile=_Ulli 61 | formatter_settings_version=12 62 | org.eclipse.jdt.ui.exception.name=exception 63 | org.eclipse.jdt.ui.gettersetter.use.is=true 64 | org.eclipse.jdt.ui.ignorelowercasenames=true 65 | org.eclipse.jdt.ui.importorder=java;javax;org;com;hudson.model;hudson.plugins; 66 | org.eclipse.jdt.ui.javadoc=true 67 | org.eclipse.jdt.ui.keywordthis=false 68 | org.eclipse.jdt.ui.ondemandthreshold=99 69 | org.eclipse.jdt.ui.overrideannotation=true 70 | org.eclipse.jdt.ui.staticondemandthreshold=0 71 | org.eclipse.jdt.ui.text.custom_code_templates= 72 | sp_cleanup.add_default_serial_version_id=true 73 | sp_cleanup.add_generated_serial_version_id=false 74 | sp_cleanup.add_missing_annotations=true 75 | sp_cleanup.add_missing_deprecated_annotations=true 76 | sp_cleanup.add_missing_methods=false 77 | sp_cleanup.add_missing_nls_tags=false 78 | sp_cleanup.add_missing_override_annotations=true 79 | sp_cleanup.add_missing_override_annotations_interface_methods=false 80 | sp_cleanup.add_serial_version_id=false 81 | sp_cleanup.always_use_blocks=true 82 | sp_cleanup.always_use_parentheses_in_expressions=false 83 | sp_cleanup.always_use_this_for_non_static_field_access=false 84 | sp_cleanup.always_use_this_for_non_static_method_access=false 85 | sp_cleanup.convert_to_enhanced_for_loop=false 86 | sp_cleanup.correct_indentation=false 87 | sp_cleanup.format_source_code=false 88 | sp_cleanup.format_source_code_changes_only=false 89 | sp_cleanup.make_local_variable_final=false 90 | sp_cleanup.make_parameters_final=true 91 | sp_cleanup.make_private_fields_final=true 92 | sp_cleanup.make_type_abstract_if_missing_method=false 93 | sp_cleanup.make_variable_declarations_final=true 94 | sp_cleanup.never_use_blocks=false 95 | sp_cleanup.never_use_parentheses_in_expressions=true 96 | sp_cleanup.on_save_use_additional_actions=true 97 | sp_cleanup.organize_imports=true 98 | sp_cleanup.qualify_static_field_accesses_with_declaring_class=false 99 | sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true 100 | sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true 101 | sp_cleanup.qualify_static_member_accesses_with_declaring_class=false 102 | sp_cleanup.qualify_static_method_accesses_with_declaring_class=false 103 | sp_cleanup.remove_private_constructors=true 104 | sp_cleanup.remove_trailing_whitespaces=true 105 | sp_cleanup.remove_trailing_whitespaces_all=true 106 | sp_cleanup.remove_trailing_whitespaces_ignore_empty=false 107 | sp_cleanup.remove_unnecessary_casts=true 108 | sp_cleanup.remove_unnecessary_nls_tags=false 109 | sp_cleanup.remove_unused_imports=true 110 | sp_cleanup.remove_unused_local_variables=false 111 | sp_cleanup.remove_unused_private_fields=true 112 | sp_cleanup.remove_unused_private_members=false 113 | sp_cleanup.remove_unused_private_methods=true 114 | sp_cleanup.remove_unused_private_types=true 115 | sp_cleanup.sort_members=false 116 | sp_cleanup.sort_members_all=false 117 | sp_cleanup.use_blocks=true 118 | sp_cleanup.use_blocks_only_for_return_and_throw=false 119 | sp_cleanup.use_parentheses_in_expressions=false 120 | sp_cleanup.use_this_for_non_static_field_access=true 121 | sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true 122 | sp_cleanup.use_this_for_non_static_method_access=true 123 | sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true 124 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | #Wed Jun 22 15:14:09 CEST 2011 2 | activeProfiles= 3 | eclipse.preferences.version=1 4 | resolveWorkspaceProjects=true 5 | version=1 6 | -------------------------------------------------------------------------------- /.settings/org.moreunit.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.moreunit.preferences.version=2 3 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | buildPlugin() -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2011 Dr. Ullrich Hafner 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /PMD-Icons-license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2003, InfoEther, LLC 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * The end-user documentation included with the redistribution, if 14 | any, must include the following acknowledgement: 15 | "This product includes software developed in part by support from 16 | the Defense Advanced Research Project Agency (DARPA)" 17 | * Neither the name of InfoEther, LLC nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 23 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 24 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 25 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## This plugin reached end-of-life. 2 | 3 | All functionality has been integrated into the 4 | [Warnings Next Generation Plugin](https://github.com/jenkinsci/warnings-ng-plugin) 5 | and the [Static Analysis Model and Parsers Library](https://github.com/jenkinsci/analysis-model). -------------------------------------------------------------------------------- /debug.sh: -------------------------------------------------------------------------------- 1 | export MAVEN_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n" 2 | rm -rf $JENKINS_HOME/plugins/pmd* 3 | mvn clean hpi:run 4 | -------------------------------------------------------------------------------- /german.sh: -------------------------------------------------------------------------------- 1 | mvn stapler:i18n -Dlocale=de 2 | 3 | -------------------------------------------------------------------------------- /go.sh: -------------------------------------------------------------------------------- 1 | rm -rf $JENKINS_HOME/plugins/pmd* 2 | 3 | mvn install || { echo "Build failed"; exit 1; } 4 | 5 | cp -f target/*.hpi $JENKINS_HOME/plugins/ 6 | 7 | cd $JENKINS_HOME 8 | ./go.sh 9 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | 5 | org.jvnet.hudson.plugins 6 | analysis-pom 7 | 1.68 8 | ../analysis-pom 9 | 10 | 11 | pmd 12 | hpi 13 | PMD Plug-in 14 | 4.0.1-SNAPSHOT 15 | http://wiki.jenkins-ci.org/x/GAAHAQ 16 | This plug-in generates the trend report for PMD, an 17 | open source static code analysis program. 18 | 19 | 20 | 21 | 22 | MIT license 23 | All source code is under the MIT license. 24 | 25 | 26 | BSD license 27 | The PMD images are Copyright (c) 2002-2005, 28 | InfoEther, Inc. All rights reserved. 29 | 30 | 31 | 32 | BSD license 33 | All YUI source code is under the BSD license. 34 | 35 | 36 | 37 | 38 | 39 | org.jvnet.hudson.plugins 40 | analysis-core 41 | 1.94 42 | 43 | 44 | org.jvnet.hudson.plugins 45 | analysis-test 46 | 1.20 47 | test 48 | 49 | 50 | net.sourceforge.pmd 51 | pmd-core 52 | 5.7.0 53 | 54 | 55 | com.ibm.icu 56 | icu4j 57 | 58 | 59 | net.sourceforge.saxon 60 | saxon 61 | 62 | 63 | 64 | 65 | net.sourceforge.pmd 66 | pmd-java 67 | 5.7.0 68 | 69 | 70 | net.sourceforge.saxon 71 | saxon 72 | 73 | 74 | 75 | 76 | 77 | 78 | scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git 79 | scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git 80 | https://github.com/jenkinsci/${project.artifactId}-plugin 81 | HEAD 82 | 83 | 84 | 85 | 86 | repo.jenkins-ci.org 87 | https://repo.jenkins-ci.org/public/ 88 | 89 | 90 | 91 | 92 | 93 | repo.jenkins-ci.org 94 | https://repo.jenkins-ci.org/public/ 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | git pull 4 | git push 5 | mvn -B -Djava.net.id=drulli release:prepare release:perform 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/MavenPmdResultAction.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 7 | 8 | import hudson.maven.AggregatableAction; 9 | import hudson.maven.MavenAggregatedReport; 10 | import hudson.maven.MavenBuild; 11 | import hudson.maven.MavenModule; 12 | import hudson.maven.MavenModuleSet; 13 | import hudson.maven.MavenModuleSetBuild; 14 | import hudson.model.AbstractBuild; 15 | import hudson.model.Action; 16 | import hudson.plugins.analysis.core.HealthDescriptor; 17 | import hudson.plugins.analysis.core.ParserResult; 18 | 19 | /** 20 | * A {@link PmdResultAction} for native maven jobs. This action 21 | * additionally provides result aggregation for sub-modules and for the main 22 | * project. 23 | * 24 | * @author Ulli Hafner 25 | * @deprecated not used anymore 26 | */ 27 | @SuppressWarnings("deprecation") 28 | @Deprecated 29 | public class MavenPmdResultAction extends PmdResultAction implements AggregatableAction, MavenAggregatedReport { 30 | /** The default encoding to be used when reading and parsing files. */ 31 | private final String defaultEncoding; 32 | 33 | /** 34 | * Creates a new instance of {@link MavenPmdResultAction}. 35 | * 36 | * @param owner 37 | * the associated build of this action 38 | * @param healthDescriptor 39 | * health descriptor to use 40 | * @param defaultEncoding 41 | * the default encoding to be used when reading and parsing files 42 | * @param result 43 | * the result in this build 44 | */ 45 | public MavenPmdResultAction(final AbstractBuild owner, final HealthDescriptor healthDescriptor, 46 | final String defaultEncoding, final PmdResult result) { 47 | super(owner, healthDescriptor, result); 48 | 49 | this.defaultEncoding = defaultEncoding; 50 | } 51 | 52 | @Override 53 | public MavenAggregatedReport createAggregatedAction(final MavenModuleSetBuild build, final Map> moduleBuilds) { 54 | return new MavenPmdResultAction(build, getHealthDescriptor(), defaultEncoding, 55 | new PmdResult(build, defaultEncoding, new ParserResult(), false, false)); 56 | } 57 | 58 | @Override 59 | public Action getProjectAction(final MavenModuleSet moduleSet) { 60 | return new PmdProjectAction(moduleSet); 61 | } 62 | 63 | @Override 64 | public Class getIndividualActionType() { 65 | return getClass(); 66 | } 67 | 68 | /** 69 | * Called whenever a new module build is completed, to update the aggregated 70 | * report. When multiple builds complete simultaneously, Jenkins serializes 71 | * the execution of this method, so this method needs not be 72 | * concurrency-safe. 73 | * 74 | * @param moduleBuilds 75 | * Same as MavenModuleSet.getModuleBuilds() but provided 76 | * for convenience and efficiency. 77 | * @param newBuild 78 | * Newly completed build. 79 | */ 80 | @Override 81 | public void update(final Map> moduleBuilds, final MavenBuild newBuild) { 82 | // not used anymore 83 | } 84 | 85 | /** Backward compatibility. @deprecated */ 86 | @SuppressFBWarnings("UUF") 87 | @SuppressWarnings("PMD") 88 | @Deprecated 89 | private transient String height; 90 | } 91 | 92 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/PmdAnnotationsAggregator.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd; 2 | 3 | import hudson.Launcher; 4 | import hudson.matrix.MatrixRun; 5 | import hudson.matrix.MatrixBuild; 6 | import hudson.model.Action; 7 | import hudson.model.BuildListener; 8 | import hudson.plugins.analysis.core.AnnotationsAggregator; 9 | import hudson.plugins.analysis.core.HealthDescriptor; 10 | import hudson.plugins.analysis.core.ParserResult; 11 | 12 | /** 13 | * Aggregates {@link PmdResultAction}s of {@link MatrixRun}s into 14 | * {@link MatrixBuild}. 15 | * 16 | * @author Ulli Hafner 17 | */ 18 | public class PmdAnnotationsAggregator extends AnnotationsAggregator { 19 | /** 20 | * Creates a new instance of {@link PmdAnnotationsAggregator}. 21 | * 22 | * @param build 23 | * the matrix build 24 | * @param launcher 25 | * the launcher 26 | * @param listener 27 | * the build listener 28 | * @param healthDescriptor 29 | * health descriptor 30 | * @param defaultEncoding 31 | * the default encoding to be used when reading and parsing files 32 | * @param usePreviousBuildAsReference 33 | * determines whether the previous build should be used as the 34 | * reference build 35 | * @param useStableBuildAsReference 36 | * determines whether only stable builds should be used as 37 | * reference builds or not 38 | */ 39 | public PmdAnnotationsAggregator(final MatrixBuild build, final Launcher launcher, 40 | final BuildListener listener, final HealthDescriptor healthDescriptor, final String defaultEncoding, 41 | final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference) { 42 | super(build, launcher, listener, healthDescriptor, defaultEncoding, 43 | usePreviousBuildAsReference, useStableBuildAsReference); 44 | } 45 | 46 | @Override 47 | protected Action createAction(final HealthDescriptor healthDescriptor, final String defaultEncoding, 48 | final ParserResult aggregatedResult) { 49 | return new PmdResultAction(build, healthDescriptor, 50 | new PmdResult(build, defaultEncoding, aggregatedResult, 51 | usePreviousBuildAsReference(), useOnlyStableBuildsAsReference())); 52 | } 53 | 54 | @Override 55 | protected boolean hasResult(final MatrixRun run) { 56 | return getAction(run) != null; 57 | } 58 | 59 | @Override 60 | protected PmdResult getResult(final MatrixRun run) { 61 | return getAction(run).getResult(); 62 | } 63 | 64 | private PmdResultAction getAction(final MatrixRun run) { 65 | return run.getAction(PmdResultAction.class); 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/PmdColumn.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd; 2 | 3 | import org.kohsuke.stapler.DataBoundConstructor; 4 | 5 | import hudson.Extension; 6 | 7 | import hudson.plugins.analysis.views.WarningsCountColumn; 8 | 9 | import hudson.views.ListViewColumnDescriptor; 10 | 11 | /** 12 | * A column that shows the total number of Checkstyle warnings in a job. 13 | * 14 | * @author Ulli Hafner 15 | */ 16 | public class PmdColumn extends WarningsCountColumn { 17 | /** 18 | * Creates a new instance of {@link PmdColumn}. 19 | */ 20 | @DataBoundConstructor 21 | public PmdColumn() { // NOPMD: data binding 22 | super(); 23 | } 24 | 25 | @Override 26 | protected Class getProjectAction() { 27 | return PmdProjectAction.class; 28 | } 29 | 30 | @Override 31 | public String getColumnCaption() { 32 | return Messages.PMD_Warnings_ColumnHeader(); 33 | } 34 | 35 | /** 36 | * Descriptor for the column. 37 | */ 38 | @Extension 39 | public static class ColumnDescriptor extends ListViewColumnDescriptor { 40 | @Override 41 | public boolean shownByDefault() { 42 | return false; 43 | } 44 | 45 | @Override 46 | public String getDisplayName() { 47 | return Messages.PMD_Warnings_Column(); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/PmdDescriptor.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd; 2 | 3 | import org.jenkinsci.Symbol; 4 | 5 | import hudson.Extension; 6 | import hudson.plugins.analysis.core.PluginDescriptor; 7 | 8 | /** 9 | * Descriptor for the class {@link PmdPublisher}. Used as a singleton. The 10 | * class is marked as public so that it can be accessed from views. 11 | * 12 | * @author Ulli Hafner 13 | */ 14 | @Extension(ordinal = 100) @Symbol("pmd") 15 | public final class PmdDescriptor extends PluginDescriptor { 16 | private static final String ICONS_PREFIX = "/plugin/pmd/icons/"; 17 | /** The ID of this plug-in is used as URL. */ 18 | static final String PLUGIN_ID = "pmd"; 19 | /** The URL of the result action. */ 20 | static final String RESULT_URL = PluginDescriptor.createResultUrlName(PLUGIN_ID); 21 | /** Icon to use for the result and project action. */ 22 | static final String ICON_URL = ICONS_PREFIX + "pmd-24x24.png"; 23 | 24 | /** 25 | * Creates a new instance of {@link PmdDescriptor}. 26 | */ 27 | public PmdDescriptor() { 28 | super(PmdPublisher.class); 29 | } 30 | 31 | @Override 32 | public String getDisplayName() { 33 | return Messages.PMD_Publisher_Name(); 34 | } 35 | 36 | @Override 37 | public String getPluginName() { 38 | return PLUGIN_ID; 39 | } 40 | 41 | @Override 42 | public String getIconUrl() { 43 | return ICON_URL; 44 | } 45 | 46 | @Override 47 | public String getSummaryIconUrl() { 48 | return ICONS_PREFIX + "pmd-48x48.png"; 49 | } 50 | } -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/PmdHealthDescriptor.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd; 2 | 3 | import hudson.plugins.analysis.core.AbstractHealthDescriptor; 4 | import hudson.plugins.analysis.core.HealthDescriptor; 5 | import hudson.plugins.analysis.util.model.AnnotationProvider; 6 | 7 | import org.jvnet.localizer.Localizable; 8 | 9 | /** 10 | * A health descriptor for PMD build results. 11 | * 12 | * @author Ulli Hafner 13 | */ 14 | public class PmdHealthDescriptor extends AbstractHealthDescriptor { 15 | /** Unique ID of this class. */ 16 | private static final long serialVersionUID = -3404826986876607396L; 17 | 18 | /** 19 | * Creates a new instance of {@link PmdHealthDescriptor} based on the 20 | * values of the specified descriptor. 21 | * 22 | * @param healthDescriptor the descriptor to copy the values from 23 | */ 24 | public PmdHealthDescriptor(final HealthDescriptor healthDescriptor) { 25 | super(healthDescriptor); 26 | } 27 | 28 | @Override 29 | protected Localizable createDescription(final AnnotationProvider result) { 30 | if (result.getNumberOfAnnotations() == 0) { 31 | return Messages._PMD_ResultAction_HealthReportNoItem(); 32 | } 33 | else if (result.getNumberOfAnnotations() == 1) { 34 | return Messages._PMD_ResultAction_HealthReportSingleItem(); 35 | } 36 | else { 37 | return Messages._PMD_ResultAction_HealthReportMultipleItem(result.getNumberOfAnnotations()); 38 | } 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/PmdMavenResult.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd; 2 | 3 | import hudson.model.AbstractBuild; 4 | import hudson.plugins.analysis.core.ParserResult; 5 | import hudson.plugins.analysis.core.ResultAction; 6 | import hudson.plugins.analysis.core.BuildResult; 7 | 8 | /** 9 | * Represents the aggregated results of the PMD analysis in m2 jobs. 10 | * 11 | * @author Ulli Hafner 12 | * @deprecated not used anymore 13 | */ 14 | @Deprecated 15 | public class PmdMavenResult extends PmdResult { 16 | /** Unique ID of this class. */ 17 | private static final long serialVersionUID = -4913938782537266259L; 18 | 19 | /** 20 | * Creates a new instance of {@link PmdMavenResult}. 21 | * 22 | * @param build 23 | * the current build as owner of this action 24 | * @param defaultEncoding 25 | * the default encoding to be used when reading and parsing files 26 | * @param result 27 | * the parsed result with all annotations 28 | */ 29 | @SuppressWarnings("deprecation") 30 | public PmdMavenResult(final AbstractBuild build, final String defaultEncoding, 31 | final ParserResult result) { 32 | super(build, defaultEncoding, result, false, false, MavenPmdResultAction.class); 33 | } 34 | 35 | /** 36 | * Returns the actual type of the associated result action. 37 | * 38 | * @return the actual type of the associated result action 39 | */ 40 | @SuppressWarnings("deprecation") 41 | @Override 42 | protected Class> getResultActionType() { 43 | return MavenPmdResultAction.class; 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/PmdMavenResultAction.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import hudson.maven.MavenAggregatedReport; 7 | import hudson.maven.MavenBuild; 8 | import hudson.maven.MavenModule; 9 | import hudson.maven.MavenModuleSet; 10 | import hudson.maven.MavenModuleSetBuild; 11 | import hudson.model.AbstractBuild; 12 | import hudson.model.Action; 13 | import hudson.plugins.analysis.core.HealthDescriptor; 14 | import hudson.plugins.analysis.core.MavenResultAction; 15 | import hudson.plugins.analysis.core.ParserResult; 16 | 17 | /** 18 | * A {@link PmdResultAction} for native Maven jobs. This action 19 | * additionally provides result aggregation for sub-modules and for the main 20 | * project. 21 | * 22 | * @author Ulli Hafner 23 | */ 24 | public class PmdMavenResultAction extends MavenResultAction { 25 | /** 26 | * Creates a new instance of {@link PmdMavenResultAction}. 27 | * 28 | * @param owner 29 | * the associated build of this action 30 | * @param healthDescriptor 31 | * health descriptor to use 32 | * @param defaultEncoding 33 | * the default encoding to be used when reading and parsing files 34 | * @param result 35 | * the result in this build 36 | */ 37 | public PmdMavenResultAction(final AbstractBuild owner, final HealthDescriptor healthDescriptor, 38 | final String defaultEncoding, final PmdResult result) { 39 | super(new PmdResultAction(owner, healthDescriptor, result), defaultEncoding, "PMD"); 40 | } 41 | 42 | @Override 43 | public MavenAggregatedReport createAggregatedAction(final MavenModuleSetBuild build, final Map> moduleBuilds) { 44 | return new PmdMavenResultAction(build, getHealthDescriptor(), getDefaultEncoding(), 45 | new PmdResult(build, getDefaultEncoding(), new ParserResult(), 46 | usePreviousBuildAsStable(), useOnlyStableBuildsAsReference())); 47 | } 48 | 49 | @Override 50 | public Action getProjectAction(final MavenModuleSet moduleSet) { 51 | return new PmdProjectAction(moduleSet, PmdMavenResultAction.class); 52 | } 53 | 54 | @Override 55 | public Class> getIndividualActionType() { 56 | return PmdMavenResultAction.class; 57 | } 58 | 59 | @Override 60 | protected PmdResult createResult(final PmdResult existingResult, final PmdResult additionalResult) { 61 | return new PmdReporterResult(getOwner(), additionalResult.getDefaultEncoding(), 62 | aggregate(existingResult, additionalResult), 63 | existingResult.usePreviousBuildAsStable(), 64 | existingResult.useOnlyStableBuildsAsReference()); 65 | } 66 | } 67 | 68 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/PmdPlugin.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd; 2 | 3 | import hudson.Plugin; 4 | import hudson.plugins.pmd.parser.PmdMessages; 5 | 6 | /** 7 | * Initializes the PMD messages and descriptions. 8 | * 9 | * @author Ulli Hafner 10 | */ 11 | public class PmdPlugin extends Plugin { 12 | @Override 13 | public void start() { 14 | PmdMessages.getInstance().initialize(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/PmdProjectAction.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd; 2 | 3 | import hudson.model.Job; 4 | import hudson.plugins.analysis.core.AbstractProjectAction; 5 | import hudson.plugins.analysis.core.ResultAction; 6 | 7 | /** 8 | * Entry point to visualize the PMD trend graph in the project screen. Drawing 9 | * of the graph is delegated to the associated {@link ResultAction}. 10 | * 11 | * @author Ulli Hafner 12 | */ 13 | public class PmdProjectAction extends AbstractProjectAction> { 14 | /** 15 | * Instantiates a new {@link PmdProjectAction}. 16 | * 17 | * @param job 18 | * the job that owns this action 19 | */ 20 | public PmdProjectAction(final Job job) { 21 | this(job, PmdResultAction.class); 22 | } 23 | 24 | /** 25 | * Instantiates a new {@link PmdProjectAction}. 26 | * 27 | * @param job 28 | * the job that owns this action 29 | * @param type 30 | * the result action type 31 | */ 32 | public PmdProjectAction(final Job job, 33 | final Class> type) { 34 | super(job, type, Messages._PMD_ProjectAction_Name(), Messages._PMD_Trend_Name(), 35 | PmdDescriptor.PLUGIN_ID, PmdDescriptor.ICON_URL, PmdDescriptor.RESULT_URL); 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/PmdPublisher.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd; 2 | 3 | import java.io.IOException; 4 | 5 | import org.apache.commons.lang.StringUtils; 6 | import org.kohsuke.stapler.DataBoundConstructor; 7 | import org.kohsuke.stapler.DataBoundSetter; 8 | import org.kohsuke.stapler.StaplerRequest; 9 | 10 | import net.sf.json.JSONObject; 11 | 12 | import hudson.FilePath; 13 | import hudson.Launcher; 14 | import hudson.matrix.MatrixAggregator; 15 | import hudson.matrix.MatrixBuild; 16 | import hudson.model.BuildListener; 17 | import hudson.model.Run; 18 | import hudson.model.TaskListener; 19 | import hudson.plugins.analysis.core.BuildResult; 20 | import hudson.plugins.analysis.core.FilesParser; 21 | import hudson.plugins.analysis.core.HealthAwarePublisher; 22 | import hudson.plugins.analysis.core.ParserResult; 23 | import hudson.plugins.analysis.util.PluginLogger; 24 | import hudson.plugins.pmd.parser.PmdParser; 25 | 26 | /** 27 | * Publishes the results of the PMD analysis (freestyle project type). 28 | * 29 | * @author Ulli Hafner 30 | */ 31 | public class PmdPublisher extends HealthAwarePublisher { 32 | private static final long serialVersionUID = 6711252664481150129L; 33 | 34 | private static final String PLUGIN_NAME = "PMD"; 35 | 36 | /** Default PMD pattern. */ 37 | private static final String DEFAULT_PATTERN = "**/pmd.xml"; 38 | /** Ant file-set pattern of files to work with. */ 39 | private String pattern; 40 | 41 | /** 42 | * Constructor used from methods like {@link StaplerRequest#bindJSON(Class, JSONObject)} (Class, JSONObject)} and 43 | * {@link StaplerRequest#bindParameters(Class, String)}. 44 | */ 45 | @DataBoundConstructor 46 | public PmdPublisher() { 47 | super(PLUGIN_NAME); 48 | } 49 | 50 | /** 51 | * Returns the Ant file-set pattern of files to work with. 52 | * 53 | * @return Ant file-set pattern of files to work with 54 | */ 55 | public String getPattern() { 56 | return pattern; 57 | } 58 | 59 | /** 60 | * Sets the Ant file-set pattern of files to work with. 61 | * 62 | * @param pattern the pattern of files 63 | */ 64 | @DataBoundSetter 65 | public void setPattern(final String pattern) { 66 | this.pattern = pattern; 67 | } 68 | 69 | @Override 70 | public BuildResult perform(final Run build, final FilePath workspace, final PluginLogger logger) throws 71 | InterruptedException, IOException { 72 | logger.log("Collecting PMD analysis files..."); 73 | FilesParser parser = new FilesParser(PLUGIN_NAME, 74 | StringUtils.defaultIfEmpty(expandFilePattern(getPattern(), build.getEnvironment(TaskListener.NULL)), DEFAULT_PATTERN), 75 | new PmdParser(getDefaultEncoding()), shouldDetectModules(), isMavenBuild(build)); 76 | ParserResult project = workspace.act(parser); 77 | logger.logLines(project.getLogMessages()); 78 | 79 | blame(project.getAnnotations(), build, workspace); 80 | 81 | PmdResult result = new PmdResult(build, getDefaultEncoding(), project, 82 | usePreviousBuildAsReference(), useOnlyStableBuildsAsReference()); 83 | build.addAction(new PmdResultAction(build, this, result)); 84 | 85 | return result; 86 | } 87 | 88 | @Override 89 | public PmdDescriptor getDescriptor() { 90 | return (PmdDescriptor)super.getDescriptor(); 91 | } 92 | 93 | @Override 94 | public MatrixAggregator createAggregator(final MatrixBuild build, final Launcher launcher, 95 | final BuildListener listener) { 96 | return new PmdAnnotationsAggregator(build, launcher, listener, this, 97 | getDefaultEncoding(), usePreviousBuildAsReference(), useOnlyStableBuildsAsReference()); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/PmdReporter.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd; 2 | 3 | import java.io.IOException; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import org.apache.maven.project.MavenProject; 8 | import org.kohsuke.stapler.DataBoundConstructor; 9 | 10 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 11 | 12 | import hudson.maven.MavenAggregatedReport; 13 | import hudson.maven.MavenBuild; 14 | import hudson.maven.MavenBuildProxy; 15 | import hudson.maven.MavenModule; 16 | import hudson.maven.MojoInfo; 17 | import hudson.plugins.analysis.core.FilesParser; 18 | import hudson.plugins.analysis.core.HealthAwareReporter; 19 | import hudson.plugins.analysis.core.ParserResult; 20 | import hudson.plugins.analysis.util.PluginLogger; 21 | import hudson.plugins.pmd.parser.PmdParser; 22 | 23 | /** 24 | * Publishes the results of the PMD analysis (maven 2 project type). 25 | * 26 | * @author Ulli Hafner 27 | */ 28 | public class PmdReporter extends HealthAwareReporter { 29 | private static final long serialVersionUID = 2272875032054063496L; 30 | private static final String PLUGIN_NAME = "PMD"; 31 | 32 | /** Default PMD pattern. */ 33 | private static final String PMD_XML_FILE = "pmd.xml"; 34 | 35 | /** 36 | * Creates a new instance of PmdReporter. 37 | * 38 | * @param healthy 39 | * Report health as 100% when the number of warnings is less than 40 | * this value 41 | * @param unHealthy 42 | * Report health as 0% when the number of warnings is greater 43 | * than this value 44 | * @param thresholdLimit 45 | * determines which warning priorities should be considered when 46 | * evaluating the build stability and health 47 | * @param useDeltaValues 48 | * determines whether the absolute annotations delta or the 49 | * actual annotations set difference should be used to evaluate 50 | * the build stability 51 | * @param unstableTotalAll 52 | * annotation threshold 53 | * @param unstableTotalHigh 54 | * annotation threshold 55 | * @param unstableTotalNormal 56 | * annotation threshold 57 | * @param unstableTotalLow 58 | * annotation threshold 59 | * @param unstableNewAll 60 | * annotation threshold 61 | * @param unstableNewHigh 62 | * annotation threshold 63 | * @param unstableNewNormal 64 | * annotation threshold 65 | * @param unstableNewLow 66 | * annotation threshold 67 | * @param failedTotalAll 68 | * annotation threshold 69 | * @param failedTotalHigh 70 | * annotation threshold 71 | * @param failedTotalNormal 72 | * annotation threshold 73 | * @param failedTotalLow 74 | * annotation threshold 75 | * @param failedNewAll 76 | * annotation threshold 77 | * @param failedNewHigh 78 | * annotation threshold 79 | * @param failedNewNormal 80 | * annotation threshold 81 | * @param failedNewLow 82 | * annotation threshold 83 | * @param canRunOnFailed 84 | * determines whether the plug-in can run for failed builds, too 85 | * @param usePreviousBuildAsReference 86 | * determines whether to always use the previous build as the reference build 87 | * @param useStableBuildAsReference 88 | * determines whether only stable builds should be used as reference builds or not 89 | * @param canComputeNew 90 | * determines whether new warnings should be computed (with 91 | * respect to baseline) 92 | */ 93 | // CHECKSTYLE:OFF 94 | @SuppressWarnings("PMD.ExcessiveParameterList") 95 | @DataBoundConstructor 96 | public PmdReporter(final String healthy, final String unHealthy, final String thresholdLimit, final boolean useDeltaValues, 97 | final String unstableTotalAll, final String unstableTotalHigh, final String unstableTotalNormal, final String unstableTotalLow, 98 | final String unstableNewAll, final String unstableNewHigh, final String unstableNewNormal, final String unstableNewLow, 99 | final String failedTotalAll, final String failedTotalHigh, final String failedTotalNormal, final String failedTotalLow, 100 | final String failedNewAll, final String failedNewHigh, final String failedNewNormal, final String failedNewLow, 101 | final boolean canRunOnFailed, final boolean usePreviousBuildAsReference, 102 | final boolean useStableBuildAsReference, final boolean canComputeNew) { 103 | super(healthy, unHealthy, thresholdLimit, useDeltaValues, 104 | unstableTotalAll, unstableTotalHigh, unstableTotalNormal, unstableTotalLow, 105 | unstableNewAll, unstableNewHigh, unstableNewNormal, unstableNewLow, 106 | failedTotalAll, failedTotalHigh, failedTotalNormal, failedTotalLow, 107 | failedNewAll, failedNewHigh, failedNewNormal, failedNewLow, 108 | canRunOnFailed, usePreviousBuildAsReference, useStableBuildAsReference, canComputeNew, PLUGIN_NAME); 109 | } 110 | // CHECKSTYLE:ON 111 | 112 | @Override 113 | protected boolean acceptGoal(final String goal) { 114 | return "pmd".equals(goal) || "site".equals(goal) || "report".equals(goal) || "check".equals(goal); 115 | } 116 | 117 | @Override 118 | public ParserResult perform(final MavenBuildProxy build, final MavenProject pom, final MojoInfo mojo, final PluginLogger logger) throws InterruptedException, IOException { 119 | FilesParser pmdCollector = new FilesParser(PLUGIN_NAME, PMD_XML_FILE, 120 | new PmdParser(getDefaultEncoding()), getModuleName(pom)); 121 | 122 | return getTargetPath(pom).act(pmdCollector); 123 | } 124 | 125 | @Override 126 | protected PmdResult createResult(final MavenBuild build, final ParserResult project) { 127 | return new PmdReporterResult(build, getDefaultEncoding(), project, 128 | usePreviousBuildAsReference(), useOnlyStableBuildsAsReference()); 129 | } 130 | 131 | @Override 132 | protected MavenAggregatedReport createMavenAggregatedReport(final MavenBuild build, final PmdResult result) { 133 | return new PmdMavenResultAction(build, this, getDefaultEncoding(), result); 134 | } 135 | 136 | @Override 137 | public List getProjectActions(final MavenModule module) { 138 | return Collections.singletonList(new PmdProjectAction(module, getResultActionClass())); 139 | } 140 | 141 | @Override 142 | protected Class getResultActionClass() { 143 | return PmdMavenResultAction.class; 144 | } 145 | 146 | /** Ant file-set pattern of files to work with. */ 147 | @SuppressWarnings("PMD") 148 | @SuppressFBWarnings("") 149 | private transient String pattern; // obsolete since release 2.5 150 | } 151 | 152 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/PmdReporterDescriptor.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd; 2 | 3 | import hudson.Extension; 4 | import hudson.plugins.analysis.core.ReporterDescriptor; 5 | 6 | /** 7 | * Descriptor for the class {@link PmdReporter}. Used as a singleton. The 8 | * class is marked as public so that it can be accessed from views. 9 | * 10 | * @author Ulli Hafner 11 | */ 12 | @Extension(ordinal = 100, optional = true) // NOCHECKSTYLE 13 | public class PmdReporterDescriptor extends ReporterDescriptor { 14 | /** 15 | * Creates a new instance of PmdReporterDescriptor. 16 | */ 17 | public PmdReporterDescriptor() { 18 | super(PmdReporter.class, new PmdDescriptor()); 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/PmdReporterResult.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd; 2 | 3 | import hudson.model.Run; 4 | import hudson.plugins.analysis.core.BuildResult; 5 | import hudson.plugins.analysis.core.ParserResult; 6 | import hudson.plugins.analysis.core.ResultAction; 7 | 8 | /** 9 | * Represents the aggregated results of the PMD analysis in maven jobs. 10 | * 11 | * @author Ulli Hafner 12 | */ 13 | public class PmdReporterResult extends PmdResult { 14 | private static final long serialVersionUID = 498726255763220019L; 15 | 16 | /** 17 | * Creates a new instance of {@link PmdReporterResult}. 18 | * 19 | * @param build 20 | * the current build as owner of this action 21 | * @param defaultEncoding 22 | * the default encoding to be used when reading and parsing files 23 | * @param result 24 | * the parsed result with all annotations 25 | * @param usePreviousBuildAsReference 26 | * determines whether to use the previous build as the reference 27 | * build 28 | * @param useStableBuildAsReference 29 | * determines whether only stable builds should be used as 30 | * reference builds or not 31 | */ 32 | public PmdReporterResult(final Run build, final String defaultEncoding, final ParserResult result, 33 | final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference) { 34 | super(build, defaultEncoding, result, usePreviousBuildAsReference, useStableBuildAsReference, 35 | PmdMavenResultAction.class); 36 | } 37 | 38 | @Override 39 | protected Class> getResultActionType() { 40 | return PmdMavenResultAction.class; 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/PmdResult.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd; 2 | 3 | import com.thoughtworks.xstream.XStream; 4 | 5 | import hudson.model.Run; 6 | import hudson.plugins.analysis.core.BuildHistory; 7 | import hudson.plugins.analysis.core.BuildResult; 8 | import hudson.plugins.analysis.core.ParserResult; 9 | import hudson.plugins.analysis.core.ResultAction; 10 | import hudson.plugins.pmd.parser.Bug; 11 | 12 | /** 13 | * Represents the results of the PMD analysis. One instance of this class is persisted for 14 | * each build via an XML file. 15 | * 16 | * @author Ulli Hafner 17 | */ 18 | public class PmdResult extends BuildResult { 19 | private static final long serialVersionUID = 2768250056765266658L; 20 | 21 | /** 22 | * Creates a new instance of {@link PmdResult}. 23 | * 24 | * @param build 25 | * the current build as owner of this action 26 | * @param defaultEncoding 27 | * the default encoding to be used when reading and parsing files 28 | * @param result 29 | * the parsed result with all annotations 30 | * @param usePreviousBuildAsReference 31 | * determines whether to use the previous build as the reference 32 | * build 33 | * @param useStableBuildAsReference 34 | * determines whether only stable builds should be used as 35 | * reference builds or not 36 | */ 37 | public PmdResult(final Run build, final String defaultEncoding, final ParserResult result, 38 | final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference) { 39 | this(build, defaultEncoding, result, usePreviousBuildAsReference, useStableBuildAsReference, PmdResultAction.class); 40 | } 41 | 42 | /** 43 | * Creates a new instance of {@link PmdResult}. 44 | * 45 | * @param build the current build as owner of this action 46 | * @param defaultEncoding the default encoding to be used when reading and parsing files 47 | * @param result the parsed result with all annotations 48 | * @param usePreviousBuildAsReference the value of usePreviousBuildAsReference 49 | * @param useStableBuildAsReference determines whether only stable builds should be used as reference builds or not 50 | * @param actionType the type of the result action 51 | */ 52 | protected PmdResult(final Run build, 53 | final String defaultEncoding, final ParserResult result, 54 | final boolean usePreviousBuildAsReference, 55 | final boolean useStableBuildAsReference, 56 | final Class> actionType) { 57 | this(build, new BuildHistory(build, actionType, usePreviousBuildAsReference, useStableBuildAsReference), result, defaultEncoding, true); 58 | } 59 | 60 | PmdResult(final Run build, final BuildHistory history, 61 | final ParserResult result, final String defaultEncoding, final boolean canSerialize) { 62 | super(build, history, result, defaultEncoding); 63 | 64 | if (canSerialize) { 65 | serializeAnnotations(result.getAnnotations()); 66 | } 67 | } 68 | 69 | @Override 70 | public String getHeader() { 71 | return Messages.PMD_ResultAction_Header(); 72 | } 73 | 74 | @Override 75 | protected void configure(final XStream xstream) { 76 | xstream.alias("bug", Bug.class); 77 | } 78 | 79 | @Override 80 | public String getSummary() { 81 | return "PMD: " + createDefaultSummary(PmdDescriptor.RESULT_URL, getNumberOfAnnotations(), getNumberOfModules()); 82 | } 83 | 84 | @Override 85 | protected String createDeltaMessage() { 86 | return createDefaultDeltaMessage(PmdDescriptor.RESULT_URL, getNumberOfNewWarnings(), getNumberOfFixedWarnings()); 87 | } 88 | 89 | @Override 90 | protected String getSerializationFileName() { 91 | return "pmd-warnings.xml"; 92 | } 93 | 94 | @Override 95 | public String getDisplayName() { 96 | return Messages.PMD_ProjectAction_Name(); 97 | } 98 | 99 | @Override 100 | protected Class> getResultActionType() { 101 | return PmdResultAction.class; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/PmdResultAction.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd; 2 | 3 | import java.util.Collection; 4 | 5 | import hudson.model.Action; 6 | import hudson.model.Run; 7 | import hudson.plugins.analysis.core.AbstractResultAction; 8 | import hudson.plugins.analysis.core.HealthDescriptor; 9 | import hudson.plugins.analysis.core.PluginDescriptor; 10 | 11 | /** 12 | * Controls the live cycle of the PMD results. This action persists the 13 | * results of the PMD analysis of a build and displays the results on the 14 | * build page. The actual visualization of the results is defined in the 15 | * matching summary.jelly file. 16 | *

17 | * Moreover, this class renders the PMD result trend. 18 | *

19 | * 20 | * @author Ulli Hafner 21 | */ 22 | public class PmdResultAction extends AbstractResultAction { 23 | /** 24 | * Creates a new instance of PmdResultAction. 25 | * 26 | * @param owner 27 | * the associated build of this action 28 | * @param healthDescriptor 29 | * health descriptor to use 30 | * @param result 31 | * the result in this build 32 | */ 33 | public PmdResultAction(final Run owner, final HealthDescriptor healthDescriptor, final PmdResult result) { 34 | super(owner, new PmdHealthDescriptor(healthDescriptor), result); 35 | } 36 | 37 | @Override 38 | public Collection getProjectActions() { 39 | return asSet(new PmdProjectAction(getJob())); 40 | } 41 | 42 | @Override 43 | public String getDisplayName() { 44 | return Messages.PMD_ProjectAction_Name(); 45 | } 46 | 47 | @Override 48 | protected PluginDescriptor getDescriptor() { 49 | return new PmdDescriptor(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/dashboard/WarningsNewVersusFixedGraphPortlet.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.dashboard; 2 | 3 | import hudson.Extension; 4 | import hudson.model.Descriptor; 5 | import hudson.plugins.analysis.core.AbstractProjectAction; 6 | import hudson.plugins.analysis.dashboard.AbstractWarningsGraphPortlet; 7 | import hudson.plugins.analysis.graph.BuildResultGraph; 8 | import hudson.plugins.analysis.graph.NewVersusFixedGraph; 9 | import hudson.plugins.pmd.Messages; 10 | import hudson.plugins.pmd.PmdProjectAction; 11 | import hudson.plugins.view.dashboard.DashboardPortlet; 12 | 13 | import org.kohsuke.stapler.DataBoundConstructor; 14 | 15 | /** 16 | * A portlet that shows the warnings trend graph of fixed versus new warnings. 17 | * 18 | * @author Ulli Hafner 19 | */ 20 | public final class WarningsNewVersusFixedGraphPortlet extends AbstractWarningsGraphPortlet { 21 | /** 22 | * Creates a new instance of {@link WarningsNewVersusFixedGraphPortlet}. 23 | * 24 | * @param name 25 | * the name of the portlet 26 | * @param width 27 | * width of the graph 28 | * @param height 29 | * height of the graph 30 | * @param dayCountString 31 | * number of days to consider 32 | */ 33 | @DataBoundConstructor 34 | public WarningsNewVersusFixedGraphPortlet(final String name, final String width, final String height, final String dayCountString) { 35 | super(name, width, height, dayCountString); 36 | 37 | configureGraph(getGraphType()); 38 | } 39 | 40 | @Override 41 | protected Class> getAction() { 42 | return PmdProjectAction.class; 43 | } 44 | 45 | @Override 46 | protected String getPluginName() { 47 | return "pmd"; 48 | } 49 | 50 | @Override 51 | protected BuildResultGraph getGraphType() { 52 | return new NewVersusFixedGraph(); 53 | } 54 | 55 | /** 56 | * Extension point registration. 57 | * 58 | * @author Ulli Hafner 59 | */ 60 | @Extension(optional = true) 61 | public static class WarningsGraphDescriptor extends Descriptor { 62 | @Override 63 | public String getDisplayName() { 64 | return Messages.Portlet_WarningsNewVsFixedGraph(); 65 | } 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/dashboard/WarningsPriorityGraphPortlet.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.dashboard; 2 | 3 | import hudson.Extension; 4 | import hudson.model.Descriptor; 5 | import hudson.plugins.analysis.core.AbstractProjectAction; 6 | import hudson.plugins.analysis.dashboard.AbstractWarningsGraphPortlet; 7 | import hudson.plugins.analysis.graph.BuildResultGraph; 8 | import hudson.plugins.analysis.graph.PriorityGraph; 9 | import hudson.plugins.pmd.Messages; 10 | import hudson.plugins.pmd.PmdProjectAction; 11 | import hudson.plugins.view.dashboard.DashboardPortlet; 12 | 13 | import org.kohsuke.stapler.DataBoundConstructor; 14 | 15 | /** 16 | * A portlet that shows the warnings trend graph by priority. 17 | * 18 | * @author Ulli Hafner 19 | */ 20 | public final class WarningsPriorityGraphPortlet extends AbstractWarningsGraphPortlet { 21 | /** 22 | * Creates a new instance of {@link WarningsPriorityGraphPortlet}. 23 | * 24 | * @param name 25 | * the name of the portlet 26 | * @param width 27 | * width of the graph 28 | * @param height 29 | * height of the graph 30 | * @param dayCountString 31 | * number of days to consider 32 | */ 33 | @DataBoundConstructor 34 | public WarningsPriorityGraphPortlet(final String name, final String width, final String height, final String dayCountString) { 35 | super(name, width, height, dayCountString); 36 | 37 | configureGraph(getGraphType()); 38 | } 39 | 40 | @Override 41 | protected Class> getAction() { 42 | return PmdProjectAction.class; 43 | } 44 | 45 | @Override 46 | protected String getPluginName() { 47 | return "pmd"; 48 | } 49 | 50 | @Override 51 | protected BuildResultGraph getGraphType() { 52 | return new PriorityGraph(); 53 | } 54 | 55 | /** 56 | * Extension point registration. 57 | * 58 | * @author Ulli Hafner 59 | */ 60 | @Extension(optional = true) 61 | public static class WarningsGraphDescriptor extends Descriptor { 62 | @Override 63 | public String getDisplayName() { 64 | return Messages.Portlet_WarningsPriorityGraph(); 65 | } 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/dashboard/WarningsTablePortlet.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.dashboard; 2 | 3 | import hudson.Extension; 4 | import hudson.model.Descriptor; 5 | import hudson.plugins.analysis.core.AbstractProjectAction; 6 | import hudson.plugins.analysis.dashboard.AbstractWarningsTablePortlet; 7 | import hudson.plugins.pmd.Messages; 8 | import hudson.plugins.pmd.PmdProjectAction; 9 | import hudson.plugins.view.dashboard.DashboardPortlet; 10 | 11 | import org.kohsuke.stapler.DataBoundConstructor; 12 | 13 | /** 14 | * A portlet that shows a table with the number of warnings in a job. 15 | * 16 | * @author Ulli Hafner 17 | */ 18 | public class WarningsTablePortlet extends AbstractWarningsTablePortlet { 19 | /** 20 | * Creates a new instance of {@link WarningsTablePortlet}. 21 | * 22 | * @param name 23 | * the name of the portlet 24 | * @param canHideZeroWarningsProjects 25 | * determines if zero warnings projects should be hidden in the 26 | * table 27 | */ 28 | @DataBoundConstructor 29 | public WarningsTablePortlet(final String name, final boolean canHideZeroWarningsProjects) { 30 | super(name, canHideZeroWarningsProjects); 31 | } 32 | 33 | @Override 34 | protected Class> getAction() { 35 | return PmdProjectAction.class; 36 | } 37 | 38 | /** 39 | * Extension point registration. 40 | * 41 | * @author Ulli Hafner 42 | */ 43 | @Extension(optional = true) 44 | public static class WarningsPerJobDescriptor extends Descriptor { 45 | @Override 46 | public String getDisplayName() { 47 | return Messages.Portlet_WarningsTable(); 48 | } 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/dashboard/WarningsTotalsGraphPortlet.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.dashboard; 2 | 3 | import hudson.Extension; 4 | import hudson.model.Descriptor; 5 | import hudson.plugins.analysis.core.AbstractProjectAction; 6 | import hudson.plugins.analysis.dashboard.AbstractWarningsGraphPortlet; 7 | import hudson.plugins.analysis.graph.BuildResultGraph; 8 | import hudson.plugins.analysis.graph.TotalsGraph; 9 | import hudson.plugins.pmd.Messages; 10 | import hudson.plugins.pmd.PmdProjectAction; 11 | import hudson.plugins.view.dashboard.DashboardPortlet; 12 | 13 | import org.kohsuke.stapler.DataBoundConstructor; 14 | 15 | /** 16 | * A portlet that shows the warnings trend graph by priority. 17 | * 18 | * @author Ulli Hafner 19 | */ 20 | public final class WarningsTotalsGraphPortlet extends AbstractWarningsGraphPortlet { 21 | /** 22 | * Creates a new instance of {@link WarningsTotalsGraphPortlet}. 23 | * 24 | * @param name 25 | * the name of the portlet 26 | * @param width 27 | * width of the graph 28 | * @param height 29 | * height of the graph 30 | * @param dayCountString 31 | * number of days to consider 32 | */ 33 | @DataBoundConstructor 34 | public WarningsTotalsGraphPortlet(final String name, final String width, final String height, final String dayCountString) { 35 | super(name, width, height, dayCountString); 36 | 37 | configureGraph(getGraphType()); 38 | } 39 | 40 | @Override 41 | protected Class> getAction() { 42 | return PmdProjectAction.class; 43 | } 44 | 45 | @Override 46 | protected String getPluginName() { 47 | return "pmd"; 48 | } 49 | 50 | @Override 51 | protected BuildResultGraph getGraphType() { 52 | return new TotalsGraph(); 53 | } 54 | 55 | /** 56 | * Extension point registration. 57 | * 58 | * @author Ulli Hafner 59 | */ 60 | @Extension(optional = true) 61 | public static class WarningsGraphDescriptor extends Descriptor { 62 | @Override 63 | public String getDisplayName() { 64 | return Messages.Portlet_WarningsTotalsGraph(); 65 | } 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/dashboard/WarningsUserGraphPortlet.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.dashboard; 2 | 3 | import org.kohsuke.stapler.DataBoundConstructor; 4 | 5 | import hudson.Extension; 6 | import hudson.model.Descriptor; 7 | import hudson.plugins.analysis.core.AbstractProjectAction; 8 | import hudson.plugins.analysis.dashboard.AbstractWarningsGraphPortlet; 9 | import hudson.plugins.analysis.graph.AnnotationsByUserGraph; 10 | import hudson.plugins.analysis.graph.BuildResultGraph; 11 | import hudson.plugins.pmd.Messages; 12 | import hudson.plugins.pmd.PmdProjectAction; 13 | import hudson.plugins.view.dashboard.DashboardPortlet; 14 | 15 | /** 16 | * A portlet that shows the warnings of the last build by user and priority. 17 | * 18 | * @author Ulli Hafner 19 | */ 20 | public final class WarningsUserGraphPortlet extends AbstractWarningsGraphPortlet { 21 | /** 22 | * Creates a new instance of {@link WarningsUserGraphPortlet}. 23 | * 24 | * @param name 25 | * the name of the portlet 26 | * @param width 27 | * width of the graph 28 | * @param height 29 | * height of the graph 30 | * @param dayCountString 31 | * number of days to consider 32 | */ 33 | @DataBoundConstructor 34 | public WarningsUserGraphPortlet(final String name, final String width, final String height, final String dayCountString) { 35 | super(name, width, height, dayCountString); 36 | 37 | configureGraph(getGraphType()); 38 | } 39 | 40 | @Override 41 | protected Class> getAction() { 42 | return PmdProjectAction.class; 43 | } 44 | 45 | @Override 46 | protected String getPluginName() { 47 | return "pmd"; 48 | } 49 | 50 | @Override 51 | protected BuildResultGraph getGraphType() { 52 | return new AnnotationsByUserGraph(); 53 | } 54 | 55 | /** 56 | * Extension point registration. 57 | * 58 | * @author Ulli Hafner 59 | */ 60 | @Extension(optional = true) 61 | public static class WarningsGraphDescriptor extends Descriptor { 62 | @Override 63 | public String getDisplayName() { 64 | return Messages.Portlet_WarningsUserGraph(); 65 | } 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/parser/Bug.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.parser; 2 | 3 | import org.apache.commons.lang.StringUtils; 4 | 5 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 6 | 7 | import hudson.plugins.analysis.util.model.AbstractAnnotation; 8 | import hudson.plugins.analysis.util.model.Priority; 9 | 10 | /** 11 | * A serializable Java Bean class representing a warning. 12 | *

13 | * Note: this class has a natural ordering that is inconsistent with equals. 14 | *

15 | * 16 | * @author Ulli Hafner 17 | */ 18 | public class Bug extends AbstractAnnotation { 19 | /** Unique identifier of this class. */ 20 | private static final long serialVersionUID = 5171661552905752370L; 21 | /** Origin of the annotation. */ 22 | public static final String ORIGIN = "pmd"; 23 | 24 | /** 25 | * Creates a new instance of Bug. 26 | * 27 | * @param priority 28 | * the priority 29 | * @param message 30 | * the message of the warning 31 | * @param category 32 | * the warning category 33 | * @param type 34 | * the identifier of the warning type 35 | * @param start 36 | * the first line of the line range 37 | * @param end 38 | * the last line of the line range 39 | */ 40 | public Bug(final Priority priority, final String message, final String category, final String type, 41 | final int start, final int end) { 42 | super(priority, message, start, end, category, type); 43 | 44 | setOrigin(ORIGIN); 45 | } 46 | 47 | /** 48 | * Creates a new instance of Bug. 49 | * 50 | * @param priority 51 | * the priority 52 | * @param message 53 | * the message of the warning 54 | * @param category 55 | * the warning category 56 | * @param type 57 | * the identifier of the warning type 58 | * @param lineNumber 59 | * the line number of the warning in the corresponding file 60 | */ 61 | public Bug(final Priority priority, final String message, final String category, final String type, final int lineNumber) { 62 | this(priority, message, category, type, lineNumber, lineNumber); 63 | } 64 | 65 | @Override 66 | public String getToolTip() { 67 | return PmdMessages.getInstance().getMessage(getCategory(), getType()); 68 | } 69 | 70 | /** The tooltip. */ 71 | @SuppressWarnings("PMD") 72 | @SuppressFBWarnings("SS") 73 | private final String tooltip = StringUtils.EMPTY; // backward compatibility 74 | } 75 | 76 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/parser/File.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.parser; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import java.util.Collections; 6 | import java.util.List; 7 | 8 | /** 9 | * Java Bean class for a file of the PMD format. 10 | * 11 | * @author Ulli Hafner 12 | */ 13 | public class File { 14 | /** Name of the file. */ 15 | private String name; 16 | /** All violations of this file. */ 17 | private final List violations = new ArrayList(); 18 | 19 | /** 20 | * Adds a new violation to this file. 21 | * 22 | * @param violation 23 | * the new violation 24 | */ 25 | public void addViolation(final Violation violation) { 26 | violations.add(violation); 27 | } 28 | 29 | /** 30 | * Returns all violations of this file. The returned collection is 31 | * read-only. 32 | * 33 | * @return all violations in this file 34 | */ 35 | public Collection getViolations() { 36 | return Collections.unmodifiableCollection(violations); 37 | } 38 | 39 | /** 40 | * Returns the name of this file. 41 | * 42 | * @return the name of this file 43 | */ 44 | public String getName() { 45 | return name; 46 | } 47 | 48 | /** 49 | * Sets the name of this file to the specified value. 50 | * 51 | * @param name the value to set 52 | */ 53 | public void setName(final String name) { 54 | this.name = name; 55 | } 56 | } 57 | 58 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/parser/Pmd.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.parser; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import java.util.Collections; 6 | import java.util.List; 7 | 8 | /** 9 | * Java Bean class for a violations collection of the PMD format. 10 | * 11 | * @author Ulli Hafner 12 | */ 13 | public class Pmd { 14 | /** All files of this violations collection. */ 15 | private final List files = new ArrayList(); 16 | 17 | /** 18 | * Adds a new file to this bug collection. 19 | * 20 | * @param file the file to add 21 | */ 22 | public void addFile(final File file) { 23 | files.add(file); 24 | } 25 | 26 | /** 27 | * Returns all files of this violations collection. The returned collection is 28 | * read-only. 29 | * 30 | * @return all files of this bug collection 31 | */ 32 | public Collection getFiles() { 33 | return Collections.unmodifiableCollection(files); 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/parser/PmdMessages.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.parser; 2 | 3 | import java.util.HashMap; 4 | import java.util.Iterator; 5 | import java.util.List; 6 | import java.util.Map; 7 | import java.util.logging.Level; 8 | import java.util.logging.Logger; 9 | 10 | import org.apache.commons.lang.StringUtils; 11 | 12 | import net.sourceforge.pmd.Rule; 13 | import net.sourceforge.pmd.RuleSet; 14 | import net.sourceforge.pmd.RuleSetFactory; 15 | import net.sourceforge.pmd.RuleSetNotFoundException; 16 | 17 | /** 18 | * Provides access to rule descriptions and examples. 19 | * 20 | * @author Ulli Hafner 21 | */ 22 | public final class PmdMessages { 23 | /** Singleton instance. */ 24 | private static final PmdMessages INSTANCE = new PmdMessages(); 25 | 26 | /** Available rule sets. */ 27 | private final Map rules = new HashMap(); 28 | 29 | /** 30 | * Returns the singleton instance. 31 | * 32 | * @return the singleton instance 33 | */ 34 | public static PmdMessages getInstance() { 35 | return INSTANCE; 36 | } 37 | 38 | /** 39 | * Creates a new instance of PmdMessages. 40 | */ 41 | private PmdMessages() { 42 | // prevents instantiation 43 | } 44 | 45 | /** 46 | * Initializes the rules. 47 | * 48 | * @return the number of rule sets 49 | */ 50 | public int initialize() { 51 | try { 52 | Iterator ruleSets = new RuleSetFactory().getRegisteredRuleSets(); 53 | for (Iterator iterator = ruleSets; iterator.hasNext();) { 54 | RuleSet ruleSet = iterator.next(); 55 | rules.put(ruleSet.getName(), ruleSet); 56 | } 57 | return rules.size(); 58 | } 59 | catch (RuleSetNotFoundException exception) { 60 | Logger.getLogger(PmdMessages.class.getName()).log(Level.SEVERE, "Installation problem: can't access PMD messages."); 61 | } 62 | return 0; 63 | } 64 | 65 | /** 66 | * Returns the message for the specified PMD rule. 67 | * 68 | * @param ruleSetName 69 | * PMD rule set 70 | * @param ruleName 71 | * PMD rule ID 72 | * @return the message 73 | */ 74 | public String getMessage(final String ruleSetName, final String ruleName) { 75 | if (rules.containsKey(ruleSetName)) { 76 | RuleSet ruleSet = rules.get(ruleSetName); 77 | Rule rule = ruleSet.getRuleByName(ruleName); 78 | if (rule != null) { 79 | return createMessage(rule); 80 | } 81 | } 82 | return StringUtils.EMPTY; 83 | } 84 | 85 | /** 86 | * Creates the message string to be shown for the specified rule. 87 | * 88 | * @param rule 89 | * the rule 90 | * @return the message string to be shown for the specified rule 91 | */ 92 | private String createMessage(final Rule rule) { 93 | List examples = rule.getExamples(); 94 | if (!examples.isEmpty()) { 95 | return rule.getDescription() + "
" + examples.get(0) + "
"; 96 | } 97 | return rule.getDescription(); 98 | } 99 | } 100 | 101 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/parser/PmdParser.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.parser; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.lang.reflect.InvocationTargetException; 6 | import java.util.ArrayList; 7 | import java.util.Collection; 8 | 9 | import org.apache.commons.lang.StringUtils; 10 | import org.xml.sax.SAXException; 11 | 12 | import hudson.plugins.analysis.core.AbstractAnnotationParser; 13 | import hudson.plugins.analysis.util.SecureDigester; 14 | import hudson.plugins.analysis.util.model.FileAnnotation; 15 | import hudson.plugins.analysis.util.model.Priority; 16 | 17 | /** 18 | * A parser for PMD XML files. 19 | * 20 | * @author Ulli Hafner 21 | */ 22 | public class PmdParser extends AbstractAnnotationParser { 23 | /** Unique ID of this class. */ 24 | private static final long serialVersionUID = 6507147028628714706L; 25 | 26 | /** PMD priorities smaller than this value are mapped to {@link Priority#HIGH}. */ 27 | private static final int PMD_PRIORITY_MAPPED_TO_HIGH_PRIORITY = 3; 28 | /** PMD priorities greater than this value are mapped to {@link Priority#LOW}. */ 29 | private static final int PMD_PRIORITY_MAPPED_TO_LOW_PRIORITY = 4; 30 | 31 | /** 32 | * Creates a new instance of {@link PmdParser}. 33 | */ 34 | public PmdParser() { 35 | super(StringUtils.EMPTY); 36 | } 37 | 38 | /** 39 | * Creates a new instance of {@link PmdParser}. 40 | * 41 | * @param defaultEncoding 42 | * the default encoding to be used when reading and parsing files 43 | */ 44 | public PmdParser(final String defaultEncoding) { 45 | super(defaultEncoding); 46 | } 47 | 48 | @Override 49 | public Collection parse(final InputStream file, final String moduleName) throws InvocationTargetException { 50 | try { 51 | SecureDigester digester = new SecureDigester(PmdParser.class); 52 | 53 | String rootXPath = "pmd"; 54 | digester.addObjectCreate(rootXPath, Pmd.class); 55 | digester.addSetProperties(rootXPath); 56 | 57 | String fileXPath = "pmd/file"; 58 | digester.addObjectCreate(fileXPath, hudson.plugins.pmd.parser.File.class); 59 | digester.addSetProperties(fileXPath); 60 | digester.addSetNext(fileXPath, "addFile", hudson.plugins.pmd.parser.File.class.getName()); 61 | 62 | String bugXPath = "pmd/file/violation"; 63 | digester.addObjectCreate(bugXPath, Violation.class); 64 | digester.addSetProperties(bugXPath); 65 | digester.addCallMethod(bugXPath, "setMessage", 0); 66 | digester.addSetNext(bugXPath, "addViolation", Violation.class.getName()); 67 | 68 | Pmd module = (Pmd)digester.parse(file); 69 | if (module == null) { 70 | throw new SAXException("Input stream is not a PMD file."); 71 | } 72 | 73 | return convert(module, moduleName); 74 | } 75 | catch (IOException exception) { 76 | throw new InvocationTargetException(exception); 77 | } 78 | catch (SAXException exception) { 79 | throw new InvocationTargetException(exception); 80 | } 81 | } 82 | 83 | /** 84 | * Converts the internal structure to the annotations API. 85 | * 86 | * @param collection 87 | * the internal maven module 88 | * @param moduleName 89 | * name of the maven module 90 | * @return a maven module of the annotations API 91 | */ 92 | private Collection convert(final Pmd collection, final String moduleName) { 93 | ArrayList annotations = new ArrayList(); 94 | 95 | for (hudson.plugins.pmd.parser.File file : collection.getFiles()) { 96 | for (Violation warning : file.getViolations()) { 97 | Priority priority; 98 | if (warning.getPriority() < PMD_PRIORITY_MAPPED_TO_HIGH_PRIORITY) { 99 | priority = Priority.HIGH; 100 | } 101 | else if (warning.getPriority() > PMD_PRIORITY_MAPPED_TO_LOW_PRIORITY) { 102 | priority = Priority.LOW; 103 | } 104 | else { 105 | priority = Priority.NORMAL; 106 | } 107 | Bug bug = new Bug(priority, createMessage(warning), warning.getRuleset(), warning.getRule(), 108 | warning.getBeginline(), warning.getEndline()); 109 | bug.setPackageName(warning.getPackage()); 110 | bug.setModuleName(moduleName); 111 | bug.setFileName(file.getName()); 112 | bug.setColumnPosition(warning.getBegincolumn(), warning.getEndcolumn()); 113 | bug.setContextHashCode(createContextHashCode(file.getName(), warning.getBeginline(), warning.getRule())); 114 | 115 | annotations.add(bug); 116 | } 117 | } 118 | return annotations; 119 | } 120 | 121 | private String createMessage(final Violation warning) { 122 | String original = warning.getMessage(); 123 | if (StringUtils.endsWith(original, ".")) { 124 | return original; 125 | } 126 | else { 127 | return original + "."; 128 | } 129 | } 130 | } 131 | 132 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/parser/Violation.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.parser; 2 | 3 | /** 4 | * Java Bean class for a violation of the PMD format. 5 | * 6 | * @author Ulli Hafner 7 | */ 8 | @SuppressWarnings("javadoc") 9 | public class Violation { 10 | /** Type of warning. */ 11 | private String rule; 12 | /** Category of warning. */ 13 | private String ruleset; 14 | 15 | private String externalInfoUrl; 16 | private String javaPackage; 17 | private int priority; 18 | private String message; 19 | private int beginline; 20 | private int endline; 21 | private int begincolumn; 22 | private int endcolumn; 23 | 24 | // CHECKSTYLE:OFF 25 | public String getRule() { 26 | return rule; 27 | } 28 | public void setRule(final String rule) { 29 | this.rule = rule; 30 | } 31 | public String getRuleset() { 32 | return ruleset; 33 | } 34 | public void setRuleset(final String ruleset) { 35 | this.ruleset = ruleset; 36 | } 37 | public String getExternalInfoUrl() { 38 | return externalInfoUrl; 39 | } 40 | public void setExternalInfoUrl(final String externalInfoUrl) { 41 | this.externalInfoUrl = externalInfoUrl; 42 | } 43 | public String getPackage() { 44 | return javaPackage; 45 | } 46 | public void setPackage(final String packageName) { 47 | javaPackage = packageName; 48 | } 49 | public int getPriority() { 50 | return priority; 51 | } 52 | public void setPriority(final int priority) { 53 | this.priority = priority; 54 | } 55 | public String getMessage() { 56 | return message; 57 | } 58 | public void setMessage(final String message) { 59 | this.message = message; 60 | } 61 | public int getBeginline() { 62 | return beginline; 63 | } 64 | public void setBeginline(final int beginline) { 65 | this.beginline = beginline; 66 | } 67 | public int getEndline() { 68 | return endline; 69 | } 70 | public void setEndline(final int endline) { 71 | this.endline = endline; 72 | } 73 | public int getEndcolumn() { 74 | return endcolumn; 75 | } 76 | public void setEndcolumn(final int endcolumn) { 77 | this.endcolumn = endcolumn; 78 | } 79 | public int getBegincolumn() { 80 | return begincolumn; 81 | } 82 | public void setBegincolumn(final int begincolumn) { 83 | this.begincolumn = begincolumn; 84 | } 85 | } 86 | 87 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/tokens/FixedPmdWarningsTokenMacro.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.tokens; 2 | 3 | import hudson.Extension; 4 | import hudson.plugins.analysis.tokens.AbstractFixedAnnotationsTokenMacro; 5 | import hudson.plugins.pmd.PmdMavenResultAction; 6 | import hudson.plugins.pmd.PmdResultAction; 7 | 8 | /** 9 | * Provides a token that evaluates to the number of fixed PMD warnings. 10 | * 11 | * @author Ulli Hafner 12 | */ 13 | @Extension(optional = true) 14 | public class FixedPmdWarningsTokenMacro extends AbstractFixedAnnotationsTokenMacro { 15 | /** 16 | * Creates a new instance of {@link FixedPmdWarningsTokenMacro}. 17 | */ 18 | @SuppressWarnings("unchecked") 19 | public FixedPmdWarningsTokenMacro() { 20 | super("PMD_FIXED", PmdResultAction.class, PmdMavenResultAction.class); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/tokens/NewPmdWarningsTokenMacro.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.tokens; 2 | 3 | import hudson.Extension; 4 | import hudson.plugins.analysis.tokens.AbstractNewAnnotationsTokenMacro; 5 | import hudson.plugins.pmd.PmdMavenResultAction; 6 | import hudson.plugins.pmd.PmdResultAction; 7 | 8 | /** 9 | * Provides a token that evaluates to the number of new PMD warnings. 10 | * 11 | * @author Ulli Hafner 12 | */ 13 | @Extension(optional = true) 14 | public class NewPmdWarningsTokenMacro extends AbstractNewAnnotationsTokenMacro { 15 | /** 16 | * Creates a new instance of {@link NewPmdWarningsTokenMacro}. 17 | */ 18 | @SuppressWarnings("unchecked") 19 | public NewPmdWarningsTokenMacro() { 20 | super("PMD_NEW", PmdResultAction.class, PmdMavenResultAction.class); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/tokens/PmdResultTokenMacro.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.tokens; 2 | 3 | import hudson.Extension; 4 | import hudson.plugins.analysis.tokens.AbstractResultTokenMacro; 5 | import hudson.plugins.pmd.PmdMavenResultAction; 6 | import hudson.plugins.pmd.PmdResultAction; 7 | 8 | /** 9 | * Provides a token that evaluates to the PMD build result. 10 | * 11 | * @author Ulli Hafner 12 | */ 13 | @Extension(optional = true) 14 | public class PmdResultTokenMacro extends AbstractResultTokenMacro { 15 | /** 16 | * Creates a new instance of {@link PmdResultTokenMacro}. 17 | */ 18 | @SuppressWarnings("unchecked") 19 | public PmdResultTokenMacro() { 20 | super("PMD_RESULT", PmdResultAction.class, PmdMavenResultAction.class); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/pmd/tokens/PmdWarningCountTokenMacro.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.tokens; 2 | 3 | import hudson.Extension; 4 | import hudson.plugins.analysis.tokens.AbstractAnnotationsCountTokenMacro; 5 | import hudson.plugins.pmd.PmdMavenResultAction; 6 | import hudson.plugins.pmd.PmdResultAction; 7 | 8 | /** 9 | * Provides a token that evaluates to the number of PMD warnings. 10 | * 11 | * @author Ulli Hafner 12 | */ 13 | @Extension(optional = true) 14 | public class PmdWarningCountTokenMacro extends AbstractAnnotationsCountTokenMacro { 15 | /** 16 | * Creates a new instance of {@link PmdWarningCountTokenMacro}. 17 | */ 18 | @SuppressWarnings("unchecked") 19 | public PmdWarningCountTokenMacro() { 20 | super("PMD_COUNT", PmdResultAction.class, PmdMavenResultAction.class); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/pmd/Messages.properties: -------------------------------------------------------------------------------- 1 | PMD.Warnings.ColumnHeader=# PMD 2 | PMD.Warnings.Column=Number of PMD warnings 3 | PMD.Publisher.Name=[Deprecated] Publish PMD analysis results 4 | 5 | PMD.ProjectAction.Name=PMD Warnings 6 | 7 | PMD.Trend.Name=PMD Trend 8 | 9 | PMD.ResultAction.Header=PMD Result 10 | 11 | PMD.ResultAction.HealthReportNoItem=PMD: no warnings found. 12 | PMD.ResultAction.HealthReportSingleItem=PMD: one warning found. 13 | PMD.ResultAction.HealthReportMultipleItem=PMD: {0} warnings found. 14 | 15 | PMD.Detail.header=PMD Warnings 16 | 17 | PMD.FixedWarnings.Detail.header=Fixed PMD Warnings 18 | PMD.NewWarnings.Detail.header=New PMD Warnings 19 | 20 | Portlet.WarningsTable=PMD warnings per project 21 | Portlet.WarningsPriorityGraph=PMD warnings trend graph (priority distribution) 22 | Portlet.WarningsNewVsFixedGraph=PMD warnings trend graph (new vs. fixed) 23 | Portlet.WarningsTotalsGraph=PMD warnings trend graph (totals) 24 | Portlet.WarningsUserGraph=PMD warnings (priority per author) -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/pmd/Messages_de.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/pmd-plugin/8ae81512020e8c9a58531dfdeec58b912d2dd212/src/main/resources/hudson/plugins/pmd/Messages_de.properties -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/pmd/Messages_fr.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/pmd-plugin/8ae81512020e8c9a58531dfdeec58b912d2dd212/src/main/resources/hudson/plugins/pmd/Messages_fr.properties -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/pmd/Messages_ja.properties: -------------------------------------------------------------------------------- 1 | PMD.ProjectAction.Name=PMD\u8B66\u544A 2 | 3 | PMD.Trend.Name=PMD\u8B66\u544A\u306E\u63A8\u79FB 4 | 5 | PMD.ResultAction.Header=PMD \u8B66\u544A 6 | PMD.ResultAction.HealthReportNoItem=PMD: \u8B66\u544A\u306F\u3042\u308A\u307E\u305B\u3093\u3002 7 | PMD.ResultAction.HealthReportSingleItem=PMD: \u8B66\u544A\u304C1\u3064\u3042\u308A\u307E\u3059\u3002 8 | PMD.ResultAction.HealthReportMultipleItem=PMD: {0} \u500B\u306E\u8B66\u544A\u304C\u3042\u308A\u307E\u3059\u3002 9 | 10 | PMD.Detail.header=PMD\u8B66\u544A 11 | 12 | PMD.FixedWarnings.Detail.header=\u4FEE\u6B63\u3055\u308C\u305FPMD\u8B66\u544A 13 | PMD.NewWarnings.Detail.header=\u65B0\u3057\u3044PMD\u8B66\u544A 14 | 15 | Portlet.WarningsTable=\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u6BCE\u306EPMD\u8B66\u544A 16 | Portlet.WarningsPriorityGraph=PMD\u8B66\u544A\u306E\u63A8\u79FB\u30B0\u30E9\u30D5 (\u512A\u5148\u5EA6\u306E\u5206\u5E03) 17 | Portlet.WarningsNewVsFixedGraph=PMD\u8B66\u544A\u306E\u63A8\u79FB\u30B0\u30E9\u30D5 (\u65B0\u898F vs. \u4FEE\u6B63\u6E08) 18 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/pmd/Messages_nl.properties: -------------------------------------------------------------------------------- 1 | PMD.ResultAction.Header=PMD Resultaat 2 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/pmd/Messages_zh_TW.properties: -------------------------------------------------------------------------------- 1 | # The MIT License 2 | # 3 | # Copyright (c) 2013, Chunghwa Telecom Co., Ltd., Pei-Tang Huang 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | PMD.ProjectAction.Name=PMD \u8b66\u544a 24 | 25 | PMD.Trend.Name=PMD \u8da8\u52e2 26 | 27 | PMD.ResultAction.Header=PMD \u7d50\u679c 28 | 29 | PMD.ResultAction.HealthReportNoItem=PMD: \u627e\u4e0d\u5230\u8b66\u544a\u3002 30 | PMD.ResultAction.HealthReportSingleItem=PMD: \u627e\u5230 1 \u9805\u8b66\u544a\u3002 31 | PMD.ResultAction.HealthReportMultipleItem=PMD: \u627e\u5230 {0} \u9805\u8b66\u544a\u3002 32 | 33 | PMD.Detail.header=PMD \u8b66\u544a 34 | 35 | PMD.FixedWarnings.Detail.header=\u4fee\u6b63\u7684 PMD \u8b66\u544a 36 | PMD.NewWarnings.Detail.header=\u65b0\u7684 PMD \u8b66\u544a 37 | 38 | Portlet.WarningsTable=\u5404\u5225\u5c08\u6848\u7684 PMD \u8b66\u544a 39 | Portlet.WarningsPriorityGraph=PMD \u8b66\u544a\u8da8\u52e2\u5716 (\u512a\u5148\u9806\u5e8f\u5206\u4f48) 40 | Portlet.WarningsNewVsFixedGraph=PMD \u8b66\u544a\u8da8\u52e2\u5716 (\u65b0\u589e\u8207\u4fee\u6b63) 41 | Portlet.WarningsTotalsGraph=PMD \u8b66\u544a\u8da8\u52e2\u5716 (\u7e3d\u8a08) 42 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/pmd/PmdPublisher/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/pmd/PmdPublisher/config.properties: -------------------------------------------------------------------------------- 1 | description.pattern=Fileset 'includes' \ 2 | setting that specifies the generated raw PMD XML report files, such as '**/pmd.xml'. \ 3 | Basedir of the fileset is the workspace root. \ 4 | If no value is set, then the default '**/pmd.xml' is used. Be sure not to include any \ 5 | non-report files into this pattern. 6 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/pmd/PmdPublisher/config_de.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/pmd-plugin/8ae81512020e8c9a58531dfdeec58b912d2dd212/src/main/resources/hudson/plugins/pmd/PmdPublisher/config_de.properties -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/pmd/PmdPublisher/config_ja.properties: -------------------------------------------------------------------------------- 1 | PMD\ results=\u96C6\u8A08\u3059\u308B\u30D5\u30A1\u30A4\u30EB 2 | description.pattern=\ 3 | PMD\u304C\u751F\u6210\u3059\u308BXML\u5F62\u5F0F\u306E\u30EC\u30DD\u30FC\u30C8\u30D5\u30A1\u30A4\u30EB\u3092\u3001\ 4 | '**/pmd.xml'\u306E\u3088\u3046\u306BAnt\u306EFileset 'includes'\u5F62\u5F0F\u3067\u6307\u5B9A\u3057\u307E\u3059\u3002\ 5 | fileset\u3067\u306E\u6307\u5B9A\u306F\u3001\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u306E\u30EB\u30FC\u30C8\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u57FA\u6E96\u3068\u3057\u307E\u3059\u3002\ 6 | \u4F55\u3082\u6307\u5B9A\u3057\u306A\u3051\u308C\u3070\u3001'**/pmd.xml'\u3092\u5BFE\u8C61\u3068\u3057\u307E\u3059\u3002PMD\u306E\u30EC\u30DD\u30FC\u30C8\u3067\u306F\u306A\u3044\u30D5\u30A1\u30A4\u30EB\u3092\u542B\u3081\u306A\u3044\u3088\u3046\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002 7 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/pmd/PmdPublisher/config_zh_TW.properties: -------------------------------------------------------------------------------- 1 | # The MIT License 2 | # 3 | # Copyright (c) 2013, Chunghwa Telecom Co., Ltd., Pei-Tang Huang 4 | # 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | # 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | # 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | description.pattern=\u6307\u5b9a\u5230 PMD \u7522\u51fa\u539f\u59cb XML \u5831\u544a\u6a94\u7684\u6a94\u6848\u96c6 'includes'\ 24 | \u8a2d\u5b9a\uff0c\u4f8b\u5982 '**/pmd.xml'\u3002\ 25 | \u6a94\u6848\u96c6\u8d77\u7b97\u76ee\u9304\u5c31\u662f\u5de5\u4f5c\u5340\u6839\u76ee\u9304\u3002\ 26 | \u5982\u679c\u6c92\u6709\u8a2d\u5b9a\uff0c\u9810\u8a2d\u6703\u662f '**/pmd.xml'\u3002\ 27 | \u8acb\u78ba\u8a8d\u8a2d\u5b9a\u7684\u6a21\u5f0f\u4e0d\u5305\u542b\u5831\u544a\u6a94\u4ee5\u5916\u7684\u6a94\u6848\u3002 28 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/pmd/PmdPublisher/global.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/pmd/PmdReporter/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/pmd/PmdReporter/global.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/pmd/tokens/FixedPmdWarningsTokenMacro/help.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
$${PMD_FIXED}
5 |
6 | Expands to the total number of fixed PMD warnings in a build. 7 |
8 | 9 |
-------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/pmd/tokens/NewPmdWarningsTokenMacro/help.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
$${PMD_NEW}
5 |
6 | Expands to the total number of new PMD warnings in a build. 7 |
8 | 9 |
-------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/pmd/tokens/PmdResultTokenMacro/help.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
$${PMD_RESULT}
5 |
6 | Expands to the build result of the PMD plug-in. 7 |
8 | 9 |
-------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/pmd/tokens/PmdWarningCountTokenMacro/help.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
$${PMD_COUNT}
5 |
6 | Expands to the total number of PMD warnings in a build. 7 |
8 | 9 |
-------------------------------------------------------------------------------- /src/main/resources/index.jelly: -------------------------------------------------------------------------------- 1 |
2 | The PMD plug-in reached end-of-life. All functionality has been integrated 3 | into the Warnings Next Generation Plugin. 4 |
5 | -------------------------------------------------------------------------------- /src/main/webapp/help-m2.html: -------------------------------------------------------------------------------- 1 |
2 |

Jenkins understands PMD 3 | analysis report XML format. When this option is configured and your 4 | build runs the maven goal pmd:pmd then Jenkins provides 5 | useful information about analysis results, such as historical result 6 | trend, module and package statistics, web UI for viewing analysis 7 | reports and warnings, and so on.

8 |

This plug-in is not invoked for failed builds, it is only called for 9 | stable or unstable builds (i.e., a build with failed tests).

10 |
-------------------------------------------------------------------------------- /src/main/webapp/help-m2_de.html: -------------------------------------------------------------------------------- 1 |
2 |

Jenkins kann PMD Reports 3 | einlesen und darstellen. Wenn dies aktiviert wird und der Build das 4 | Maven Goal pmd:pmd ausführt, dann analysiert Jenkins nach 5 | jedem Build die erzeugten PMD Dateien und stellt deren Informationen in 6 | verschiedenen Ansichten dar: Trend Anzeige, Projekt Statistik und 7 | Package Statistik. Zudem zeigt Jenkins die jeweiligen Warnungen direkt in 8 | der betroffen Datei an.

9 |

Das Plug-in wird nicht aufgerufen, wenn der Build fehlgeschlagen 10 | ist, sondern nur für stabile bzw. instabile Builds (mit fehlgeschlagenen Tests).

11 |
-------------------------------------------------------------------------------- /src/main/webapp/help-m2_zh_TW.html: -------------------------------------------------------------------------------- 1 |
2 |

3 | Jenkins 認得 XML 格式的 PMD 分析報告。 4 | 當您啟用這個選項,而且您的建置執行了 Maven pmd:pmd 這個 5 | Goal,Jenkins 就會提供很有用的分析結果資訊,例如: 6 | 結果歷史趨勢、模組及套件統計、查看分析報告及警告的網頁等。 7 |

8 |

9 | 本外掛程式在不會在失敗的建置中執行,只有穩定或是不穩定 (測試失敗) 的建置才會呼叫。 10 |

11 |
-------------------------------------------------------------------------------- /src/main/webapp/help.html: -------------------------------------------------------------------------------- 1 |
2 |

Jenkins understands PMD 3 | analysis report XML format. When this option is configured Jenkins shows 4 | the PMD analysis results in different views: historical result 5 | trend, module and package statistics, web UI for viewing analysis 6 | reports and warnings, and so on.

7 |

You need to set up your build to run PMD in order to use 8 | this feature - this Jenkins plug-in does not perform the actual analysis! 9 | This plug-in is not invoked for failed builds, it is only called for 10 | stable or unstable builds (i.e., a build with failed tests).

11 |

Note: If you are using the maven-pmd-plugin to create the 12 | PMD analysis files please make sure to specify the pattern **/target/pmd.xml. 13 | Otherwise you will get a wrong warning count since the maven-pmd-plugin 14 | gererates two identical output files.

15 |
-------------------------------------------------------------------------------- /src/main/webapp/help_de.html: -------------------------------------------------------------------------------- 1 |
2 |

Jenkins kann PMD Reports 3 | einlesen und darstellen. Wenn dies aktiviert wird, analysiert Jenkins 4 | nach jedem Build die erzeugten PMD Dateien und stellt deren 5 | Informationen in verschiedenen Ansichten dar: Trend Anzeige, Projekt 6 | Statistik und Package Statistik. Zudem zeigt Jenkins die jeweiligen 7 | Warnungen direkt in der betroffen Datei an.

8 |

Damit das Plug-in korrekt funktioniert, muss im Build PMD 9 | gestartet werden - das Jenkins Plug-in selbst macht dies nicht! Das 10 | Plug-in wird nicht aufgerufen, wenn der Build fehlgeschlagen ist, 11 | sondern nur für stabile bzw. instabile Builds (mit fehlgeschlagenen 12 | Tests).

13 |
-------------------------------------------------------------------------------- /src/main/webapp/help_zh_TW.html: -------------------------------------------------------------------------------- 1 |
2 |

3 | Jenkins 認得 XML 格式的 PMD 分析報告。 4 | 選用這個選項後,Jenkins 會從不同面向顯示 PMD 分析結果,包含: 5 | 結果歷史趨勢、模組及套件統計、查看分析報告及警告的網頁等。 6 |

7 |

8 | 您要在建置過程中執行 PMD 才能用這項功能,本 Jenkins 外掛程式不會實際執行分析作業! 9 | 本外掛程式在不會在失敗的建置中執行,只有穩定或是不穩定 (測試失敗) 的建置才會呼叫。 10 |

11 |

12 | 注意: 如果您是使用 maven-pmd-plugin 產生 PMD 分析結果檔,請確認您是設成 13 | **/target/pmd.xml。 14 | 否則計算出來的警告數會是錯的,因為 maven-pmd-plugin 會產生兩個一模一樣的檔案。 15 |

16 |
-------------------------------------------------------------------------------- /src/main/webapp/icons/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2003, InfoEther, LLC 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * The end-user documentation included with the redistribution, if 14 | any, must include the following acknowledgement: 15 | "This product includes software developed in part by support from 16 | the Defense Advanced Research Project Agency (DARPA)" 17 | * Neither the name of InfoEther, LLC nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 23 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 24 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 25 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /src/main/webapp/icons/pmd-24x24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/pmd-plugin/8ae81512020e8c9a58531dfdeec58b912d2dd212/src/main/webapp/icons/pmd-24x24.png -------------------------------------------------------------------------------- /src/main/webapp/icons/pmd-48x48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/pmd-plugin/8ae81512020e8c9a58531dfdeec58b912d2dd212/src/main/webapp/icons/pmd-48x48.png -------------------------------------------------------------------------------- /src/test/java/hudson/plugins/pmd/PmdHealthDescriptorTest.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd; 2 | 3 | import static org.junit.Assert.*; 4 | import static org.mockito.Mockito.*; 5 | import hudson.plugins.analysis.core.AbstractHealthDescriptor; 6 | import hudson.plugins.analysis.core.HealthDescriptor; 7 | import hudson.plugins.analysis.core.NullHealthDescriptor; 8 | import hudson.plugins.analysis.test.AbstractHealthDescriptorTest; 9 | import hudson.plugins.analysis.util.model.AnnotationProvider; 10 | 11 | import org.junit.Test; 12 | import org.jvnet.localizer.Localizable; 13 | 14 | /** 15 | * Tests the class {@link PmdHealthDescriptor}. 16 | * 17 | * @author Ulli Hafner 18 | */ 19 | public class PmdHealthDescriptorTest extends AbstractHealthDescriptorTest { 20 | /** 21 | * Verifies the different messages if the number of items are 0, 1, and 2. 22 | */ 23 | @Test 24 | public void verifyNumberOfItems() { 25 | AnnotationProvider provider = mock(AnnotationProvider.class); 26 | PmdHealthDescriptor healthDescriptor = new PmdHealthDescriptor(NullHealthDescriptor.NULL_HEALTH_DESCRIPTOR); 27 | 28 | Localizable description = healthDescriptor.createDescription(provider); 29 | assertEquals(WRONG_DESCRIPTION, Messages.PMD_ResultAction_HealthReportNoItem(), description.toString()); 30 | 31 | when(provider.getNumberOfAnnotations()).thenReturn(1); 32 | description = healthDescriptor.createDescription(provider); 33 | assertEquals(WRONG_DESCRIPTION, Messages.PMD_ResultAction_HealthReportSingleItem(), description.toString()); 34 | 35 | when(provider.getNumberOfAnnotations()).thenReturn(2); 36 | description = healthDescriptor.createDescription(provider); 37 | assertEquals(WRONG_DESCRIPTION, Messages.PMD_ResultAction_HealthReportMultipleItem(2), description.toString()); 38 | } 39 | 40 | @Override 41 | protected AbstractHealthDescriptor createHealthDescriptor(final HealthDescriptor healthDescriptor) { 42 | return new PmdHealthDescriptor(healthDescriptor); 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /src/test/java/hudson/plugins/pmd/PmdResultTest.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd; 2 | 3 | import hudson.model.AbstractBuild; 4 | import hudson.plugins.analysis.core.BuildHistory; 5 | import hudson.plugins.analysis.core.ParserResult; 6 | import hudson.plugins.analysis.test.BuildResultTest; 7 | 8 | /** 9 | * Tests the class {@link PmdResult}. 10 | */ 11 | public class PmdResultTest extends BuildResultTest { 12 | @Override 13 | protected PmdResult createBuildResult(final AbstractBuild build, final ParserResult project, final BuildHistory history) { 14 | return new PmdResult(build, history, project, "UTF8", false); 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /src/test/java/hudson/plugins/pmd/PmdWorkflowTest.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd; 2 | 3 | import hudson.FilePath; 4 | import hudson.model.Result; 5 | import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; 6 | import org.jenkinsci.plugins.workflow.job.WorkflowJob; 7 | import org.junit.Rule; 8 | import org.junit.Test; 9 | import org.jvnet.hudson.test.JenkinsRule; 10 | 11 | import static org.junit.Assert.assertEquals; 12 | import static org.junit.Assert.assertTrue; 13 | 14 | public class PmdWorkflowTest { 15 | 16 | @Rule 17 | public JenkinsRule jenkinsRule = new JenkinsRule(); 18 | 19 | /** 20 | * Run a workflow job using {@link PmdPublisher} and check for success. 21 | */ 22 | @Test 23 | public void pmdPublisherWorkflowStep() throws Exception { 24 | WorkflowJob job = jenkinsRule.jenkins.createProject(WorkflowJob.class, "pmdPublisherWorkflowStep"); 25 | FilePath workspace = jenkinsRule.jenkins.getWorkspaceFor(job); 26 | FilePath report = workspace.child("target").child("pmd.xml"); 27 | report.copyFrom(PmdWorkflowTest.class.getResourceAsStream("/hudson/plugins/pmd/parser/4-pmd-warnings.xml")); 28 | job.setDefinition(new CpsFlowDefinition("" 29 | + "node {\n" 30 | + " step([$class: 'PmdPublisher'])\n" 31 | + "}\n", true) 32 | ); 33 | jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0)); 34 | PmdResultAction result = job.getLastBuild().getAction(PmdResultAction.class); 35 | assertEquals(4, result.getResult().getAnnotations().size()); 36 | } 37 | 38 | /** 39 | * Run a workflow job using {@link PmdPublisher} with a failing threshold of 0, so the given example file 40 | * "/hudson/plugins/pmd/parser/4-pmd-warnings.xml" will make the build to fail. 41 | */ 42 | @Test 43 | public void pmdPublisherWorkflowStepSetLimits() throws Exception { 44 | WorkflowJob job = jenkinsRule.jenkins.createProject(WorkflowJob.class, "pmdPublisherWorkflowStepSetLimits"); 45 | FilePath workspace = jenkinsRule.jenkins.getWorkspaceFor(job); 46 | FilePath report = workspace.child("target").child("pmd.xml"); 47 | report.copyFrom(PmdWorkflowTest.class.getResourceAsStream("/hudson/plugins/pmd/parser/4-pmd-warnings.xml")); 48 | job.setDefinition(new CpsFlowDefinition("" 49 | + "node {\n" 50 | + " step([$class: 'PmdPublisher', pattern: '**/pmd.xml', failedTotalAll: '0', usePreviousBuildAsReference: false])\n" 51 | + "}\n", true) 52 | ); 53 | jenkinsRule.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get()); 54 | PmdResultAction result = job.getLastBuild().getAction(PmdResultAction.class); 55 | assertEquals(4, result.getResult().getAnnotations().size()); 56 | } 57 | 58 | /** 59 | * Run a workflow job using {@link PmdPublisher} with a unstable threshold of 0, so the given example file 60 | * "/hudson/plugins/pmd/parser/4-pmd-warnings.xml" will make the build to fail. 61 | */ 62 | @Test 63 | public void pmdPublisherWorkflowStepFailure() throws Exception { 64 | WorkflowJob job = jenkinsRule.jenkins.createProject(WorkflowJob.class, "pmdPublisherWorkflowStepFailure"); 65 | FilePath workspace = jenkinsRule.jenkins.getWorkspaceFor(job); 66 | FilePath report = workspace.child("target").child("pmd.xml"); 67 | report.copyFrom(PmdWorkflowTest.class.getResourceAsStream("/hudson/plugins/pmd/parser/4-pmd-warnings.xml")); 68 | job.setDefinition(new CpsFlowDefinition("" 69 | + "node {\n" 70 | + " step([$class: 'PmdPublisher', pattern: '**/pmd.xml', unstableTotalAll: '0', usePreviousBuildAsReference: false])\n" 71 | + "}\n") 72 | ); 73 | jenkinsRule.assertBuildStatus(Result.UNSTABLE, job.scheduleBuild2(0).get()); 74 | PmdResultAction result = job.getLastBuild().getAction(PmdResultAction.class); 75 | assertEquals(4, result.getResult().getAnnotations().size()); 76 | } 77 | } 78 | 79 | -------------------------------------------------------------------------------- /src/test/java/hudson/plugins/pmd/parser/BugSerializeModelTest.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.parser; 2 | 3 | import hudson.XmlFile; 4 | import hudson.plugins.analysis.test.AbstractSerializeModelTest; 5 | import hudson.plugins.analysis.util.model.AbstractAnnotation; 6 | import hudson.plugins.analysis.util.model.AnnotationStream; 7 | import hudson.plugins.analysis.util.model.JavaProject; 8 | import hudson.plugins.analysis.util.model.Priority; 9 | 10 | import java.io.File; 11 | 12 | import org.junit.Assert; 13 | 14 | import org.junit.Test; 15 | 16 | import com.thoughtworks.xstream.XStream; 17 | 18 | /** 19 | * Tests the serialization of the model. 20 | * 21 | * @see Testing object serialization 22 | */ 23 | public class BugSerializeModelTest extends AbstractSerializeModelTest { 24 | /** Serialization provider. */ 25 | private static final XStream XSTREAM = new AnnotationStream(); 26 | 27 | static { 28 | XSTREAM.alias("bug", Bug.class); 29 | } 30 | 31 | /** 32 | * Verifies the first created annotation. 33 | * 34 | * @param annotation 35 | * the first created annotation 36 | */ 37 | @Override 38 | protected void verifyFirstAnnotation(final AbstractAnnotation annotation) { 39 | Bug bug = (Bug)annotation; 40 | Assert.assertEquals("Wrong detail message." , TEST_TASK1, bug.getMessage()); 41 | } 42 | 43 | /** 44 | * Creates an annotation. 45 | * 46 | * @param line 47 | * the line 48 | * @param message 49 | * the message 50 | * @param priority 51 | * the priority 52 | * @param fileName 53 | * the file name 54 | * @param packageName 55 | * the package name 56 | * @param moduleName 57 | * the module name 58 | * @return the annotation 59 | */ 60 | @Override 61 | protected AbstractAnnotation createAnnotation(final int line, final String message, final Priority priority, final String fileName, final String packageName, final String moduleName) { 62 | Bug annotation = new Bug(priority, message, message, message, line); 63 | annotation.setFileName(fileName); 64 | annotation.setPackageName(packageName); 65 | annotation.setModuleName(moduleName); 66 | 67 | return annotation; 68 | } 69 | 70 | /** 71 | * Test whether a serialized project is the same object after 72 | * deserialization of the file format of release 2.2. 73 | */ 74 | @Test 75 | public void ensureSameSerialization() { 76 | JavaProject project = deserialize("project.ser"); 77 | 78 | verifyProject(project); 79 | } 80 | 81 | /** 82 | * Test whether a serialized project is the same object after 83 | * deserialization of the file format of release 2.2. 84 | */ 85 | @Test 86 | public void ensureSameXmlSerialization() { 87 | ensureSerialization("project.ser.xml"); 88 | } 89 | 90 | @Override 91 | protected XmlFile createXmlFile(final File file) { 92 | return new XmlFile(XSTREAM, file); 93 | } 94 | } 95 | 96 | -------------------------------------------------------------------------------- /src/test/java/hudson/plugins/pmd/parser/BugsDifferencerTest.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.parser; 2 | 3 | import hudson.plugins.analysis.core.IssueDifference; 4 | import hudson.plugins.analysis.test.AnnotationDifferencerTest; 5 | import hudson.plugins.analysis.util.model.FileAnnotation; 6 | import hudson.plugins.analysis.util.model.Priority; 7 | 8 | /** 9 | * Tests the {@link IssueDifference} for bugs. 10 | */ 11 | public class BugsDifferencerTest extends AnnotationDifferencerTest { 12 | @Override 13 | public FileAnnotation createAnnotation(final String fileName, final Priority priority, final String message, final String category, 14 | final String type, final int start, final int end) { 15 | Bug bug = new Bug(priority, message, message, message, start, end); 16 | bug.setFileName(fileName); 17 | return bug; 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/test/java/hudson/plugins/pmd/parser/PmdMessagesTest.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.parser; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.assertEquals; 6 | 7 | /** 8 | * Tests the class {@link PmdMessages}. 9 | * 10 | * @author Ullrich Hafner 11 | */ 12 | public class PmdMessagesTest { 13 | /** 14 | * Verifies that the PMD messages could be correctly read. 15 | */ 16 | @Test 17 | public void shouldHaveAllMessage() { 18 | assertEquals("Wrong number of rulesets found: ", 25, PmdMessages.getInstance().initialize()); 19 | 20 | assertEquals("\n" + 21 | "Empty Catch Block finds instances where an exception is caught, but nothing is done. \n" + 22 | "In most circumstances, this swallows an exception which should either be acted on \n" + 23 | "or reported.\n" + 24 | "
\n" +
25 |                 "  \n" +
26 |                 "public void doSomething() {\n" +
27 |                 "  try {\n" +
28 |                 "    FileInputStream fis = new FileInputStream(\"/tmp/bugger\");\n" +
29 |                 "  } catch (IOException ioe) {\n" +
30 |                 "      // not good\n" +
31 |                 "  }\n" +
32 |                 "}\n" +
33 |                 " \n" +
34 |                 "      
", 35 | PmdMessages.getInstance().getMessage("Empty Code", "EmptyCatchBlock")); 36 | } 37 | } -------------------------------------------------------------------------------- /src/test/java/hudson/plugins/pmd/parser/PmdParserTest.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.pmd.parser; 2 | 3 | import java.io.InputStream; 4 | import java.lang.reflect.InvocationTargetException; 5 | import java.util.Collection; 6 | 7 | import org.apache.commons.io.IOUtils; 8 | import org.junit.Test; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | import hudson.plugins.analysis.core.ParserResult; 13 | import hudson.plugins.analysis.util.model.FileAnnotation; 14 | import hudson.plugins.analysis.util.model.MavenModule; 15 | import hudson.plugins.analysis.util.model.Priority; 16 | 17 | /** 18 | * Tests the extraction of PMD analysis results. 19 | */ 20 | public class PmdParserTest { 21 | /** Error message. */ 22 | private static final String WRONG_WARNING_PROPERTY = "Wrong warning property"; 23 | /** Error message. */ 24 | private static final String ERROR_MESSAGE = "Wrong number of warnings detected."; 25 | 26 | /** 27 | * Parses the specified file. 28 | * 29 | * @param fileName 30 | * the file to read 31 | * @return the parsed module 32 | * @throws InvocationTargetException 33 | * in case of an error 34 | */ 35 | private Collection parseFile(final String fileName) throws InvocationTargetException { 36 | InputStream file = PmdParserTest.class.getResourceAsStream(fileName); 37 | try { 38 | return new PmdParser().parse(file, "module"); 39 | } 40 | finally { 41 | IOUtils.closeQuietly(file); 42 | } 43 | } 44 | 45 | /** 46 | * Parses a warning log with 15 warnings. 47 | * 48 | * @throws InvocationTargetException 49 | * if the file could not be read 50 | * @see Issue 12801 51 | */ 52 | @Test 53 | public void issue12801() throws InvocationTargetException { 54 | String fileName = "issue12801.xml"; 55 | Collection annotations = parseFile(fileName); 56 | 57 | assertEquals(ERROR_MESSAGE, 2, annotations.size()); 58 | ParserResult result = new ParserResult(annotations); 59 | assertEquals(ERROR_MESSAGE, 2, result.getNumberOfAnnotations()); 60 | 61 | } 62 | 63 | /** 64 | * Checks whether we correctly detect all 669 warnings. 65 | * 66 | * @throws InvocationTargetException 67 | * indicates a test failure 68 | */ 69 | @Test 70 | public void scanFileWithSeveralWarnings() throws InvocationTargetException { 71 | String fileName = "pmd.xml"; 72 | Collection annotations = parseFile(fileName); 73 | 74 | assertEquals(ERROR_MESSAGE, 669, annotations.size()); 75 | } 76 | 77 | /** 78 | * Checks whether we create messages with a single dot. 79 | * 80 | * @throws InvocationTargetException 81 | * indicates a test failure 82 | */ 83 | @Test 84 | public void verifySingleDot() throws InvocationTargetException { 85 | String fileName = "warning-message-with-dot.xml"; 86 | Collection annotations = parseFile(fileName); 87 | 88 | assertEquals(ERROR_MESSAGE, 2, annotations.size()); 89 | 90 | FileAnnotation annotation = annotations.iterator().next(); 91 | 92 | assertEquals("Wrong message text: ", "Avoid really long parameter lists.", annotation.getMessage()); 93 | } 94 | 95 | /** 96 | * Checks whether we correctly detect an empty file. 97 | * * @throws InvocationTargetException indicates a test failure 98 | 99 | * @throws InvocationTargetException 100 | * indicates a test failure 101 | */ 102 | @Test 103 | public void scanFileWithNoBugs() throws InvocationTargetException { 104 | String fileName = "empty.xml"; 105 | Collection annotations = parseFile(fileName); 106 | 107 | assertEquals(ERROR_MESSAGE, 0, annotations.size()); 108 | } 109 | 110 | /** 111 | * Checks whether we correctly parse a file with 4 warnings. 112 | * 113 | * @throws InvocationTargetException 114 | * indicates a test failure 115 | */ 116 | @Test 117 | public void scanFileWith4Warnings() throws InvocationTargetException { 118 | PmdMessages.getInstance().initialize(); 119 | 120 | String fileName = "4-pmd-warnings.xml"; 121 | Collection annotations = parseFile(fileName); 122 | MavenModule module = new MavenModule(); 123 | module.addAnnotations(annotations); 124 | 125 | assertEquals(ERROR_MESSAGE, 4, module.getNumberOfAnnotations()); 126 | 127 | assertEquals(ERROR_MESSAGE, 1, module.getPackage("com.avaloq.adt.env.internal.ui.actions") 128 | .getNumberOfAnnotations()); 129 | assertEquals(ERROR_MESSAGE, 1, module.getPackage( 130 | "com.avaloq.adt.env.internal.ui.actions.change").getNumberOfAnnotations()); 131 | assertEquals(ERROR_MESSAGE, 2, module.getPackage("com.avaloq.adt.env.internal.ui.dialogs") 132 | .getNumberOfAnnotations()); 133 | 134 | assertEquals(ERROR_MESSAGE, 1, module.getNumberOfAnnotations("HIGH")); 135 | assertEquals(ERROR_MESSAGE, 2, module.getNumberOfAnnotations("NORMAL")); 136 | assertEquals(ERROR_MESSAGE, 1, module.getNumberOfAnnotations("LOW")); 137 | 138 | Bug warning = (Bug)module.getPackage("com.avaloq.adt.env.internal.ui.actions") 139 | .getAnnotations().iterator().next(); 140 | 141 | assertEquals(WRONG_WARNING_PROPERTY, "These nested if statements could be combined.", 142 | warning.getMessage()); 143 | assertEquals(WRONG_WARNING_PROPERTY, Priority.NORMAL, warning.getPriority()); 144 | assertEquals(WRONG_WARNING_PROPERTY, "Basic", warning.getCategory()); 145 | assertEquals(WRONG_WARNING_PROPERTY, "CollapsibleIfStatements", warning.getType()); 146 | assertEquals(WRONG_WARNING_PROPERTY, 54, warning.getPrimaryLineNumber()); 147 | assertEquals(WRONG_WARNING_PROPERTY, "com.avaloq.adt.env.internal.ui.actions", warning 148 | .getPackageName()); 149 | assertEquals(WRONG_WARNING_PROPERTY, 1, warning.getLineRanges().size()); 150 | assertEquals(WRONG_WARNING_PROPERTY, 54, warning.getLineRanges().iterator().next() 151 | .getStart()); 152 | assertEquals(WRONG_WARNING_PROPERTY, 61, warning.getLineRanges().iterator().next().getEnd()); 153 | assertEquals( 154 | WRONG_WARNING_PROPERTY, 155 | "C:/Build/Results/jobs/ADT-Base/workspace/com.avaloq.adt.ui/src/main/java/com/avaloq/adt/env/internal/ui/actions/CopyToClipboard.java", 156 | warning.getFileName()); 157 | assertEquals( 158 | WRONG_WARNING_PROPERTY, 159 | "\n" + 160 | "Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.\n" + 161 | "
\n" +
162 |                         "  \n" +
163 |                         "void bar() {\n" +
164 |                         "\tif (x) {\t\t\t// original implementation\n" +
165 |                         "\t\tif (y) {\n" +
166 |                         "\t\t\t// do stuff\n" +
167 |                         "\t\t}\n" +
168 |                         "\t}\n" +
169 |                         "}\n" +
170 |                         "\n" +
171 |                         "void bar() {\n" +
172 |                         "\tif (x && y) {\t\t// optimized implementation\n" +
173 |                         "\t\t// do stuff\n" +
174 |                         "\t}\n" +
175 |                         "}\n" +
176 |                         " \n" +
177 |                         "      
", warning.getToolTip()); 178 | } 179 | 180 | /** 181 | * Checks whether we correctly parse a file with 4 warnings. 182 | * 183 | * @throws InvocationTargetException 184 | * indicates a test failure 185 | */ 186 | @Test 187 | public void testEquals() throws InvocationTargetException { 188 | String fileName = "equals-test.xml"; 189 | Collection annotations = parseFile(fileName); 190 | MavenModule module = new MavenModule(); 191 | module.addAnnotations(annotations); 192 | 193 | assertEquals(ERROR_MESSAGE, 4, module.getNumberOfAnnotations()); 194 | assertEquals(ERROR_MESSAGE, 4, module.getPackage("com.avaloq.adt.env.core.db.plsqlCompletion").getNumberOfAnnotations()); 195 | assertEquals(ERROR_MESSAGE, 4, module.getNumberOfAnnotations(Priority.NORMAL)); 196 | } 197 | } 198 | -------------------------------------------------------------------------------- /src/test/resources/hudson/plugins/pmd/parser/4-pmd-warnings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | These nested if statements could be combined 6 | 7 | 8 | 9 | 10 | Avoid unused imports such as 'org.eclipse.ui.IWorkbenchPart' 11 | 12 | 13 | 14 | 15 | Avoid empty catch blocks 16 | 17 | 18 | Avoid empty catch blocks 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/test/resources/hudson/plugins/pmd/parser/empty.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/test/resources/hudson/plugins/pmd/parser/equals-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | These nested if statements could be combined 6 | 7 | 8 | These nested if statements could be combined 9 | 10 | 11 | These nested if statements could be combined 12 | 13 | 14 | These nested if statements could be combined 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/test/resources/hudson/plugins/pmd/parser/issue12801.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Use equals() to compare object references. 6 | 7 | 8 | Use equals() to compare object references. 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/test/resources/hudson/plugins/pmd/parser/otherfile.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/test/resources/hudson/plugins/pmd/parser/project.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/pmd-plugin/8ae81512020e8c9a58531dfdeec58b912d2dd212/src/test/resources/hudson/plugins/pmd/parser/project.ser -------------------------------------------------------------------------------- /src/test/resources/hudson/plugins/pmd/parser/project.ser.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Test Task3 5 | Test Task3 6 | 7 | Test Task3 8 | LOW 9 | 679 10 | 11 | 12 | 100 13 | 100 14 | 15 | 16 | 100 17 | Path/To/File2 18 | Module1 19 | Package1 20 | 21 | 22 | Test Task2 23 | Test Task2 24 | 25 | Test Task2 26 | LOW 27 | 678 28 | 29 | 30 | 100 31 | 100 32 | 33 | 34 | 100 35 | Path/To/File 36 | Module1 37 | Package1 38 | 39 | 40 | Test Task4 41 | Test Task4 42 | 43 | Test Task4 44 | NORMAL 45 | 680 46 | 47 | 48 | 100 49 | 100 50 | 51 | 52 | 100 53 | Path/To/File 54 | Module1 55 | Package2 56 | 57 | 58 | Test Task5 59 | Test Task5 60 | 61 | Test Task5 62 | NORMAL 63 | 681 64 | 65 | 66 | 100 67 | 100 68 | 69 | 70 | 100 71 | Path/To/File 72 | Module2 73 | Package1 74 | 75 | 76 | Test Task1 77 | Test Task1 78 | 79 | Test Task1 80 | HIGH 81 | 677 82 | 83 | 84 | 100 85 | 100 86 | 87 | 88 | 100 89 | Path/To/File 90 | Module1 91 | Package1 92 | 93 | -------------------------------------------------------------------------------- /src/test/resources/hudson/plugins/pmd/parser/warning-message-with-dot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Avoid really long parameter lists. 6 | 7 | 8 | 9 | 10 | A high number of imports can indicate a high degree of coupling within an object. 11 | 12 | 13 | 15 | 17 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 28 | 29 | 30 | 32 | 33 | 34 | 36 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 50 | 52 | 54 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 76 | 78 | 80 | 82 | 83 | 84 | 85 | 87 | 89 | 91 | 92 | --------------------------------------------------------------------------------