Java Code Examples for com.android.tools.lint.detector.api.Issue#getId()

The following examples show how to use com.android.tools.lint.detector.api.Issue#getId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LintDriver.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
private static boolean matches(@Nullable Issue issue, @NonNull String id) {
    if (id.equalsIgnoreCase(SUPPRESS_ALL)) {
        return true;
    }

    if (issue != null) {
        String issueId = issue.getId();
        if (id.equalsIgnoreCase(issueId)) {
            return true;
        }
        if (id.startsWith(STUDIO_ID_PREFIX)
            && id.regionMatches(true, STUDIO_ID_PREFIX.length(), issueId, 0, issueId.length())
            && id.substring(STUDIO_ID_PREFIX.length()).equalsIgnoreCase(issueId)) {
            return true;
        }
    }

    return false;
}
 
Example 2
Source File: DefaultConfiguration.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setSeverity(@NonNull Issue issue, @Nullable Severity severity) {
    ensureInitialized();

    String id = issue.getId();
    if (severity == null) {
        mSeverity.remove(id);
    } else {
        mSeverity.put(id, severity);
    }

    if (!mBulkEditing) {
        writeConfig();
    }
}
 
Example 3
Source File: BuiltinIssueRegistryTest.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public void testUnique() {
    // Check that ids are unique
    Set<String> ids = new HashSet<String>();
    for (Issue issue : new BuiltinIssueRegistry().getIssues()) {
        String id = issue.getId();
        assertTrue("Duplicate id " + id, !ids.contains(id));
        ids.add(id);
    }
}
 
Example 4
Source File: LintCliClient.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private Severity computeSeverity(@NonNull Issue issue) {
    Severity severity = super.getSeverity(issue);

    String id = issue.getId();
    Set<String> suppress = mFlags.getSuppressedIds();
    if (suppress.contains(id)) {
        return Severity.IGNORE;
    }

    Severity manual = mFlags.getSeverityOverrides().get(id);
    if (manual != null) {
        return manual;
    }

    Set<String> enabled = mFlags.getEnabledIds();
    Set<String> check = mFlags.getExactCheckedIds();
    if (enabled.contains(id) || (check != null && check.contains(id))) {
        // Overriding default
        // Detectors shouldn't be returning ignore as a default severity,
        // but in case they do, force it up to warning here to ensure that
        // it's run
        if (severity == Severity.IGNORE) {
            severity = issue.getDefaultSeverity();
            if (severity == Severity.IGNORE) {
                severity = Severity.WARNING;
            }
        }

        return severity;
    }

    if (check != null && issue != LINT_ERROR && issue != PARSER_ERROR) {
        return Severity.IGNORE;
    }

    return severity;
}