From 8a763cc9d13f23a5833edc09feb554e678fa121f Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Mon, 16 Jul 2012 10:09:34 +0200 Subject: [PATCH] New FindBugs settings. --- .classpath | 1 + .fbprefs | 6 +-- .settings/org.eclipse.jdt.core.prefs | 41 ++++++++++++++++--- pom.xml | 2 +- .../plugins/warnings/WarningsPublisher.java | 10 ++++- .../warnings/parser/PuppetLintParser.java | 5 --- .../warnings/parser/ViolationsAdapter.java | 8 +++- .../plugins/warnings/GroovyParserTest.java | 2 + .../warnings/parser/MsBuildParserTest.java | 3 +- .../parser/ParserRegistryIntegrationTest.java | 4 +- 10 files changed, 63 insertions(+), 19 deletions(-) diff --git a/.classpath b/.classpath index 85da9ab84..dd2947813 100644 --- a/.classpath +++ b/.classpath @@ -8,6 +8,7 @@ + diff --git a/.fbprefs b/.fbprefs index 8f85ca408..118c7bae0 100644 --- a/.fbprefs +++ b/.fbprefs @@ -1,5 +1,5 @@ #FindBugs User Preferences -#Fri Feb 24 13:50:19 CET 2012 +#Fri Jul 13 08:53:48 CEST 2012 cloud_id=edu.umd.cs.findbugs.cloud.doNothingCloud detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true detectorAtomicityProblem=AtomicityProblem|true @@ -131,6 +131,6 @@ detectorXMLFactoryBypass=XMLFactoryBypass|true detector_threshold=3 effort=max excludefilter0=../analysis-config/etc/findbugs-exclusion-filter.xml|true -filter_settings=Low|BAD_PRACTICE,CORRECTNESS,EXPERIMENTAL,MALICIOUS_CODE,MT_CORRECTNESS,PERFORMANCE,SECURITY,STYLE|false|20 -filter_settings_neg=NOISE,I18N| +filter_settings=Low|BAD_PRACTICE,CORRECTNESS,EXPERIMENTAL,I18N,MALICIOUS_CODE,MT_CORRECTNESS,PERFORMANCE,SECURITY,STYLE|false|20 +filter_settings_neg=NOISE| run_at_full_build=true diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index b4c8af3a8..82f3add3e 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,3 @@ -#Wed Jan 13 19:40:02 CET 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.codeComplete.argumentPrefixes= org.eclipse.jdt.core.codeComplete.argumentSuffixes= @@ -8,16 +7,26 @@ org.eclipse.jdt.core.codeComplete.localPrefixes= org.eclipse.jdt.core.codeComplete.localSuffixes= org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning org.eclipse.jdt.core.compiler.problem.deprecation=warning org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled org.eclipse.jdt.core.compiler.problem.fieldHiding=warning @@ -25,6 +34,7 @@ org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning @@ -35,32 +45,50 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning -org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=private -org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=warning org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore @@ -73,6 +101,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverridin org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore org.eclipse.jdt.core.compiler.problem.unusedParameter=warning org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled diff --git a/pom.xml b/pom.xml index e999952bc..dccb39433 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jvnet.hudson.plugins analysis-pom - 1.36 + 1.37 ../analysis-pom/pom.xml diff --git a/src/main/java/hudson/plugins/warnings/WarningsPublisher.java b/src/main/java/hudson/plugins/warnings/WarningsPublisher.java index ed3d4bb04..26f9d276a 100644 --- a/src/main/java/hudson/plugins/warnings/WarningsPublisher.java +++ b/src/main/java/hudson/plugins/warnings/WarningsPublisher.java @@ -107,8 +107,12 @@ public class WarningsPublisher extends HealthAwarePublisher { * annotation threshold * @param canRunOnFailed * determines whether the plug-in can run for failed builds, too + * @param canComputeNew + * determines whether new warnings should be computed (with + * respect to baseline) * @param shouldDetectModules - * determines whether module names should be derived from Maven POM or Ant build files + * determines whether module names should be derived from Maven + * POM or Ant build files * @param includePattern * Ant file-set pattern of files to include in report * @param excludePattern @@ -117,6 +121,10 @@ public class WarningsPublisher extends HealthAwarePublisher { * determines whether relative paths in warnings should be * resolved using a time expensive operation that scans the whole * workspace for matching files. + * @param parserConfigurations + * the parser configurations to scan files + * @param consoleParsers + * the parsers to scan the console */ // CHECKSTYLE:OFF @SuppressWarnings("PMD.ExcessiveParameterList") diff --git a/src/main/java/hudson/plugins/warnings/parser/PuppetLintParser.java b/src/main/java/hudson/plugins/warnings/parser/PuppetLintParser.java index 596b508b4..954bc76d2 100644 --- a/src/main/java/hudson/plugins/warnings/parser/PuppetLintParser.java +++ b/src/main/java/hudson/plugins/warnings/parser/PuppetLintParser.java @@ -57,11 +57,6 @@ protected Warning createWarning(final Matcher matcher) { return warning; } - /** - * Detects the module name for the specified filename. - * - * @param fileName the file name - */ private String detectModuleName(final String fileName) { if (StringUtils.isNotBlank(fileName)) { return splitFileName(fileName); diff --git a/src/main/java/hudson/plugins/warnings/parser/ViolationsAdapter.java b/src/main/java/hudson/plugins/warnings/parser/ViolationsAdapter.java index 8e4cbf25e..03bfb4ce8 100644 --- a/src/main/java/hudson/plugins/warnings/parser/ViolationsAdapter.java +++ b/src/main/java/hudson/plugins/warnings/parser/ViolationsAdapter.java @@ -98,7 +98,13 @@ private Priority convertSeverity(final String severity) { private File copyContentToTemporaryFile(final Reader reader) throws IOException, FileNotFoundException { File temp = File.createTempFile("warnings", "log"); temp.deleteOnExit(); - IOUtils.copy(reader, new FileOutputStream(temp), "UTF-8"); + FileOutputStream output = new FileOutputStream(temp); + try { + IOUtils.copy(reader, output, "UTF-8"); + } + finally { + IOUtils.closeQuietly(output); + } return temp; } } diff --git a/src/test/java/hudson/plugins/warnings/GroovyParserTest.java b/src/test/java/hudson/plugins/warnings/GroovyParserTest.java index 30e99280c..e82a5caf6 100644 --- a/src/test/java/hudson/plugins/warnings/GroovyParserTest.java +++ b/src/test/java/hudson/plugins/warnings/GroovyParserTest.java @@ -41,7 +41,9 @@ public class GroovyParserTest { "String message = matcher.group(4)\n" + "\n" + "return new Warning(fileName, Integer.parseInt(lineNumber), \"Generic Parser\", \"\", message);\n"; + @SuppressWarnings("javadoc") public static final String MULTI_LINE_REGEXP = "(WARNING|ERROR)\\s*in\\s*(.*)\\(at line\\s*(\\d+)\\).*(?:\\r?\\n[^\\^]*)+(?:\\r?\\n.*[\\^]+.*)\\r?\\n(?:\\s*\\[.*\\]\\s*)?(.*)"; + @SuppressWarnings("javadoc") public static final String SINGLE_LINE_REGEXP = "^\\s*(.*):(\\d+):(.*):\\s*(.*)$"; // CHECKSTYLE:ON diff --git a/src/test/java/hudson/plugins/warnings/parser/MsBuildParserTest.java b/src/test/java/hudson/plugins/warnings/parser/MsBuildParserTest.java index 7359fc9d5..efbedabf0 100644 --- a/src/test/java/hudson/plugins/warnings/parser/MsBuildParserTest.java +++ b/src/test/java/hudson/plugins/warnings/parser/MsBuildParserTest.java @@ -229,7 +229,8 @@ public void shouldDetectKeywordsInRegexCaseInsensitive() throws IOException { testData.append("\r\n"); testData.append("C:\\Src\\Parser\\CSharp\\file.cs (10): Error XXX: An error occurred"); - Collection warnings = new MsBuildParser().parse(new InputStreamReader(IOUtils.toInputStream(testData.toString()))); + Collection warnings = new MsBuildParser().parse(new InputStreamReader( + IOUtils.toInputStream(testData.toString()))); assertEquals(WRONG_NUMBER_OF_WARNINGS_DETECTED, 2, warnings.size()); diff --git a/src/test/java/hudson/plugins/warnings/parser/ParserRegistryIntegrationTest.java b/src/test/java/hudson/plugins/warnings/parser/ParserRegistryIntegrationTest.java index 4a45120bc..37d813ad2 100644 --- a/src/test/java/hudson/plugins/warnings/parser/ParserRegistryIntegrationTest.java +++ b/src/test/java/hudson/plugins/warnings/parser/ParserRegistryIntegrationTest.java @@ -154,6 +154,7 @@ protected Reader createReader(final File file) throws FileNotFoundException { return parserRegistry; } // CHECKSTYLE:OFF Test implementations + @SuppressWarnings("javadoc") @TestExtension public static class TestBothParser extends RegexpLineParser { private static final Localizable DUMMY = Messages._Warnings_NotLocalizedName(MIXED_API); @@ -170,6 +171,7 @@ protected Warning createWarning(final Matcher matcher) { } } + @SuppressWarnings("javadoc") @TestExtension public static class TestNewParser extends AbstractWarningsParser { private static final long serialVersionUID = 1L; @@ -185,7 +187,7 @@ public Collection parse(final Reader reader) throws IOException, return null; } } - @SuppressWarnings("deprecation") + @SuppressWarnings({"javadoc", "deprecation"}) @TestExtension public static class TestOldParser implements WarningsParser { private static final long serialVersionUID = 1L;