In Android Studio I sometimes use this kind of comment to disable an inspection warning on a specific line of code that I already handled, for example:
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
//noinspection deprecation
textView.setBackgroundDrawable(ContextCompat.getDrawable(mContext, R.drawable.calendar_item_separator));
} else {
textView.setBackground(ContextCompat.getDrawable(mContext, R.drawable.calendar_item_separator));
}
In this example I used the keyword "deprecation" but I cannot find the full list of available keywords.
Did anyone find out?
Thanks!
I finally succeeded to get the keywords list from this Github source code.
I paste it here just in case:
"localInspection": [
{
"language": "JAVA",
"shortName": "UndesirableClassUsage",
"displayName": "Undesirable class usage",
"groupName": "IntelliJ IDEA Platform Inspections",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.internal.UndesirableClassUsageInspection"
},
{
"language": "JAVA",
"shortName": "FileEqualsUsage",
"displayName": "File.equals() usage",
"groupName": "IntelliJ IDEA Platform Inspections",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.internal.FileEqualsUsageInspection"
},
{
"language": "JAVA",
"shortName": "GtkPreferredJComboBoxRenderer",
"displayName": "Preferred JComboBox renderer",
"groupName": "IntelliJ IDEA Platform Inspections",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.internal.GtkPreferredJComboBoxRendererInspection"
},
{
"language": "JAVA",
"shortName": "UnsafeVfsRecursion",
"displayName": "Unsafe VFS recursion",
"groupName": "IntelliJ IDEA Platform Inspections",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.internal.UnsafeVfsRecursionInspection"
},
{
"language": "JAVA",
"shortName": "ConstantConditions",
"bundle": "messages.InspectionsBundle",
"key": "inspection.data.flow.display.name",
"groupName": "Probable bugs",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.dataFlow.DataFlowInspection"
},
{
"language": "JAVA",
"shortName": "UnusedAssignment",
"displayName": "Unused assignment",
"groupName": "Probable bugs",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.defUse.DefUseInspection"
},
{
"language": "JAVA",
"shortName": "NumericOverflow",
"displayName": "Numeric overflow",
"groupName": "Numeric issues",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.NumericOverflowInspection"
},
{
"language": "JAVA",
"shortName": "RedundantCast",
"displayName": "Redundant type cast",
"groupName": "Verbose or redundant code constructs",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.redundantCast.RedundantCastInspection"
},
{
"language": "JAVA",
"shortName": "RedundantTypeArguments",
"bundle": "messages.InspectionsBundle",
"key": "inspection.redundant.type.display.name",
"groupName": "Verbose or redundant code constructs",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.miscGenerics.RedundantTypeArgsInspection"
},
{
"language": "JAVA",
"shortName": "RedundantArrayCreation",
"bundle": "messages.InspectionsBundle",
"key": "inspection.redundant.array.creation.display.name",
"groupName": "Verbose or redundant code constructs",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.miscGenerics.RedundantArrayForVarargsCallInspection"
},
{
"language": "JAVA",
"shortName": "SuspiciousMethodCalls",
"bundle": "messages.InspectionsBundle",
"key": "inspection.suspicious.collections.method.calls.display.name",
"groupName": "Probable bugs",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.miscGenerics.SuspiciousCollectionsMethodCallsInspection"
},
{
"language": "JAVA",
"shortName": "LocalCanBeFinal",
"bundle": "messages.InspectionsBundle",
"key": "inspection.local.can.be.final.display.name",
"groupName": "Code style issues",
"enabledByDefault": "false",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.localCanBeFinal.LocalCanBeFinal"
},
{
"language": "JAVA",
"shortName": "JavaDoc",
"bundle": "messages.InspectionsBundle",
"key": "inspection.javadoc.display.name",
"groupKey": "group.names.javadoc.issues",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.javaDoc.JavaDocLocalInspection"
},
{
"language": "JAVA",
"shortName": "JavadocReference",
"bundle": "messages.InspectionsBundle",
"key": "inspection.javadoc.ref.display.name",
"groupKey": "group.names.javadoc.issues",
"enabledByDefault": "true",
"level": "ERROR",
"implementationClass": "com.intellij.codeInspection.javaDoc.JavaDocReferenceInspection"
},
{
"language": "JAVA",
"suppressId": "deprecation",
"shortName": "Deprecation",
"displayName": "Deprecated API usage",
"groupName": "",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.deprecation.DeprecationInspection"
},
{
"language": "JAVA",
"suppressId": "extensionSyntax",
"bundle": "messages.InspectionsBundle",
"key": "deprecated.defender.syntax.description",
"groupName": "",
"enabledByDefault": "true",
"level": "ERROR",
"implementationClass": "com.intellij.codeInspection.deprecation.DeprecatedDefenderSyntaxInspection"
},
{
"language": "XML",
"shortName": "DeprecatedClassUsageInspection",
"displayName": "Deprecated API usage in XML",
"groupName": "XML",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.util.xml.DeprecatedClassUsageInspection"
},
{
"language": "JAVA",
"shortName": "EqualsAndHashcode",
"bundle": "messages.InspectionsBundle",
"key": "inspection.equals.hashcode.display.name",
"groupName": "",
"enabledByDefault": "false",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.equalsAndHashcode.EqualsAndHashcode"
},
{
"language": "JAVA",
"shortName": "Since15",
"bundle": "messages.InspectionsBundle",
"key": "inspection.1.5.display.name",
"groupName": "Java language level migration aids",
"enabledByDefault": "false",
"level": "ERROR",
"implementationClass": "com.intellij.codeInspection.java15api.Java15APIUsageInspection"
},
{
"language": "JAVA",
"shortName": "Dependency",
"displayName": "Illegal package dependencies",
"groupName": "",
"enabledByDefault": "true",
"level": "ERROR",
"implementationClass": "com.intellij.codeInspection.dependencyViolation.DependencyInspection"
},
{
"language": "JAVA",
"shortName": "FieldCanBeLocal",
"bundle": "messages.InspectionsBundle",
"key": "inspection.field.can.be.local.display.name",
"groupName": "Class structure",
"enabledByDefault": "true",
"level": "WARNING",
"runForWholeFile": "true",
"implementationClass": "com.intellij.codeInspection.varScopeCanBeNarrowed.FieldCanBeLocalInspection"
},
{
"language": "JAVA",
"shortName": "ParameterCanBeLocal",
"key": "inspection.parameter.can.be.local.display.name",
"groupName": "Class structure",
"enabledByDefault": "true",
"level": "WARNING",
"bundle": "messages.InspectionsBundle",
"implementationClass": "com.intellij.codeInspection.varScopeCanBeNarrowed.ParameterCanBeLocalInspection"
},
{
"language": "JAVA",
"shortName": "NullableProblems",
"bundle": "messages.InspectionsBundle",
"key": "inspection.nullable.problems.display.name",
"groupName": "Probable bugs",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.nullable.NullableStuffInspection"
},
{
"language": "JAVA",
"shortName": "TestOnlyProblems",
"bundle": "messages.InspectionsBundle",
"key": "inspection.test.only.problems.display.name",
"groupName": "General",
"enabledByDefault": "false",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.testOnly.TestOnlyInspection"
},
{
"language": "JAVA",
"shortName": "WrongPackageStatement",
"bundle": "messages.InspectionsBundle",
"key": "wrong.package.statement",
"groupName": "",
"enabledByDefault": "true",
"level": "ERROR",
"implementationClass": "com.intellij.codeInspection.wrongPackageStatement.WrongPackageStatementInspection"
},
{
"language": "JAVA",
"shortName": "SillyAssignment",
"bundle": "messages.InspectionsBundle",
"key": "inspection.variable.assigned.to.itself.display.name",
"groupName": "",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.sillyAssignment.SillyAssignmentInspection"
},
{
"language": "JAVA",
"shortName": "RedundantThrowsDeclaration",
"bundle": "messages.InspectionsBundle",
"key": "redundant.throws.declaration",
"groupName": "Declaration redundancy",
"enabledByDefault": "false",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.unneededThrows.RedundantThrowsDeclaration"
},
{
"language": "JAVA",
"shortName": "AccessStaticViaInstance",
"bundle": "messages.InspectionsBundle",
"key": "access.static.via.instance",
"groupName": "",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.accessStaticViaInstance.AccessStaticViaInstance"
},
{
"shortName": "DefaultFileTemplate",
"bundle": "messages.InspectionsBundle",
"key": "default.file.template.display.name",
"groupName": "General",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.defaultFileTemplateUsage.DefaultFileTemplateUsageInspection"
},
{
"language": "JAVA",
"suppressId": "UnusedDeclaration",
"alternativeId": "unused",
"shortName": "UNUSED_SYMBOL",
"displayName": "Unused symbol",
"groupName": "Declaration redundancy",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection",
"unfair": "true"
},
{
"language": "JAVA",
"shortName": "UNUSED_IMPORT",
"displayName": "Unused import (editor light)",
"groupName": "Imports",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection"
},
{
"language": "JAVA",
"suppressId": "unchecked",
"shortName": "UNCHECKED_WARNING",
"displayName": "Unchecked warning",
"groupName": "",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.uncheckedWarnings.UncheckedWarningLocalInspection"
},
{
"language": "JAVA",
"shortName": "SuspiciousNameCombination",
"bundle": "messages.InspectionsBundle",
"key": "suspicious.name.combination.display.name",
"groupName": "Probable bugs",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.suspiciousNameCombination.SuspiciousNameCombinationInspection"
},
{
"language": "JAVA",
"shortName": "DuplicateThrows",
"bundle": "messages.InspectionsBundle",
"key": "inspection.duplicate.throws.display.name",
"groupName": "Declaration redundancy",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.duplicateThrows.DuplicateThrowsInspection"
},
{
"language": "JAVA",
"shortName": "FieldAccessNotGuarded",
"displayName": "Unguarded field access",
"groupName": "Concurrency annotation issues",
"enabledByDefault": "false",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.concurrencyAnnotations.FieldAccessNotGuardedInspection"
},
{
"language": "JAVA",
"shortName": "InstanceGuardedByStatic",
"displayName": "Instance member guarded by static field",
"groupName": "Concurrency annotation issues",
"enabledByDefault": "false",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.concurrencyAnnotations.InstanceGuardedByStaticInspection"
},
{
"language": "JAVA",
"shortName": "NonFinalFieldInImmutable",
"displayName": "Non-final field in @Immutable class",
"groupName": "Concurrency annotation issues",
"enabledByDefault": "false",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.concurrencyAnnotations.NonFinalFieldInImmutableInspection"
},
{
"language": "JAVA",
"shortName": "NonFinalGuard",
"displayName": "Non-final @GuardedBy field",
"groupName": "Concurrency annotation issues",
"enabledByDefault": "false",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.concurrencyAnnotations.NonFinalGuardInspection"
},
{
"language": "JAVA",
"shortName": "StaticGuardedByInstance",
"displayName": "Static member guarded by instance field or this",
"groupName": "Concurrency annotation issues",
"enabledByDefault": "false",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.concurrencyAnnotations.StaticGuardedByInstanceInspection"
},
{
"language": "JAVA",
"shortName": "UnknownGuard",
"displayName": "Unknown @GuardedBy field",
"groupName": "Concurrency annotation issues",
"enabledByDefault": "false",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.concurrencyAnnotations.UnknownGuardInspection"
},
{
"language": "JAVA",
"shortName": "Convert2Diamond",
"displayName": "Explicit type can be replaced with <>",
"groupName": "Java language level migration aids",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.ExplicitTypeCanBeDiamondInspection"
},
{
"language": "JAVA",
"shortName": "Convert2Lambda",
"displayName": "Anonymous type can be replaced with lambda",
"groupName": "Java language level migration aids",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.AnonymousCanBeLambdaInspection"
},
{
"language": "JAVA",
"shortName": "Anonymous2MethodRef",
"displayName": "Anonymous type can be replaced with method reference",
"groupName": "Java language level migration aids",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.AnonymousCanBeMethodReferenceInspection"
},
{
"language": "JAVA",
"shortName": "Convert2MethodRef",
"displayName": "Lambda can be replaced with method reference",
"groupName": "Java language level migration aids",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.LambdaCanBeMethReferenceInspection"
},
{
"language": "JAVA",
"shortName": "CodeBlock2Expr",
"displayName": "Lambda code block can be replaced with expression",
"groupName": "Java language level migration aids",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.RedundantLambdaCodeBlockInspection"
},
{
"language": "JAVA",
"suppressId": "unchecked",
"shortName": "SafeVarargsDetector",
"displayName": "Possible heap pollution from parameterized vararg type",
"groupName": "Java language level migration aids",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.PossibleHeapPollutionVarargsInspection"
},
{
"language": "JAVA",
"shortName": "JavacQuirks",
"bundle": "messages.InspectionsBundle",
"key": "inspection.compiler.javac.quirks.name",
"groupName": "Compiler issues",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.compiler.JavacQuirksInspection"
},
{
"language": "JAVA",
"shortName": "MagicConstant",
"displayName": "Magic Constant",
"groupName": "Probable bugs",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.magicConstant.MagicConstantInspection"
}
],
"globalInspection": [
{
"shortName": "WeakerAccess",
"displayName": "Declaration access can be weaker",
"groupName": "Declaration redundancy",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.visibility.VisibilityInspection"
},
{
"shortName": "CanBeFinal",
"displayName": "Declaration can have final modifier",
"groupName": "Declaration redundancy",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.canBeFinal.CanBeFinalInspection"
},
{
"shortName": "UnusedParameters",
"bundle": "messages.InspectionsBundle",
"key": "inspection.unused.parameter.display.name",
"groupName": "Declaration redundancy",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.unusedParameters.UnusedParametersInspection"
},
{
"shortName": "SameParameterValue",
"bundle": "messages.InspectionsBundle",
"key": "inspection.same.parameter.display.name",
"groupName": "Declaration redundancy",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.sameParameterValue.SameParameterValueInspection"
},
{
"shortName": "UnusedReturnValue",
"bundle": "messages.InspectionsBundle",
"key": "inspection.unused.return.value.display.name",
"groupName": "Declaration redundancy",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.unusedReturnValue.UnusedReturnValue"
},
{
"shortName": "SameReturnValue",
"bundle": "messages.InspectionsBundle",
"key": "inspection.same.return.value.display.name",
"groupName": "Declaration redundancy",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.sameReturnValue.SameReturnValueInspection"
},
{
"shortName": "EmptyMethod",
"displayName": "Empty method",
"groupName": "Declaration redundancy",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.emptyMethod.EmptyMethodInspection"
},
{
"shortName": "RedundantThrows",
"displayName": "Redundant throws clause",
"groupName": "Declaration redundancy",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.unneededThrows.RedundantThrows"
},
{
"shortName": "UnnecessaryModuleDependencyInspection",
"bundle": "messages.InspectionsBundle",
"key": "unnecessary.module.dependency.display.name",
"groupName": "Declaration redundancy",
"enabledByDefault": "true",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.unnecessaryModuleDependency.UnnecessaryModuleDependencyInspection"
},
{
"shortName": "RedundantSuppression",
"bundle": "messages.InspectionsBundle",
"key": "inspection.redundant.suppression.name",
"groupName": "Declaration redundancy",
"enabledByDefault": "false",
"level": "WARNING",
"implementationClass": "com.intellij.codeInspection.RedundantSuppressInspection"
}
]
For a reason I still don't know, the use of the comment //noinspection <keyword>
does not work all the time.
To be able to use the keyword UnusedDeclaration
I had to write this line before my variable declaration:
/** @noinspection UnusedDeclaration */
private static final String TAG = "DateTools";
I might be wrong, but I think the closest you can get is the Inspections
view in Android Studio's settings. Hit Ctrl + Alt + S, choose Editor
-> Inspections
.
It will not show you the list of available noinspection
keywords, but it'll provide you the full list of inspections available in Android Studio.
BTW, why would you need that in the first place? Any time the warning is shown in the Android Studio, there is this quick-fix option available by Alt + Enter which shows you how this warning can be suppressed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With