2015-12-17 11 views
13
私は時々、例えば、私はすでに扱わコードの特定の行に警告検査を無効にするには、コメントのこの種を使用してAndroidのメーカーでは

:この例では「noinspection」キーワードリスト

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)); 
} 

キーワード「廃止」を使用しましたが、利用可能なキーワードの完全なリストが見つかりません。

誰かが見つけましたか?

ありがとうございます!

+0

アンドロイド糸くずを見てhttp://tools.android.com/tips/lint/suppressing:

は私が私の変数の宣言の前に、この行を書かなければならなかったキーワードUnusedDeclarationを使用できるようにするには-lint-warnings –

答えて

15

このGithubからキーワードリストを取得することに成功しましたsource code。私は念のためにここに貼り付け

:私はまだ知らないため

"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" 
    } 
] 

は、コメント//noinspection <keyword>の使用は、すべての時間を動作しません。

/** @noinspection UnusedDeclaration */ 
private static final String TAG = "DateTools"; 
3

私は間違っているかもしれませんが、最も近いのはAndroid Studioの設定でInspectionsビューです。ヒットCtrl + Alt + Sを選択し、Editor - >Inspectionsを選択します。

利用可能なnoinspectionキーワードのリストは表示されませんが、Android Studioで利用可能な完全な検査のリストが表示されます。

ところで、なぜ最初にその必要がありますか? Android Studioに警告が表示されるたびに、Alt + と入力してください。と入力すると、この警告を抑制する方法が示されます。

+0

返信をありがとうが、Inscpectionsの設定では使用するキーワードが表示されません。 Alt + Enterキーは毎回動作していません。たとえば、「未使用の宣言」警告を非表示にしたい場合などは提案されていません。私は別の答えで投稿する新しい情報を見つけました。 –

+0

hit alt-enterを選択し、「検査を無効にする」を選択します。 – Christine

関連する問題