diff options
author | Tor Norbye <tnorbye@google.com> | 2012-06-01 12:30:27 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-06-01 12:30:40 -0700 |
commit | 764d9297c9631f239c8ebafc64edc77db80ce3c2 (patch) | |
tree | 1dbb7699938ee055ca7de96dfbba41e45c0571eb /lint/cli | |
parent | 87ab6d594ec7e4ba4010ec8b090c43ba29317694 (diff) | |
download | sdk-764d9297c9631f239c8ebafc64edc77db80ce3c2.zip sdk-764d9297c9631f239c8ebafc64edc77db80ce3c2.tar.gz sdk-764d9297c9631f239c8ebafc64edc77db80ce3c2.tar.bz2 |
Fix warnings
First, update our various project-specific Eclipse compiler settings
configuration files to include the new Eclipse 4 flags.
Second, turn off the "Unchecked conversion from non-annotated type to
@NonNull" warnings; there are hundreds or thousands of these, and
there isn't much we can do about them when they're coming from
platform and library APIs.
Third, make the lint projects warning-clean again by addressing
various warnings Eclipse found (such as some unclosed resources and
some null handling issues; yesterday's null annotation fixes only
addressed errors, not warnings.)
Change-Id: If75f7401a1cbeef1bf58b47ccaa9ad17bede7f91
Diffstat (limited to 'lint/cli')
-rw-r--r-- | lint/cli/.settings/org.eclipse.jdt.core.prefs | 5 | ||||
-rw-r--r-- | lint/cli/src/com/android/tools/lint/HtmlReporter.java | 6 | ||||
-rw-r--r-- | lint/cli/src/com/android/tools/lint/Main.java | 8 |
3 files changed, 12 insertions, 7 deletions
diff --git a/lint/cli/.settings/org.eclipse.jdt.core.prefs b/lint/cli/.settings/org.eclipse.jdt.core.prefs index 5381a0e..d11c211 100644 --- a/lint/cli/.settings/org.eclipse.jdt.core.prefs +++ b/lint/cli/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,5 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled @@ -36,7 +37,9 @@ org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore 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.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled @@ -45,9 +48,11 @@ org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignor 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=error org.eclipse.jdt.core.compiler.problem.nullReference=error org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning diff --git a/lint/cli/src/com/android/tools/lint/HtmlReporter.java b/lint/cli/src/com/android/tools/lint/HtmlReporter.java index 8b3e99e..e962fec 100644 --- a/lint/cli/src/com/android/tools/lint/HtmlReporter.java +++ b/lint/cli/src/com/android/tools/lint/HtmlReporter.java @@ -227,7 +227,8 @@ public class HtmlReporter extends Reporter { Location l = warning.location.getSecondary(); int otherLocations = 0; while (l != null) { - if (l.getMessage() != null && l.getMessage().length() > 0) { + String message = l.getMessage(); + if (message != null && message.length() > 0) { Position start = l.getStart(); int line = start != null ? start.getLine() : -1; String path = mClient.getDisplayPath(warning.project, l.getFile()); @@ -235,7 +236,7 @@ public class HtmlReporter extends Reporter { mWriter.write(':'); mWriter.write(' '); mWriter.write("<span class=\"message\">"); //$NON-NLS-1$ - appendEscapedText(l.getMessage()); + appendEscapedText(message); mWriter.write("</span>"); //$NON-NLS-1$ mWriter.write("<br />"); //$NON-NLS-1$ @@ -484,6 +485,7 @@ public class HtmlReporter extends Reporter { if (mSimpleFormat) { // Inline the CSS mWriter.write("<style>\n"); //$NON-NLS-1$ + @SuppressWarnings("resource") // Eclipse doesn't know about Closeables.closeQuietly InputStream input = cssUrl.openStream(); byte[] bytes = ByteStreams.toByteArray(input); Closeables.closeQuietly(input); diff --git a/lint/cli/src/com/android/tools/lint/Main.java b/lint/cli/src/com/android/tools/lint/Main.java index 68d68b4..18a2da0 100644 --- a/lint/cli/src/com/android/tools/lint/Main.java +++ b/lint/cli/src/com/android/tools/lint/Main.java @@ -638,10 +638,11 @@ public class Main extends LintClient { "\"lint --ignore UnusedResources,UselessLeaf /my/project/path\"\n"; } + @SuppressWarnings("resource") // Eclipse doesn't know about Closeables.closeQuietly private void printVersion() { File file = findResource("tools" + File.separator + //$NON-NLS-1$ "source.properties"); //$NON-NLS-1$ - if (file.exists()) { + if (file != null && file.exists()) { FileInputStream input = null; try { input = new FileInputStream(file); @@ -924,9 +925,6 @@ public class Main extends LintClient { String s = mFileContents.get(file); if (s == null) { s = readFile(file); - if (s == null) { - s = ""; - } mFileContents.put(file, s); } @@ -1068,7 +1066,7 @@ public class Main extends LintClient { * flags supplied on the command line */ class CliConfiguration extends DefaultConfiguration { - CliConfiguration(Configuration parent, Project project) { + CliConfiguration(@NonNull Configuration parent, @NonNull Project project) { super(Main.this, project, parent); } |