├── .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 ├── README.md ├── checkstyle.iml ├── clean.sh ├── debug.sh ├── german.sh ├── go.sh ├── pom.xml ├── release.sh └── src ├── main ├── java │ └── hudson │ │ └── plugins │ │ └── checkstyle │ │ ├── CheckStyleAnnotationsAggregator.java │ │ ├── CheckStyleColumn.java │ │ ├── CheckStyleDescriptor.java │ │ ├── CheckStyleHealthDescriptor.java │ │ ├── CheckStyleMavenResult.java │ │ ├── CheckStyleMavenResultAction.java │ │ ├── CheckStylePlugin.java │ │ ├── CheckStyleProjectAction.java │ │ ├── CheckStylePublisher.java │ │ ├── CheckStyleReporter.java │ │ ├── CheckStyleReporterDescriptor.java │ │ ├── CheckStyleReporterResult.java │ │ ├── CheckStyleResult.java │ │ ├── CheckStyleResultAction.java │ │ ├── MavenCheckStyleResultAction.java │ │ ├── dashboard │ │ ├── WarningsNewVersusFixedGraphPortlet.java │ │ ├── WarningsPriorityGraphPortlet.java │ │ ├── WarningsTablePortlet.java │ │ ├── WarningsTotalsGraphPortlet.java │ │ └── WarningsUserGraphPortlet.java │ │ ├── parser │ │ ├── CheckStyle.java │ │ ├── CheckStyleParser.java │ │ ├── Error.java │ │ ├── File.java │ │ └── Warning.java │ │ ├── rules │ │ ├── CheckStyleRules.java │ │ ├── Rule.java │ │ ├── Topic.java │ │ └── TopicRule.java │ │ └── tokens │ │ ├── CheckStyleResultTokenMacro.java │ │ ├── CheckStyleWarningCountTokenMacro.java │ │ ├── FixedCheckStyleWarningsTokenMacro.java │ │ └── NewCheckStyleWarningsTokenMacro.java ├── resources │ ├── hudson │ │ └── plugins │ │ │ └── checkstyle │ │ │ ├── CheckStylePublisher │ │ │ ├── config.jelly │ │ │ ├── config.properties │ │ │ ├── config_de.properties │ │ │ ├── config_ja.properties │ │ │ └── global.jelly │ │ │ ├── CheckStyleReporter │ │ │ ├── config.jelly │ │ │ └── global.jelly │ │ │ ├── Messages.properties │ │ │ ├── Messages_de.properties │ │ │ ├── Messages_fr.properties │ │ │ ├── Messages_ja.properties │ │ │ ├── Messages_nl.properties │ │ │ ├── rules │ │ │ ├── config_annotation.xml │ │ │ ├── config_blocks.xml │ │ │ ├── config_coding.xml │ │ │ ├── config_design.xml │ │ │ ├── config_filefilters.xml │ │ │ ├── config_filters.xml │ │ │ ├── config_header.xml │ │ │ ├── config_imports.xml │ │ │ ├── config_javadoc.xml │ │ │ ├── config_metrics.xml │ │ │ ├── config_misc.xml │ │ │ ├── config_modifier.xml │ │ │ ├── config_naming.xml │ │ │ ├── config_regexp.xml │ │ │ ├── config_reporting.xml │ │ │ ├── config_sizes.xml │ │ │ └── config_whitespace.xml │ │ │ └── tokens │ │ │ ├── CheckStyleResultTokenMacro │ │ │ └── help.jelly │ │ │ ├── CheckStyleWarningCountTokenMacro │ │ │ └── help.jelly │ │ │ ├── FixedCheckStyleWarningsTokenMacro │ │ │ └── help.jelly │ │ │ └── NewCheckStyleWarningsTokenMacro │ │ │ └── help.jelly │ └── index.jelly └── webapp │ ├── help-m2.html │ ├── help-m2_de.html │ ├── help-m2_ja.html │ ├── help.html │ ├── help_de.html │ ├── help_ja.html │ └── icons │ ├── checkstyle-24x24.png │ └── checkstyle-48x48.png └── test ├── java └── hudson │ └── plugins │ └── checkstyle │ ├── CheckStyleHealthDescriptorTest.java │ ├── CheckStylePublisherTest.java │ ├── CheckstyleResultTest.java │ ├── CheckstyleWorkflowTest.java │ ├── parser │ ├── BugSerializeModelTest.java │ ├── CheckStyleParserTest.java │ └── WarningsDifferencerTest.java │ └── rules │ └── CheckStyleRulesTest.java └── resources └── hudson └── plugins └── checkstyle ├── parser ├── checkstyle-result-build1.xml ├── checkstyle-result-build2.xml ├── checkstyle-result-build3.xml ├── checkstyle-result-build4.xml ├── checkstyle.xml ├── issue19122.xml ├── issue25511.xml ├── project.ser ├── project.ser.xml └── scalastyle-output.xml ├── testXxe-oob.xml └── testXxe-xxe.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.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 | -------------------------------------------------------------------------------- /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). -------------------------------------------------------------------------------- /clean.sh: -------------------------------------------------------------------------------- 1 | rm -rf $JENKINS_HOME/plugins/checkstlye* 2 | 3 | mvn clean install 4 | cp -f target/*.hpi $JENKINS_HOME/plugins/ 5 | 6 | cd $JENKINS_HOME 7 | ./go.sh 8 | -------------------------------------------------------------------------------- /debug.sh: -------------------------------------------------------------------------------- 1 | export MAVEN_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n" 2 | rm -rf $JENKINS_HOME/plugins/checkstyle* 3 | mvn clean hpi:run 4 | -------------------------------------------------------------------------------- /german.sh: -------------------------------------------------------------------------------- 1 | mvn stapler:i18n -Dlocale=de 2 | 3 | -------------------------------------------------------------------------------- /go.sh: -------------------------------------------------------------------------------- 1 | rm -rf $JENKINS_HOME/plugins/checkstyle* 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 | checkstyle 12 | hpi 13 | Checkstyle Plug-in 14 | 4.0.1-SNAPSHOT 15 | http://wiki.jenkins-ci.org/x/GYCGAQ 16 | This plug-in generates the trend report for 17 | Checkstyle, an 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 | LGPL 27 | All icons are made by Carlitus (Carles Carbonell 28 | Bernado) and are under the LGPL. 29 | 30 | 31 | 32 | 33 | 34 | 35 | org.jvnet.hudson.plugins 36 | analysis-core 37 | 1.94 38 | 39 | 40 | org.jvnet.hudson.plugins 41 | analysis-test 42 | 1.20 43 | test 44 | 45 | 46 | 47 | 48 | scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git 49 | scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git 50 | https://github.com/jenkinsci/${project.artifactId}-plugin 51 | HEAD 52 | 53 | 54 | 55 | 56 | repo.jenkins-ci.org 57 | https://repo.jenkins-ci.org/public/ 58 | 59 | 60 | 61 | 62 | 63 | repo.jenkins-ci.org 64 | https://repo.jenkins-ci.org/public/ 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /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/checkstyle/CheckStyleAnnotationsAggregator.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle; 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 CheckStyleResultAction}s of {@link MatrixRun}s into 14 | * {@link MatrixBuild}. 15 | * 16 | * @author Ulli Hafner 17 | */ 18 | public class CheckStyleAnnotationsAggregator extends AnnotationsAggregator { 19 | /** 20 | * Creates a new instance of {@link CheckStyleAnnotationsAggregator}. 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 CheckStyleAnnotationsAggregator(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, final ParserResult aggregatedResult) { 48 | return new CheckStyleResultAction(build, healthDescriptor, 49 | new CheckStyleResult(build, defaultEncoding, aggregatedResult, 50 | usePreviousBuildAsReference(), useOnlyStableBuildsAsReference())); 51 | } 52 | 53 | @Override 54 | protected boolean hasResult(final MatrixRun run) { 55 | return getAction(run) != null; 56 | } 57 | 58 | @Override 59 | protected CheckStyleResult getResult(final MatrixRun run) { 60 | return getAction(run).getResult(); 61 | } 62 | 63 | private CheckStyleResultAction getAction(final MatrixRun run) { 64 | return run.getAction(CheckStyleResultAction.class); 65 | } 66 | } 67 | 68 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/CheckStyleColumn.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle; 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 CheckStyleColumn extends WarningsCountColumn { 17 | /** 18 | * Creates a new instance of {@link CheckStyleColumn}. 19 | */ 20 | @DataBoundConstructor 21 | public CheckStyleColumn() { // NOPMD: data binding 22 | super(); 23 | } 24 | 25 | @Override 26 | protected Class getProjectAction() { 27 | return CheckStyleProjectAction.class; 28 | } 29 | 30 | @Override 31 | public String getColumnCaption() { 32 | return Messages.Checkstyle_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.Checkstyle_Warnings_Column(); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/CheckStyleDescriptor.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle; 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 CheckStylePublisher}. 10 | * 11 | * @author Ulli Hafner 12 | */ 13 | @Extension(ordinal = 100) @Symbol("checkstyle") 14 | public final class CheckStyleDescriptor extends PluginDescriptor { 15 | /** The ID of this plug-in is used as URL. */ 16 | static final String PLUGIN_ID = "checkstyle"; 17 | /** The URL of the result action. */ 18 | static final String RESULT_URL = PluginDescriptor.createResultUrlName(PLUGIN_ID); 19 | /** Icons prefix. */ 20 | static final String ICON_URL_PREFIX = "/plugin/checkstyle/icons/"; 21 | /** Icon to use for the result and project action. */ 22 | static final String ICON_URL = ICON_URL_PREFIX + "checkstyle-24x24.png"; 23 | 24 | /** 25 | * Instantiates a new find bugs descriptor. 26 | */ 27 | public CheckStyleDescriptor() { 28 | super(CheckStylePublisher.class); 29 | } 30 | 31 | @Override 32 | public String getDisplayName() { 33 | return Messages.Checkstyle_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 ICON_URL_PREFIX + "checkstyle-48x48.png"; 49 | } 50 | } -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/CheckStyleHealthDescriptor.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle; 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 CheckStyle build results. 11 | * 12 | * @author Ulli Hafner 13 | */ 14 | public class CheckStyleHealthDescriptor extends AbstractHealthDescriptor { 15 | /** Unique ID of this class. */ 16 | private static final long serialVersionUID = -3404826986876607396L; 17 | 18 | /** 19 | * Creates a new instance of {@link CheckStyleHealthDescriptor} based on the 20 | * values of the specified descriptor. 21 | * 22 | * @param healthDescriptor the descriptor to copy the values from 23 | */ 24 | public CheckStyleHealthDescriptor(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._Checkstyle_ResultAction_HealthReportNoItem(); 32 | } 33 | else if (result.getNumberOfAnnotations() == 1) { 34 | return Messages._Checkstyle_ResultAction_HealthReportSingleItem(); 35 | } 36 | else { 37 | return Messages._Checkstyle_ResultAction_HealthReportMultipleItem(result.getNumberOfAnnotations()); 38 | } 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/CheckStyleMavenResult.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle; 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 Checkstyle analysis in m2 jobs. 10 | * 11 | * @author Ulli Hafner 12 | * @deprecated not used anymore 13 | */ 14 | @Deprecated 15 | public class CheckStyleMavenResult extends CheckStyleResult { 16 | /** Unique ID of this class. */ 17 | private static final long serialVersionUID = -4913938782537266259L; 18 | 19 | /** 20 | * Creates a new instance of {@link CheckStyleMavenResult}. 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 CheckStyleMavenResult(final AbstractBuild build, final String defaultEncoding, 31 | final ParserResult result) { 32 | super(build, defaultEncoding, result, false, false, MavenCheckStyleResultAction.class); 33 | } 34 | 35 | @SuppressWarnings("deprecation") 36 | @Override 37 | protected Class> getResultActionType() { 38 | return MavenCheckStyleResultAction.class; 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/CheckStyleMavenResultAction.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle; 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 CheckStyleResultAction} 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 CheckStyleMavenResultAction extends MavenResultAction { 25 | /** 26 | * Creates a new instance of {@link CheckStyleMavenResultAction}. 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 CheckStyleMavenResultAction(final AbstractBuild owner, final HealthDescriptor healthDescriptor, 38 | final String defaultEncoding, final CheckStyleResult result) { 39 | super(new CheckStyleResultAction(owner, healthDescriptor, result), defaultEncoding, "CHECKSTYLE"); 40 | } 41 | 42 | @Override 43 | public MavenAggregatedReport createAggregatedAction(final MavenModuleSetBuild build, final Map> moduleBuilds) { 44 | return new CheckStyleMavenResultAction(build, getHealthDescriptor(), getDefaultEncoding(), 45 | new CheckStyleResult(build, getDefaultEncoding(), new ParserResult(), 46 | usePreviousBuildAsStable(), useOnlyStableBuildsAsReference())); 47 | } 48 | 49 | @Override 50 | public Action getProjectAction(final MavenModuleSet moduleSet) { 51 | return new CheckStyleProjectAction(moduleSet, CheckStyleMavenResultAction.class); 52 | } 53 | 54 | @Override 55 | public Class> getIndividualActionType() { 56 | return CheckStyleMavenResultAction.class; 57 | } 58 | 59 | @Override 60 | protected CheckStyleResult createResult(final CheckStyleResult existingResult, final CheckStyleResult additionalResult) { 61 | return new CheckStyleReporterResult(getOwner(), additionalResult.getDefaultEncoding(), 62 | aggregate(existingResult, additionalResult), 63 | existingResult.usePreviousBuildAsStable(), 64 | existingResult.useOnlyStableBuildsAsReference()); 65 | } 66 | } 67 | 68 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/CheckStylePlugin.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle; 2 | 3 | import hudson.Plugin; 4 | import hudson.plugins.checkstyle.rules.CheckStyleRules; 5 | 6 | /** 7 | * Initializes the Checkstyle messages and descriptions. 8 | * 9 | * @author Ulli Hafner 10 | */ 11 | public class CheckStylePlugin extends Plugin { 12 | @Override 13 | public void start() { 14 | CheckStyleRules.getInstance().initialize(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/CheckStyleProjectAction.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle; 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 Checkstyle trend graph in the project screen. 9 | * Drawing of the graph is delegated to the associated {@link ResultAction}. 10 | * 11 | * @author Ulli Hafner 12 | */ 13 | public class CheckStyleProjectAction extends AbstractProjectAction> { 14 | /** 15 | * Instantiates a new {@link CheckStyleProjectAction}. 16 | * 17 | * @param job 18 | * the job that owns this action 19 | */ 20 | public CheckStyleProjectAction(final Job job) { 21 | this(job, CheckStyleResultAction.class); 22 | } 23 | 24 | /** 25 | * Instantiates a new {@link CheckStyleProjectAction}. 26 | * 27 | * @param job 28 | * the job that owns this action 29 | * @param type 30 | * the result action type 31 | */ 32 | public CheckStyleProjectAction(final Job job, 33 | final Class> type) { 34 | super(job, type, Messages._Checkstyle_ProjectAction_Name(), Messages._Checkstyle_Trend_Name(), 35 | CheckStyleDescriptor.PLUGIN_ID, CheckStyleDescriptor.ICON_URL, CheckStyleDescriptor.RESULT_URL); 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/CheckStylePublisher.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle; 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.checkstyle.parser.CheckStyleParser; 25 | 26 | /** 27 | * Publishes the results of the Checkstyle analysis (freestyle project type). 28 | * 29 | * @author Ulli Hafner 30 | */ 31 | public class CheckStylePublisher extends HealthAwarePublisher { 32 | /** Unique ID of this class. */ 33 | private static final long serialVersionUID = 6369581633551160418L; 34 | 35 | private static final String PLUGIN_NAME = "CHECKSTYLE"; 36 | 37 | /** Default Checkstyle pattern. */ 38 | private static final String DEFAULT_PATTERN = "**/checkstyle-result.xml"; 39 | /** Ant file-set pattern of files to work with. */ 40 | private String pattern; 41 | 42 | /** 43 | * Constructor used from methods like {@link StaplerRequest#bindJSON(Class, JSONObject)} and 44 | * {@link StaplerRequest#bindParameters(Class, String)}. 45 | */ 46 | @DataBoundConstructor 47 | public CheckStylePublisher() { 48 | super(PLUGIN_NAME); 49 | } 50 | 51 | /** 52 | * Returns the Ant file-set pattern of files to work with. 53 | * 54 | * @return Ant file-set pattern of files to work with 55 | */ 56 | public String getPattern() { 57 | return pattern; 58 | } 59 | 60 | /** 61 | * Sets the Ant file-set pattern of files to work with. 62 | */ 63 | @DataBoundSetter 64 | public void setPattern(final String pattern) { 65 | this.pattern = pattern; 66 | } 67 | 68 | @Override 69 | public BuildResult perform(final Run build, final FilePath workspace, final PluginLogger logger) throws 70 | InterruptedException, IOException { 71 | logger.log("Collecting checkstyle analysis files..."); 72 | 73 | FilesParser parser = new FilesParser(PLUGIN_NAME, 74 | StringUtils.defaultIfEmpty(expandFilePattern(getPattern(), build.getEnvironment(TaskListener.NULL)), DEFAULT_PATTERN), 75 | new CheckStyleParser(getDefaultEncoding()), 76 | shouldDetectModules(), isMavenBuild(build)); 77 | 78 | ParserResult project = workspace.act(parser); 79 | logger.logLines(project.getLogMessages()); 80 | 81 | blame(project.getAnnotations(), build, workspace); 82 | 83 | CheckStyleResult result = new CheckStyleResult(build, getDefaultEncoding(), project, 84 | usePreviousBuildAsReference(), useOnlyStableBuildsAsReference()); 85 | build.addAction(new CheckStyleResultAction(build, this, result)); 86 | 87 | return result; 88 | } 89 | 90 | @Override 91 | public CheckStyleDescriptor getDescriptor() { 92 | return (CheckStyleDescriptor)super.getDescriptor(); 93 | } 94 | 95 | @Override 96 | public MatrixAggregator createAggregator(final MatrixBuild build, final Launcher launcher, 97 | final BuildListener listener) { 98 | return new CheckStyleAnnotationsAggregator(build, launcher, listener, this, getDefaultEncoding(), 99 | usePreviousBuildAsReference(), useOnlyStableBuildsAsReference()); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/CheckStyleReporter.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle; 2 | 3 | import java.io.IOException; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import org.apache.commons.lang.StringUtils; 8 | import org.apache.maven.project.MavenProject; 9 | import org.codehaus.plexus.component.configurator.ComponentConfigurationException; 10 | import org.kohsuke.stapler.DataBoundConstructor; 11 | 12 | import hudson.FilePath; 13 | import hudson.maven.MavenAggregatedReport; 14 | import hudson.maven.MavenBuildProxy; 15 | import hudson.maven.MojoInfo; 16 | import hudson.maven.MavenBuild; 17 | import hudson.maven.MavenModule; 18 | 19 | import hudson.plugins.analysis.core.FilesParser; 20 | import hudson.plugins.analysis.core.HealthAwareReporter; 21 | import hudson.plugins.analysis.core.ParserResult; 22 | import hudson.plugins.analysis.util.PluginLogger; 23 | import hudson.plugins.checkstyle.parser.CheckStyleParser; 24 | 25 | import hudson.remoting.VirtualChannel; 26 | 27 | /** 28 | * Publishes the results of the Checkstyle analysis (maven 2 project type). 29 | * 30 | * @author Ulli Hafner 31 | */ 32 | public class CheckStyleReporter extends HealthAwareReporter { 33 | /** Unique identifier of this class. */ 34 | private static final long serialVersionUID = 2272875032054063496L; 35 | 36 | private static final String PLUGIN_NAME = "CHECKSTYLE"; 37 | 38 | /** Default Checkstyle pattern. */ 39 | private static final String CHECKSTYLE_XML_FILE = "checkstyle-result.xml"; 40 | 41 | /** 42 | * Creates a new instance of CheckStyleReporter. 43 | * 44 | * @param healthy 45 | * Report health as 100% when the number of warnings is less than 46 | * this value 47 | * @param unHealthy 48 | * Report health as 0% when the number of warnings is greater 49 | * than this value 50 | * @param thresholdLimit 51 | * determines which warning priorities should be considered when 52 | * evaluating the build stability and health 53 | * @param useDeltaValues 54 | * determines whether the absolute annotations delta or the 55 | * actual annotations set difference should be used to evaluate 56 | * the build stability 57 | * @param unstableTotalAll 58 | * annotation threshold 59 | * @param unstableTotalHigh 60 | * annotation threshold 61 | * @param unstableTotalNormal 62 | * annotation threshold 63 | * @param unstableTotalLow 64 | * annotation threshold 65 | * @param unstableNewAll 66 | * annotation threshold 67 | * @param unstableNewHigh 68 | * annotation threshold 69 | * @param unstableNewNormal 70 | * annotation threshold 71 | * @param unstableNewLow 72 | * annotation threshold 73 | * @param failedTotalAll 74 | * annotation threshold 75 | * @param failedTotalHigh 76 | * annotation threshold 77 | * @param failedTotalNormal 78 | * annotation threshold 79 | * @param failedTotalLow 80 | * annotation threshold 81 | * @param failedNewAll 82 | * annotation threshold 83 | * @param failedNewHigh 84 | * annotation threshold 85 | * @param failedNewNormal 86 | * annotation threshold 87 | * @param failedNewLow 88 | * annotation threshold 89 | * @param canRunOnFailed 90 | * determines whether the plug-in can run for failed builds, too 91 | * @param usePreviousBuildAsReference 92 | * determines whether to always use the previous build as the reference build 93 | * @param useStableBuildAsReference 94 | * determines whether only stable builds should be used as reference builds or not 95 | * @param canComputeNew 96 | * determines whether new warnings should be computed (with 97 | * respect to baseline) 98 | */ 99 | // CHECKSTYLE:OFF 100 | @SuppressWarnings("PMD.ExcessiveParameterList") 101 | @DataBoundConstructor 102 | public CheckStyleReporter(final String healthy, final String unHealthy, final String thresholdLimit, final boolean useDeltaValues, 103 | final String unstableTotalAll, final String unstableTotalHigh, final String unstableTotalNormal, final String unstableTotalLow, 104 | final String unstableNewAll, final String unstableNewHigh, final String unstableNewNormal, final String unstableNewLow, 105 | final String failedTotalAll, final String failedTotalHigh, final String failedTotalNormal, final String failedTotalLow, 106 | final String failedNewAll, final String failedNewHigh, final String failedNewNormal, final String failedNewLow, 107 | final boolean canRunOnFailed, final boolean usePreviousBuildAsReference, 108 | final boolean useStableBuildAsReference, final boolean canComputeNew) { 109 | super(healthy, unHealthy, thresholdLimit, useDeltaValues, 110 | unstableTotalAll, unstableTotalHigh, unstableTotalNormal, unstableTotalLow, 111 | unstableNewAll, unstableNewHigh, unstableNewNormal, unstableNewLow, 112 | failedTotalAll, failedTotalHigh, failedTotalNormal, failedTotalLow, 113 | failedNewAll, failedNewHigh, failedNewNormal, failedNewLow, 114 | canRunOnFailed, usePreviousBuildAsReference, useStableBuildAsReference, canComputeNew, PLUGIN_NAME); 115 | } 116 | // CHECKSTYLE:ON 117 | 118 | @Override 119 | protected boolean acceptGoal(final String goal) { 120 | return "checkstyle".equals(goal) || "check".equals(goal) || "site".equals(goal); 121 | } 122 | 123 | @Override 124 | public ParserResult perform(final MavenBuildProxy build, final MavenProject pom, 125 | final MojoInfo mojo, final PluginLogger logger) throws InterruptedException, IOException { 126 | FilesParser checkstyleCollector = new FilesParser(PLUGIN_NAME, 127 | new CheckStyleParser(getDefaultEncoding()), getModuleName(pom)); 128 | 129 | return getFileName(mojo, pom).act(checkstyleCollector); 130 | } 131 | 132 | private FilePath getFileName(final MojoInfo mojo, final MavenProject pom) { 133 | try { 134 | String configurationValue = mojo.getConfigurationValue("outputFile", String.class); 135 | if (StringUtils.isNotBlank(configurationValue)) { 136 | return new FilePath((VirtualChannel)null, configurationValue); 137 | } 138 | } 139 | catch (ComponentConfigurationException exception) { 140 | // ignore and use fall back value 141 | } 142 | return getTargetPath(pom).child(CHECKSTYLE_XML_FILE); 143 | } 144 | 145 | @Override 146 | protected CheckStyleResult createResult(final MavenBuild build, final ParserResult project) { 147 | return new CheckStyleReporterResult(build, getDefaultEncoding(), project, 148 | usePreviousBuildAsReference(), useOnlyStableBuildsAsReference()); 149 | } 150 | 151 | @Override 152 | protected MavenAggregatedReport createMavenAggregatedReport(final MavenBuild build, final CheckStyleResult result) { 153 | return new CheckStyleMavenResultAction(build, this, getDefaultEncoding(), result); 154 | } 155 | 156 | @Override 157 | public List getProjectActions(final MavenModule module) { 158 | return Collections.singletonList(new CheckStyleProjectAction(module, getResultActionClass())); 159 | } 160 | 161 | @Override 162 | protected Class getResultActionClass() { 163 | return CheckStyleMavenResultAction.class; 164 | } 165 | } 166 | 167 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/CheckStyleReporterDescriptor.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle; 2 | 3 | import hudson.Extension; 4 | import hudson.plugins.analysis.core.ReporterDescriptor; 5 | 6 | /** 7 | * Descriptor for the class {@link CheckStyleReporter}. 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 CheckStyleReporterDescriptor extends ReporterDescriptor { 14 | /** 15 | * Creates a new instance of CheckStyleReporterDescriptor. 16 | */ 17 | public CheckStyleReporterDescriptor() { 18 | super(CheckStyleReporter.class, new CheckStyleDescriptor()); 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/CheckStyleReporterResult.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle; 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 Checkstyle analysis in m2 jobs. 10 | * 11 | * @author Ulli Hafner 12 | */ 13 | public class CheckStyleReporterResult extends CheckStyleResult { 14 | private static final long serialVersionUID = 6414012312137436141L; 15 | 16 | /** 17 | * Creates a new instance of {@link CheckStyleReporterResult}. 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 CheckStyleReporterResult(final Run build, final String defaultEncoding, final ParserResult result, 33 | final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference) { 34 | super(build, defaultEncoding, result, usePreviousBuildAsReference, useStableBuildAsReference, 35 | CheckStyleMavenResultAction.class); 36 | } 37 | 38 | @Override 39 | protected Class> getResultActionType() { 40 | return CheckStyleMavenResultAction.class; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/CheckStyleResult.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle; 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.checkstyle.parser.Warning; 11 | 12 | /** 13 | * Represents the results of the Checkstyle analysis. One instance of this class 14 | * is persisted for each build via an XML file. 15 | * 16 | * @author Ulli Hafner 17 | */ 18 | public class CheckStyleResult extends BuildResult { 19 | private static final long serialVersionUID = 2768250056765266658L; 20 | 21 | /** 22 | * Creates a new instance of {@link CheckStyleResult}. 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 CheckStyleResult(final Run build, final String defaultEncoding, final ParserResult result, 38 | final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference) { 39 | this(build, defaultEncoding, result, usePreviousBuildAsReference, useStableBuildAsReference, 40 | CheckStyleResultAction.class); 41 | } 42 | 43 | /** 44 | * Creates a new instance of {@link CheckStyleResult}. 45 | * 46 | * @param build 47 | * the current build as owner of this action 48 | * @param defaultEncoding 49 | * the default encoding to be used when reading and parsing files 50 | * @param result 51 | * the parsed result with all annotations 52 | * @param useStableBuildAsReference 53 | * determines whether only stable builds should be used as 54 | * reference builds or not 55 | * @param actionType 56 | * the type of the result action 57 | */ 58 | protected CheckStyleResult(final Run build, final String defaultEncoding, final ParserResult result, 59 | final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference, 60 | final Class> actionType) { 61 | this(build, new BuildHistory(build, actionType, usePreviousBuildAsReference, useStableBuildAsReference), 62 | result, defaultEncoding, true); 63 | } 64 | 65 | CheckStyleResult(final Run build, final BuildHistory history, 66 | final ParserResult result, final String defaultEncoding, final boolean canSerialize) { 67 | super(build, history, result, defaultEncoding); 68 | 69 | if (canSerialize) { 70 | serializeAnnotations(result.getAnnotations()); 71 | } 72 | } 73 | 74 | @Override 75 | public String getHeader() { 76 | return Messages.Checkstyle_ResultAction_Header(); 77 | } 78 | 79 | @Override 80 | protected void configure(final XStream xstream) { 81 | xstream.alias("warning", Warning.class); 82 | } 83 | 84 | @Override 85 | public String getSummary() { 86 | return "Checkstyle: " + createDefaultSummary(CheckStyleDescriptor.RESULT_URL, getNumberOfAnnotations(), getNumberOfModules()); 87 | } 88 | 89 | @Override 90 | protected String createDeltaMessage() { 91 | return createDefaultDeltaMessage(CheckStyleDescriptor.RESULT_URL, getNumberOfNewWarnings(), getNumberOfFixedWarnings()); 92 | } 93 | 94 | /** 95 | * Returns the name of the file to store the serialized annotations. 96 | * 97 | * @return the name of the file to store the serialized annotations 98 | */ 99 | @Override 100 | protected String getSerializationFileName() { 101 | return "checkstyle-warnings.xml"; 102 | } 103 | 104 | @Override 105 | public String getDisplayName() { 106 | return Messages.Checkstyle_ProjectAction_Name(); 107 | } 108 | 109 | @Override 110 | protected Class> getResultActionType() { 111 | return CheckStyleResultAction.class; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/CheckStyleResultAction.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle; 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 Checkstyle results. This action persists the 13 | * results of the Checkstyle 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 Checkstyle result trend. 18 | *

19 | * 20 | * @author Ulli Hafner 21 | */ 22 | public class CheckStyleResultAction extends AbstractResultAction { 23 | /** 24 | * Creates a new instance of CheckStyleResultAction. 25 | * 26 | * @param owner 27 | * the associated run of this action 28 | * @param healthDescriptor 29 | * health descriptor 30 | * @param result 31 | * the result in this build 32 | */ 33 | public CheckStyleResultAction(final Run owner, final HealthDescriptor healthDescriptor, 34 | final CheckStyleResult result) { 35 | super(owner, new CheckStyleHealthDescriptor(healthDescriptor), result); 36 | } 37 | 38 | @Override 39 | public String getDisplayName() { 40 | return Messages.Checkstyle_ProjectAction_Name(); 41 | } 42 | 43 | @Override 44 | protected PluginDescriptor getDescriptor() { 45 | return new CheckStyleDescriptor(); 46 | } 47 | 48 | @Override 49 | public Collection getProjectActions() { 50 | return asSet(new CheckStyleProjectAction(getJob())); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/MavenCheckStyleResultAction.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle; 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 CheckStyleResultAction} 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 MavenCheckStyleResultAction extends CheckStyleResultAction 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 MavenCheckStyleResultAction. 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 | */ 43 | public MavenCheckStyleResultAction(final AbstractBuild owner, final HealthDescriptor healthDescriptor, 44 | final String defaultEncoding) { 45 | super(owner, healthDescriptor, new CheckStyleResult(owner, defaultEncoding, new ParserResult(), false, false)); 46 | this.defaultEncoding = defaultEncoding; 47 | } 48 | 49 | /** 50 | * Creates a new instance of MavenCheckStyleResultAction. 51 | * 52 | * @param owner 53 | * the associated build of this action 54 | * @param healthDescriptor 55 | * health descriptor to use 56 | * @param result 57 | * the result in this build 58 | * @param defaultEncoding 59 | * the default encoding to be used when reading and parsing files 60 | */ 61 | public MavenCheckStyleResultAction(final AbstractBuild owner, final HealthDescriptor healthDescriptor, 62 | final String defaultEncoding, final CheckStyleResult result) { 63 | super(owner, healthDescriptor, result); 64 | this.defaultEncoding = defaultEncoding; 65 | } 66 | 67 | @Override 68 | public MavenAggregatedReport createAggregatedAction(final MavenModuleSetBuild build, final Map> moduleBuilds) { 69 | return new MavenCheckStyleResultAction(build, getHealthDescriptor(), defaultEncoding); 70 | } 71 | 72 | @Override 73 | public Action getProjectAction(final MavenModuleSet moduleSet) { 74 | return new CheckStyleProjectAction(moduleSet); 75 | } 76 | 77 | @Override 78 | public Class getIndividualActionType() { 79 | return getClass(); 80 | } 81 | 82 | /** 83 | * Called whenever a new module build is completed, to update the aggregated 84 | * report. When multiple builds complete simultaneously, Jenkins serializes 85 | * the execution of this method, so this method needs not be 86 | * concurrency-safe. 87 | * 88 | * @param moduleBuilds 89 | * Same as MavenModuleSet.getModuleBuilds() but provided 90 | * for convenience and efficiency. 91 | * @param newBuild 92 | * Newly completed build. 93 | */ 94 | @Override 95 | public void update(final Map> moduleBuilds, final MavenBuild newBuild) { 96 | // not used anymore 97 | } 98 | 99 | /** Backward compatibility. @deprecated */ 100 | @SuppressWarnings("PMD") 101 | @SuppressFBWarnings("") 102 | @Deprecated 103 | private transient String height; 104 | } -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/dashboard/WarningsNewVersusFixedGraphPortlet.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle.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.checkstyle.CheckStyleProjectAction; 10 | import hudson.plugins.checkstyle.Messages; 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 CheckStyleProjectAction.class; 43 | } 44 | 45 | @Override 46 | protected String getPluginName() { 47 | return "checkstyle"; 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/checkstyle/dashboard/WarningsPriorityGraphPortlet.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle.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.checkstyle.CheckStyleProjectAction; 10 | import hudson.plugins.checkstyle.Messages; 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 CheckStyleProjectAction.class; 43 | } 44 | 45 | @Override 46 | protected String getPluginName() { 47 | return "checkstyle"; 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/checkstyle/dashboard/WarningsTablePortlet.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle.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.checkstyle.CheckStyleProjectAction; 8 | import hudson.plugins.checkstyle.Messages; 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 CheckStyleProjectAction.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/checkstyle/dashboard/WarningsTotalsGraphPortlet.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle.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.checkstyle.CheckStyleProjectAction; 10 | import hudson.plugins.checkstyle.Messages; 11 | import hudson.plugins.view.dashboard.DashboardPortlet; 12 | 13 | import org.kohsuke.stapler.DataBoundConstructor; 14 | 15 | /** 16 | * A portlet that shows the warnings totals trend graph. 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 CheckStyleProjectAction.class; 43 | } 44 | 45 | @Override 46 | protected String getPluginName() { 47 | return "checkstyle"; 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/checkstyle/dashboard/WarningsUserGraphPortlet.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle.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.checkstyle.CheckStyleProjectAction; 12 | import hudson.plugins.checkstyle.Messages; 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 CheckStyleProjectAction.class; 43 | } 44 | 45 | @Override 46 | protected String getPluginName() { 47 | return "checkstyle"; 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/checkstyle/parser/CheckStyle.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle.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 errors collection of the Checkstyle format. 10 | * 11 | * @author Ulli Hafner 12 | */ 13 | public class CheckStyle { 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/checkstyle/parser/CheckStyleParser.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle.parser; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.io.InputStreamReader; 6 | import java.lang.reflect.InvocationTargetException; 7 | import java.util.ArrayList; 8 | import java.util.Collection; 9 | 10 | import org.apache.commons.lang.StringUtils; 11 | import org.xml.sax.SAXException; 12 | 13 | import hudson.plugins.analysis.core.AbstractAnnotationParser; 14 | import hudson.plugins.analysis.util.PackageDetectors; 15 | import hudson.plugins.analysis.util.SecureDigester; 16 | import hudson.plugins.analysis.util.model.FileAnnotation; 17 | import hudson.plugins.analysis.util.model.Priority; 18 | 19 | /** 20 | * A parser for Checkstyle XML files. 21 | * 22 | * @author Ulli Hafner 23 | */ 24 | public class CheckStyleParser extends AbstractAnnotationParser { 25 | /** Unique identifier of this class. */ 26 | private static final long serialVersionUID = -8705621875291182458L; 27 | 28 | /** 29 | * Creates a new instance of {@link CheckStyleParser}. 30 | */ 31 | public CheckStyleParser() { 32 | super(StringUtils.EMPTY); 33 | } 34 | 35 | /** 36 | * Creates a new instance of {@link CheckStyleParser}. 37 | * 38 | * @param defaultEncoding 39 | * the default encoding to be used when reading and parsing files 40 | */ 41 | public CheckStyleParser(final String defaultEncoding) { 42 | super(defaultEncoding); 43 | } 44 | 45 | @Override 46 | public Collection parse(final InputStream file, final String moduleName) throws InvocationTargetException { 47 | try { 48 | SecureDigester digester = new SecureDigester(CheckStyleParser.class); 49 | 50 | String rootXPath = "checkstyle"; 51 | digester.addObjectCreate(rootXPath, CheckStyle.class); 52 | digester.addSetProperties(rootXPath); 53 | 54 | String fileXPath = "checkstyle/file"; 55 | digester.addObjectCreate(fileXPath, hudson.plugins.checkstyle.parser.File.class); 56 | digester.addSetProperties(fileXPath); 57 | digester.addSetNext(fileXPath, "addFile", hudson.plugins.checkstyle.parser.File.class.getName()); 58 | 59 | String bugXPath = "checkstyle/file/error"; 60 | digester.addObjectCreate(bugXPath, Error.class); 61 | digester.addSetProperties(bugXPath); 62 | digester.addSetNext(bugXPath, "addError", Error.class.getName()); 63 | 64 | CheckStyle module; 65 | module = (CheckStyle)digester.parse(new InputStreamReader(file, "UTF-8")); 66 | if (module == null) { 67 | throw new SAXException("Input stream is not a Checkstyle file."); 68 | } 69 | 70 | return convert(module, moduleName); 71 | } 72 | catch (IOException exception) { 73 | throw new InvocationTargetException(exception); 74 | } 75 | catch (SAXException exception) { 76 | throw new InvocationTargetException(exception); 77 | } 78 | } 79 | 80 | /** 81 | * Converts the internal structure to the annotations API. 82 | * 83 | * @param collection 84 | * the internal maven module 85 | * @param moduleName 86 | * name of the maven module 87 | * @return a maven module of the annotations API 88 | */ 89 | private Collection convert(final CheckStyle collection, final String moduleName) { 90 | ArrayList annotations = new ArrayList(); 91 | 92 | for (hudson.plugins.checkstyle.parser.File file : collection.getFiles()) { 93 | if (isValidWarning(file)) { 94 | String packageName = PackageDetectors.detectPackageName(file.getName()); 95 | for (Error error : file.getErrors()) { 96 | Priority priority; 97 | if ("error".equalsIgnoreCase(error.getSeverity())) { 98 | priority = Priority.HIGH; 99 | } 100 | else if ("warning".equalsIgnoreCase(error.getSeverity())) { 101 | priority = Priority.NORMAL; 102 | } 103 | else if ("info".equalsIgnoreCase(error.getSeverity())) { 104 | priority = Priority.LOW; 105 | } 106 | else { 107 | continue; // ignore 108 | } 109 | String source = error.getSource(); 110 | String type = StringUtils.substringAfterLast(source, "."); 111 | String category = StringUtils.substringAfterLast(StringUtils.substringBeforeLast(source, "."), "."); 112 | 113 | Warning warning = new Warning(priority, error.getMessage(), StringUtils.capitalize(category), 114 | type, error.getLine(), error.getLine()); 115 | warning.setModuleName(moduleName); 116 | warning.setFileName(file.getName()); 117 | warning.setPackageName(packageName); 118 | warning.setColumnPosition(error.getColumn()); 119 | warning.setContextHashCode(createContextHashCode(file.getName(), error.getLine(), type)); 120 | annotations.add(warning); 121 | } 122 | } 123 | } 124 | return annotations; 125 | } 126 | 127 | /** 128 | * Returns true if this warning is valid or false 129 | * if the warning can't be processed by the checkstyle plug-in. 130 | * 131 | * @param file the file to check 132 | * @return true if this warning is valid 133 | */ 134 | private boolean isValidWarning(final hudson.plugins.checkstyle.parser.File file) { 135 | return !file.getName().endsWith("package.html"); 136 | } 137 | } 138 | 139 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/parser/Error.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle.parser; 2 | 3 | /** 4 | * Java Bean class for a violation of the Checkstyle format. 5 | * 6 | * @author Ulli Hafner 7 | */ 8 | // CHECKSTYLE:OFF 9 | @SuppressWarnings("javadoc") 10 | public class Error { 11 | private String source; 12 | private String severity; 13 | private String message; 14 | private int line; 15 | private int column; 16 | 17 | public int getColumn() { 18 | return column; 19 | } 20 | 21 | public void setColumn(final int column) { 22 | this.column = column; 23 | } 24 | 25 | public String getSource() { 26 | return source; 27 | } 28 | 29 | public void setSource(final String source) { 30 | this.source = source; 31 | } 32 | 33 | public String getSeverity() { 34 | return severity; 35 | } 36 | 37 | public void setSeverity(final String severity) { 38 | this.severity = severity; 39 | } 40 | 41 | public String getMessage() { 42 | return message; 43 | } 44 | 45 | public void setMessage(final String message) { 46 | this.message = message; 47 | } 48 | 49 | public int getLine() { 50 | return line; 51 | } 52 | 53 | public void setLine(final int line) { 54 | this.line = line; 55 | } 56 | } 57 | 58 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/parser/File.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle.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 Checkstyle format. 10 | * 11 | * @author Ulli Hafner 12 | */ 13 | public class File { 14 | /** Name of the file. */ 15 | private String name; 16 | /** All errors of this file. */ 17 | private final List errors = new ArrayList(); 18 | 19 | /** 20 | * Adds a new violation to this file. 21 | * 22 | * @param violation 23 | * the new violation 24 | */ 25 | public void addError(final Error violation) { 26 | errors.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 getErrors() { 36 | return Collections.unmodifiableCollection(errors); 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/checkstyle/parser/Warning.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle.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 | import hudson.plugins.checkstyle.rules.CheckStyleRules; 10 | 11 | /** 12 | * A serializable Java Bean class representing a warning. 13 | *

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

16 | * 17 | * @author Ulli Hafner 18 | */ 19 | public class Warning extends AbstractAnnotation { 20 | /** Unique identifier of this class. */ 21 | private static final long serialVersionUID = 5171661552905752370L; 22 | /** Origin of the annotation. */ 23 | public static final String ORIGIN = "checkstyle"; 24 | 25 | /** 26 | * Creates a new instance of {@link Warning}. 27 | * 28 | * @param priority 29 | * the priority 30 | * @param message 31 | * the message of the warning 32 | * @param category 33 | * the warning category 34 | * @param type 35 | * the identifier of the warning type 36 | * @param start 37 | * the first line of the line range 38 | * @param end 39 | * the last line of the line range 40 | */ 41 | public Warning(final Priority priority, final String message, final String category, final String type, 42 | final int start, final int end) { 43 | super(priority, message, start, end, category, type); 44 | setOrigin(ORIGIN); 45 | } 46 | 47 | /** 48 | * Creates a new instance of {@link Warning}. 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 Warning(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 CheckStyleRules.getInstance().getDescription(getType()); 68 | } 69 | 70 | /** Not used anymore. @deprecated */ 71 | @SuppressWarnings("all") 72 | @SuppressFBWarnings("") 73 | @Deprecated 74 | private final transient String tooltip = StringUtils.EMPTY; // backward compatibility NOPMD 75 | } 76 | 77 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/rules/CheckStyleRules.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle.rules; 2 | 3 | import javax.xml.parsers.ParserConfigurationException; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.util.ArrayList; 7 | import java.util.Collection; 8 | import java.util.Collections; 9 | import java.util.HashMap; 10 | import java.util.List; 11 | import java.util.Map; 12 | import java.util.logging.Level; 13 | import java.util.logging.Logger; 14 | 15 | import org.apache.commons.lang.StringUtils; 16 | import org.xml.sax.SAXException; 17 | 18 | import hudson.plugins.analysis.util.SecureDigester; 19 | 20 | /** 21 | * Reads the meta data of the Checkstyle rules from the DocBook files of the Checkstyle distribution. 22 | * 23 | * @author Ulli Hafner 24 | */ 25 | public final class CheckStyleRules { 26 | /** Mapping of rule names to rules. */ 27 | private final Map rulesByName = new HashMap(); 28 | /** Singleton instance. */ 29 | private static final CheckStyleRules INSTANCE = new CheckStyleRules(); 30 | 31 | /** 32 | * Returns the singleton instance. 33 | * 34 | * @return the singleton instance 35 | */ 36 | public static CheckStyleRules getInstance() { 37 | return INSTANCE; 38 | } 39 | 40 | /** 41 | * Creates the singleton instance. 42 | */ 43 | private CheckStyleRules() { 44 | // prevents instantiation 45 | } 46 | 47 | /** 48 | * Initializes the rules. 49 | */ 50 | public void initialize() { 51 | try { 52 | String[] ruleFiles = new String[] {"annotation", "blocks", "coding", "design", "filters", "header", 53 | "imports", "javadoc", "metrics", "misc", "modifier", "naming", "regexp", "reporting", 54 | "sizes", "whitespace"}; 55 | for (int i = 0; i < ruleFiles.length; i++) { 56 | String ruleFile = ruleFiles[i]; 57 | InputStream inputStream = CheckStyleRules.class.getResourceAsStream("config_" + ruleFile + ".xml"); 58 | SecureDigester digester = createDigester(); 59 | List rules = new ArrayList(); 60 | digester.push(rules); 61 | digester.parse(inputStream); 62 | for (Rule rule : rules) { 63 | if (StringUtils.isNotBlank(rule.getDescription())) { 64 | rulesByName.put(rule.getName(), rule); 65 | } 66 | } 67 | } 68 | } 69 | catch (ParserConfigurationException exception) { 70 | log(exception); 71 | } 72 | catch (IOException exception) { 73 | log(exception); 74 | } 75 | catch (SAXException exception) { 76 | log(exception); 77 | } 78 | } 79 | 80 | private void log(final Throwable exception) { 81 | Logger.getLogger(CheckStyleRules.class.getName()).log(Level.SEVERE, "Can't initialize CheckStyle rules.", exception); 82 | } 83 | 84 | /** 85 | * Creates a new digester. 86 | * 87 | * @return the new digester. 88 | * @throws ParserConfigurationException 89 | * if digester is not configured properly 90 | */ 91 | private SecureDigester createDigester() throws ParserConfigurationException { 92 | SecureDigester digester = new SecureDigester(CheckStyleRules.class); 93 | 94 | String section = "*/section"; 95 | digester.addObjectCreate(section, Rule.class); 96 | digester.addSetProperties(section); 97 | digester.addSetNext(section, "add"); 98 | 99 | String subSection = "*/section/subsection"; 100 | digester.addObjectCreate(subSection, Topic.class); 101 | digester.addSetProperties(subSection); 102 | digester.addSetNext(subSection, "setDescription"); 103 | digester.addRule(subSection, new TopicRule()); 104 | return digester; 105 | } 106 | 107 | /** 108 | * Returns all Checkstyle rules. 109 | * 110 | * @return all Checkstyle rules 111 | */ 112 | public Collection getRules() { 113 | return Collections.unmodifiableCollection(rulesByName.values()); 114 | } 115 | 116 | /** 117 | * Returns the Checkstyle rule with the specified name. 118 | * 119 | * @param name the name of the rule 120 | * @return the Checkstyle rule with the specified name. 121 | */ 122 | public Rule getRule(final String name) { 123 | Rule rule = rulesByName.get(name); 124 | if (rule == null) { 125 | rule = rulesByName.get(StringUtils.removeEnd(name, "Check")); 126 | } 127 | if (rule == null) { 128 | return new Rule(name); 129 | } 130 | return rule; 131 | } 132 | 133 | /** 134 | * Returns the description of the Checkstyle rule with the specified name. 135 | * 136 | * @param name the name of the rule 137 | * @return the description for the specified rule . 138 | */ 139 | public String getDescription(final String name) { 140 | return getRule(name).getDescription(); 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/rules/Rule.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle.rules; 2 | 3 | import org.apache.commons.lang.StringUtils; 4 | 5 | /** 6 | * Java Bean class representing a Checkstyle rule. 7 | * 8 | * @author Ulli Hafner 9 | */ 10 | public class Rule { 11 | /** Description to indicate that the rules stored in this plug-in don't match with the generators version. */ 12 | static final String UNDEFINED_DESCRIPTION = StringUtils.EMPTY; 13 | /** The name of the subsection that defines a description in the docbook files. */ 14 | private static final String DESCRIPTION_SUBSECTION_NAME = "Description"; 15 | /** The name of this rule. */ 16 | private String name; 17 | /** The description of this rule. */ 18 | private String description; 19 | 20 | /** 21 | * Instantiates a new rule. 22 | */ 23 | public Rule() { 24 | // nothing to do 25 | } 26 | 27 | /** 28 | * Instantiates a new rule. 29 | * 30 | * @param name the name of the rule 31 | */ 32 | public Rule(final String name) { 33 | this.name = name; 34 | description = UNDEFINED_DESCRIPTION; 35 | } 36 | 37 | /** 38 | * Returns the name of this rule. 39 | * 40 | * @return the name 41 | */ 42 | public String getName() { 43 | return name; 44 | } 45 | 46 | /** 47 | * Sets the name of this rule. 48 | * 49 | * @param name the name 50 | */ 51 | public void setName(final String name) { 52 | this.name = name; 53 | } 54 | 55 | /** 56 | * Returns the description of this rule. 57 | * 58 | * @return the description 59 | */ 60 | public String getDescription() { 61 | return StringUtils.defaultString(description); 62 | } 63 | 64 | /** 65 | * Sets the description of this rule. The description is only set if the 66 | * topic is a description. 67 | * 68 | * @param topic 69 | * the topic that might contain the description 70 | */ 71 | public void setDescription(final Topic topic) { 72 | if (DESCRIPTION_SUBSECTION_NAME.equalsIgnoreCase(topic.getName())) { 73 | description = topic.getValue(); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/rules/Topic.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle.rules; 2 | 3 | /** 4 | * Java Bean class representing a DocBook subsection. 5 | * 6 | * @author Ulli Hafner 7 | */ 8 | public class Topic { 9 | /** The name of this topic. */ 10 | private String name; 11 | /** The value of this topic. */ 12 | private String value; 13 | 14 | /** 15 | * Returns the name of this topic. 16 | * 17 | * @return the name 18 | */ 19 | public String getName() { 20 | return name; 21 | } 22 | 23 | /** 24 | * Sets the name of this topic. 25 | * 26 | * @param name the name 27 | */ 28 | public void setName(final String name) { 29 | this.name = name; 30 | } 31 | 32 | /** 33 | * Returns the value of this topic. 34 | * 35 | * @return the value 36 | */ 37 | public String getValue() { 38 | return value; 39 | } 40 | 41 | /** 42 | * Sets the value of this topic. 43 | * 44 | * @param value the value 45 | */ 46 | public void setValue(final String value) { 47 | this.value = value; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/rules/TopicRule.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle.rules; 2 | 3 | import java.io.IOException; 4 | import java.io.StringWriter; 5 | 6 | import javax.xml.parsers.DocumentBuilder; 7 | import javax.xml.parsers.DocumentBuilderFactory; 8 | import javax.xml.parsers.ParserConfigurationException; 9 | 10 | import org.apache.commons.beanutils.MethodUtils; 11 | import org.apache.commons.digester3.NodeCreateRule; 12 | import org.apache.commons.lang.StringUtils; 13 | import org.apache.xml.serialize.OutputFormat; 14 | import org.apache.xml.serialize.XMLSerializer; 15 | import org.w3c.dom.Document; 16 | import org.w3c.dom.Element; 17 | import org.w3c.dom.Node; 18 | 19 | /** 20 | * Digester rule to parse the actual content of a DocBook subsection node. Does 21 | * not interpret XML elements that are children of a subsection. 22 | * 23 | * @author Ulli Hafner 24 | */ 25 | public class TopicRule extends NodeCreateRule { 26 | /** 27 | * Instantiates a new topic rule. 28 | * 29 | * @throws ParserConfigurationException 30 | * the parser configuration exception 31 | */ 32 | public TopicRule() throws ParserConfigurationException { 33 | super(Node.ELEMENT_NODE); 34 | } 35 | 36 | @Override 37 | @SuppressWarnings("PMD.SignatureDeclareThrowsException") 38 | public void end(final String namespace, final String name) throws Exception { 39 | Element subsection = (Element)getDigester().pop(); 40 | String description = extractNoteContent(subsection); 41 | 42 | MethodUtils.invokeExactMethod(getDigester().peek(), "setValue", description); 43 | } 44 | 45 | /** 46 | * Extracts the node content. Basically returns every character in the 47 | * subsection element. 48 | * 49 | * @param subsection 50 | * the subsection of a rule 51 | * @return the node content 52 | * @throws ParserConfigurationException 53 | * in case of an error 54 | * @throws IOException 55 | * in case of an error 56 | */ 57 | protected String extractNoteContent(final Element subsection) throws ParserConfigurationException, 58 | IOException { 59 | StringWriter writer = new StringWriter(); 60 | DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); 61 | Document doc = builder.newDocument(); 62 | 63 | OutputFormat format = new OutputFormat(doc); 64 | format.setOmitXMLDeclaration(true); 65 | XMLSerializer serializer = new XMLSerializer(writer, format); 66 | serializer.serialize(subsection); 67 | 68 | String serialized = writer.getBuffer().toString(); 69 | serialized = StringUtils.substringAfter(serialized, ">"); 70 | return StringUtils.substringBeforeLast(serialized, "<"); 71 | } 72 | } -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/tokens/CheckStyleResultTokenMacro.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle.tokens; 2 | 3 | import hudson.Extension; 4 | import hudson.plugins.analysis.tokens.AbstractResultTokenMacro; 5 | import hudson.plugins.checkstyle.CheckStyleMavenResultAction; 6 | import hudson.plugins.checkstyle.CheckStyleResultAction; 7 | 8 | /** 9 | * Provides a token that evaluates to the Checkstyle build result. 10 | * 11 | * @author Ulli Hafner 12 | */ 13 | @Extension(optional = true) 14 | public class CheckStyleResultTokenMacro extends AbstractResultTokenMacro { 15 | /** 16 | * Creates a new instance of {@link CheckStyleResultTokenMacro}. 17 | */ 18 | @SuppressWarnings("unchecked") 19 | public CheckStyleResultTokenMacro() { 20 | super("CHECKSTYLE_RESULT", CheckStyleResultAction.class, CheckStyleMavenResultAction.class); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/tokens/CheckStyleWarningCountTokenMacro.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle.tokens; 2 | 3 | import hudson.Extension; 4 | import hudson.plugins.analysis.tokens.AbstractAnnotationsCountTokenMacro; 5 | import hudson.plugins.checkstyle.CheckStyleMavenResultAction; 6 | import hudson.plugins.checkstyle.CheckStyleResultAction; 7 | 8 | /** 9 | * Provides a token that evaluates to the number of Checkstyle warnings. 10 | * 11 | * @author Ulli Hafner 12 | */ 13 | @Extension(optional = true) 14 | public class CheckStyleWarningCountTokenMacro extends AbstractAnnotationsCountTokenMacro { 15 | /** 16 | * Creates a new instance of {@link CheckStyleWarningCountTokenMacro}. 17 | */ 18 | @SuppressWarnings("unchecked") 19 | public CheckStyleWarningCountTokenMacro() { 20 | super("CHECKSTYLE_COUNT", CheckStyleResultAction.class, CheckStyleMavenResultAction.class); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/tokens/FixedCheckStyleWarningsTokenMacro.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle.tokens; 2 | 3 | import hudson.Extension; 4 | import hudson.plugins.analysis.tokens.AbstractFixedAnnotationsTokenMacro; 5 | import hudson.plugins.checkstyle.CheckStyleMavenResultAction; 6 | import hudson.plugins.checkstyle.CheckStyleResultAction; 7 | 8 | /** 9 | * Provides a token that evaluates to the number of fixed Checkstyle warnings. 10 | * 11 | * @author Ulli Hafner 12 | */ 13 | @Extension(optional = true) 14 | public class FixedCheckStyleWarningsTokenMacro extends AbstractFixedAnnotationsTokenMacro { 15 | /** 16 | * Creates a new instance of {@link FixedCheckStyleWarningsTokenMacro}. 17 | */ 18 | @SuppressWarnings("unchecked") 19 | public FixedCheckStyleWarningsTokenMacro() { 20 | super("CHECKSTYLE_FIXED", CheckStyleResultAction.class, CheckStyleMavenResultAction.class); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/checkstyle/tokens/NewCheckStyleWarningsTokenMacro.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.checkstyle.tokens; 2 | 3 | import hudson.Extension; 4 | import hudson.plugins.analysis.tokens.AbstractNewAnnotationsTokenMacro; 5 | import hudson.plugins.checkstyle.CheckStyleMavenResultAction; 6 | import hudson.plugins.checkstyle.CheckStyleResultAction; 7 | 8 | /** 9 | * Provides a token that evaluates to the number of new Checkstyle warnings. 10 | * 11 | * @author Ulli Hafner 12 | */ 13 | @Extension(optional = true) 14 | public class NewCheckStyleWarningsTokenMacro extends AbstractNewAnnotationsTokenMacro { 15 | /** 16 | * Creates a new instance of {@link NewCheckStyleWarningsTokenMacro}. 17 | */ 18 | @SuppressWarnings("unchecked") 19 | public NewCheckStyleWarningsTokenMacro() { 20 | super("CHECKSTYLE_NEW", CheckStyleResultAction.class, CheckStyleMavenResultAction.class); 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/checkstyle/CheckStylePublisher/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/checkstyle/CheckStylePublisher/config.properties: -------------------------------------------------------------------------------- 1 | description.pattern=Fileset 'includes' \ 2 | setting that specifies the generated raw CheckStyle XML report files, such as '**/checkstyle-result.xml'. \ 3 | Basedir of the fileset is the workspace root. \ 4 | If no value is set, then the default '**/checkstyle-result.xml' is used. Be sure not to include any \ 5 | non-report files into this pattern. 6 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/checkstyle/CheckStylePublisher/config_de.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/checkstyle-plugin/46d69902914026afbc70ce30bc1099965b2b8c26/src/main/resources/hudson/plugins/checkstyle/CheckStylePublisher/config_de.properties -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/checkstyle/CheckStylePublisher/config_ja.properties: -------------------------------------------------------------------------------- 1 | Checkstyle\ results=\u96c6\u8a08\u3059\u308b\u30d5\u30a1\u30a4\u30eb 2 | description.pattern=\u8b66\u544a\u3092\u30b9\u30ad\u30e3\u30f3\u3059\u308bCheckstyle\u306eXML\u5f62\u5f0f\u306e\u30ec\u30dd\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u3001\ 3 | Ant\u306eFileset ''includes''\u5f62\u5f0f\u3067\u6307\u5b9a\u3057\u307e\u3059\u3002 \ 4 | 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 \ 5 | \u4f55\u3082\u6307\u5b9a\u3057\u306a\u3051\u308c\u3070\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u3068\u3057\u3066 '**/checkstyle-result.xml' \u3092\u5bfe\u8c61\u3068\u3057\u307e\u3059\u3002 \ 6 | \u3053\u3053\u3067\u306fCheckstyle\u306e\u30ec\u30dd\u30fc\u30c8\u3067\u306f\u306a\u3044\u30d5\u30a1\u30a4\u30eb\u3092\u542b\u3081\u306a\u3044\u3088\u3046\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002 7 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/checkstyle/CheckStylePublisher/global.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/checkstyle/CheckStyleReporter/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/checkstyle/CheckStyleReporter/global.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/checkstyle/Messages.properties: -------------------------------------------------------------------------------- 1 | Checkstyle.Warnings.ColumnHeader=# Checkstyle 2 | Checkstyle.Warnings.Column=Number of Checkstyle warnings 3 | 4 | Checkstyle.Publisher.Name=[Deprecated] Publish Checkstyle analysis results 5 | 6 | Checkstyle.ProjectAction.Name=Checkstyle Warnings 7 | 8 | Checkstyle.Trend.Name=Checkstyle Trend 9 | 10 | Checkstyle.ResultAction.Header=CheckStyle Result 11 | 12 | Checkstyle.ResultAction.HealthReportNoItem=Checkstyle: no warnings found. 13 | Checkstyle.ResultAction.HealthReportSingleItem=Checkstyle: one warning found. 14 | Checkstyle.ResultAction.HealthReportMultipleItem=Checkstyle: {0} warnings found. 15 | 16 | Checkstyle.Detail.header=Checkstyle Warnings 17 | 18 | Checkstyle.FixedWarnings.Detail.header=Fixed Checkstyle Warnings 19 | Checkstyle.NewWarnings.Detail.header=New Checkstyle Warnings 20 | 21 | Portlet.WarningsTable=Checkstyle warnings per project 22 | Portlet.WarningsPriorityGraph=Checkstyle warnings trend graph (priority distribution) 23 | Portlet.WarningsNewVsFixedGraph=Checkstyle warnings trend graph (new vs. fixed) 24 | Portlet.WarningsTotalsGraph=Checkstyle warnings trend graph (totals) 25 | Portlet.WarningsUserGraph=Checkstyle warnings (priority per author) 26 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/checkstyle/Messages_de.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/checkstyle-plugin/46d69902914026afbc70ce30bc1099965b2b8c26/src/main/resources/hudson/plugins/checkstyle/Messages_de.properties -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/checkstyle/Messages_fr.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/checkstyle-plugin/46d69902914026afbc70ce30bc1099965b2b8c26/src/main/resources/hudson/plugins/checkstyle/Messages_fr.properties -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/checkstyle/Messages_ja.properties: -------------------------------------------------------------------------------- 1 | Checkstyle.ProjectAction.Name=Checkstyle\u8B66\u544A 2 | 3 | Checkstyle.Trend.Name=Checkstyle\u8B66\u544A\u306E\u63A8\u79FB 4 | 5 | Checkstyle.ResultAction.HealthReportNoItem=Checkstyle\uFF1A \u8B66\u544A\u306F\u3042\u308A\u307E\u305B\u3093\u3002 6 | Checkstyle.ResultAction.HealthReportSingleItem=Checkstyle: 1\u500B\u306E\u8B66\u544A\u304C\u3042\u308A\u307E\u3059\u3002 7 | Checkstyle.ResultAction.HealthReportMultipleItem=Checkstyle: {0}\u500B\u306E\u8B66\u544A\u304C\u3042\u308A\u307E\u3059\u3002 8 | 9 | Checkstyle.Detail.header=Checkstyle\u8B66\u544A 10 | 11 | Checkstyle.FixedWarnings.Detail.header=\u4FEE\u6B63\u3055\u308C\u305FCheckstyle\u8B66\u544A 12 | Checkstyle.NewWarnings.Detail.header=\u65B0\u3057\u3044Checkstyle\u8B66\u544A 13 | 14 | Portlet.WarningsTable=\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u6BCE\u306ECheckstyle\u8B66\u544A 15 | Portlet.WarningsPriorityGraph=Checkstyle\u8B66\u544A\u306E\u63A8\u79FB\u30B0\u30E9\u30D5 (\u512A\u5148\u5EA6\u306E\u5206\u5E03) 16 | Portlet.WarningsNewVsFixedGraph=Checkstyle\u8B66\u544A\u306E\u63A8\u79FB\u30B0\u30E9\u30D5 (\u65B0\u898F vs. \u4FEE\u6B63\u6E08) 17 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/checkstyle/Messages_nl.properties: -------------------------------------------------------------------------------- 1 | 2 | Checkstyle.ResultAction.Header=CheckStyle resultaat 3 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/checkstyle/rules/config_filefilters.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | Before Execution File Filters 9 |