/** * Returns false if the given issue has been disabled. This is just * a convenience method for {@code getSeverity(issue) != Severity.IGNORE}. * * @param issue the issue to check * @return false if the issue has been disabled */ public boolean isEnabled(Issue issue) { return getSeverity(issue) != Severity.IGNORE; }
/** * Returns false if the given issue has been disabled. This is just * a convenience method for {@code getSeverity(issue) != Severity.IGNORE}. * * @param issue the issue to check * @return false if the issue has been disabled */ public boolean isEnabled(@NonNull Issue issue) { return getSeverity(issue) != Severity.IGNORE; }
@Override public Severity getSeverity(Issue issue) { ensureInitialized(); Severity severity = mSeverity.get(issue.getId()); if (severity != null) { return severity; } if (mParent != null) { return mParent.getSeverity(issue); } return getDefaultSeverity(issue); }
@Override @NonNull public Severity getSeverity(@NonNull Issue issue) { ensureInitialized(); Severity severity = this.severity.get(issue.getId()); if (severity == null) { severity = this.severity.get(VALUE_ALL); } if (severity != null) { return severity; } if (parent != null) { return parent.getSeverity(issue); } return getDefaultSeverity(issue); }
private void formatError(String message, Object... args) { if (args != null && args.length > 0) { message = String.format(message, args); } message = "Failed to parse `lint.xml` configuration file: " + message; LintDriver driver = new LintDriver(new IssueRegistry() { @Override @NonNull public List<Issue> getIssues() { return Collections.emptyList(); } }, client); client.report(new Context(driver, project, project, configFile), IssueRegistry.LINT_ERROR, project.getConfiguration(driver).getSeverity(IssueRegistry.LINT_ERROR), Location.create(configFile), message, TextFormat.RAW); }
@Override public void report(Context context, Issue issue, Location location, String message, Object data) { Configuration configuration = context.configuration; if (!configuration.isEnabled(issue)) { if (issue != IssueRegistry.PARSER_ERROR) { mDelegate.log(null, "Incorrect detector reported disabled issue %1$s", issue.toString()); } return; } if (configuration.isIgnored(context, issue, location, message, data)) { return; } Severity severity = configuration.getSeverity(issue); if (severity == Severity.IGNORE) { return; } mDelegate.report(context, issue, location, message, data); }
protected void reportNonExistingIssueId(@Nullable Project project, @NonNull String id) { String message = String.format("Unknown issue id \"%1$s\"", id); if (driver != null && project != null) { Location location = Location.create(project.getDir()); if (!isSuppressed(IssueRegistry.LINT_ERROR)) { report(new Context(driver, project, project, project.getDir()), IssueRegistry.LINT_ERROR, project.getConfiguration(driver).getSeverity(IssueRegistry.LINT_ERROR), location, message, TextFormat.RAW); } } else { log(Severity.ERROR, null, "Lint: %1$s", message); } }
&& this.configuration.getSeverity(issue) == Severity.IGNORE) { return; Severity severity = configuration.getSeverity(issue); if (severity == Severity.IGNORE) { return;
client.report(new Context(driver, project, project, baselineFile), IssueRegistry.BASELINE, client.getConfiguration(project, driver).getSeverity(IssueRegistry.BASELINE), Location.create(baselineFile), message, TextFormat.RAW); client.report(new Context(driver, project, project, baselineFile), IssueRegistry.BASELINE, client.getConfiguration(project, driver).getSeverity(IssueRegistry.BASELINE), Location.create(baselineFile), message, TextFormat.RAW);
client.report(new Context(this, project, main, project.getDir()), IssueRegistry.LINT_ERROR, project.getConfiguration(this).getSeverity(IssueRegistry.LINT_ERROR), location, message, TextFormat.RAW); classEntries = Collections.emptyList();
@NonNull @Override protected Project createProject(@NonNull File dir, @NonNull File referenceDir) { Project project = super.createProject(dir, referenceDir); if (project.isGradleProject()) { @SuppressWarnings("SpellCheckingInspection") String message = String.format("\"`%1$s`\" is a Gradle project. To correctly " + "analyze Gradle projects, you should run \"`gradlew :lint`\" instead.", project.getName()); Location location = Location.create(project.getDir()); Context context = new Context(driver, project, project, project.getDir()); if (context.isEnabled(IssueRegistry.LINT_ERROR) && !getConfiguration(project, null).isIgnored(context, IssueRegistry.LINT_ERROR, location, message)) { report(context, IssueRegistry.LINT_ERROR, project.getConfiguration(null).getSeverity( IssueRegistry.LINT_ERROR), location, message, TextFormat.RAW); } } return project; }