com.android.tools.lint.detector.api
Class Issue

java.lang.Object
  extended by com.android.tools.lint.detector.api.Issue
All Implemented Interfaces:
Comparable<Issue>

public final class Issue
extends Object
implements Comparable<Issue>

An issue is a potential bug in an Android application. An issue is discovered by a Detector, and has an associated Severity.

Issues and detectors are separate classes because a detector can discover multiple different issues as it's analyzing code, and we want to be able to different severities for different issues, the ability to suppress one but not other issues from the same detector, and so on.

NOTE: This is not a public or final API; if you rely on this be prepared to adjust your code for the next tools release.


Method Summary
 int compareTo(Issue other)
          Sorts the detectors alphabetically by id.
static Issue create(String id, String description, String explanation, Category category, int priority, Severity severity, Class<? extends Detector> detectorClass, EnumSet<Scope> scope)
          Creates a new issue
 Category getCategory()
          The category, or null if no category has been assigned
 Severity getDefaultSeverity()
          Returns the default severity of the issues found by this detector (some tools may allow the user to specify custom severities for detectors).
 String getDescription()
          Briefly (one line) describes the kinds of checks performed by this rule
 Class<? extends Detector> getDetectorClass()
          Returns the class of the detector to use to find this issue
 String getExplanation()
          Describes the error found by this rule, e.g.
 String getId()
          Returns the unique id of this issue.
 String getMoreInfo()
          Returns a link (a URL string) to more information, or null
 int getPriority()
          Returns a priority, in the range 1-10, with 10 being the most severe and 1 the least
 EnumSet<Scope> getScope()
          Returns the scope required to analyze the code to detect this issue.
 boolean isEnabledByDefault()
          Returns whether this issue should be enabled by default, unless the user has explicitly disabled it.
 Issue setEnabledByDefault(boolean enabledByDefault)
          Sets whether this issue is enabled by default.
 Issue setMoreInfo(String moreInfoUrl)
          Sets a more info URL string
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

create

public static Issue create(String id,
                           String description,
                           String explanation,
                           Category category,
                           int priority,
                           Severity severity,
                           Class<? extends Detector> detectorClass,
                           EnumSet<Scope> scope)
Creates a new issue

Parameters:
id - the fixed id of the issue
description - the quick summary of the issue (one line)
explanation - a full explanation of the issue, with suggestions for how to fix it
category - the associated category, if any
priority - the priority, a number from 1 to 10 with 10 being most important/severe
severity - the default severity of the issue
detectorClass - the class of the detector to find this issue
scope - the scope of files required to analyze this issue
Returns:
a new Issue

getId

public String getId()
Returns the unique id of this issue. These should not change over time since they are used to persist the names of issues suppressed by the user etc. It is typically a single camel-cased word.

Returns:
the associated fixed id, never null and always unique

getDescription

public String getDescription()
Briefly (one line) describes the kinds of checks performed by this rule

Returns:
a quick summary of the issue, never null

getExplanation

public String getExplanation()
Describes the error found by this rule, e.g. "Buttons must define contentDescriptions". Preferably the explanation should also contain a description of how the problem should be solved. Additional info can be provided via getMoreInfo().

Returns:
an explanation of the issue, never null.

getCategory

public Category getCategory()
The category, or null if no category has been assigned

Returns:
the category, or null if no category has been assigned

getPriority

public int getPriority()
Returns a priority, in the range 1-10, with 10 being the most severe and 1 the least

Returns:
a priority from 1 to 10

getDefaultSeverity

public Severity getDefaultSeverity()
Returns the default severity of the issues found by this detector (some tools may allow the user to specify custom severities for detectors).

Note that even though the normal way for an issue to be disabled is for the Configuration to return Severity.IGNORE, there is a isEnabledByDefault() method which can be used to turn off issues by default. This is done rather than just having the severity as the only attribute on the issue such that an issue can be configured with an appropriate severity (such as Severity.ERROR) even when issues are disabled by default for example because they are experimental or not yet stable.

Returns:
the severity of the issues found by this detector

getMoreInfo

public String getMoreInfo()
Returns a link (a URL string) to more information, or null

Returns:
a link to more information, or null

isEnabledByDefault

public boolean isEnabledByDefault()
Returns whether this issue should be enabled by default, unless the user has explicitly disabled it.

Returns:
true if this issue should be enabled by default

getScope

public EnumSet<Scope> getScope()
Returns the scope required to analyze the code to detect this issue. This is determined by the detectors which reports the issue.

Returns:
the required scope

compareTo

public int compareTo(Issue other)
Sorts the detectors alphabetically by id. This is intended to make it convenient to store settings for detectors in a fixed order. It is not intended as the order to be shown to the user; for that, a tool embedding lint might consider the priorities, categories, severities etc of the various detectors.

Specified by:
compareTo in interface Comparable<Issue>
Parameters:
other - the Issue to compare this issue to

setMoreInfo

public Issue setMoreInfo(String moreInfoUrl)
Sets a more info URL string

Parameters:
moreInfoUrl - url string
Returns:
this, for constructor chaining

setEnabledByDefault

public Issue setEnabledByDefault(boolean enabledByDefault)
Sets whether this issue is enabled by default.

Parameters:
enabledByDefault - whether the issue should be enabled by default
Returns:
this, for constructor chaining

getDetectorClass

public Class<? extends Detector> getDetectorClass()
Returns the class of the detector to use to find this issue

Returns:
the class of the detector to use to find this issue

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2008-2012. All Rights Reserved.