Refine search
@Override public void visitAttribute(XmlContext xmlContext, Attr attr) { String fileName = xmlContext.file.getName(); if (!fileName.equals(ONLY_FILE_ALLOWED_TO_HAVE_HARDCODED_COLORS)) { String value = attr.getValue(); if (value.startsWith(HARDCODED_COLOR_PREFIX)) { xmlContext.report(ISSUE, attr, xmlContext.getLocation(attr), ISSUE.getBriefDescription(TextFormat.TEXT)); } } }
/** * 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. * * @param other the {@link Issue} to compare this issue to */ @Override public int compareTo(@NonNull Issue other) { return getId().compareTo(other.getId()); }
/** * Returns all available issues of a given scope (regardless of whether * they are actually enabled for a given configuration etc) * * @param scope the applicable scope set * @return a list of issues */ @NonNull protected List<Issue> getIssuesForScope(@NonNull EnumSet<Scope> scope) { List<Issue> list = scopeIssues.get(scope); if (list == null) { List<Issue> issues = getIssues(); if (scope.equals(Scope.ALL)) { list = issues; } else { list = new ArrayList<>(getIssueCapacity(scope)); for (Issue issue : issues) { // Determine if the scope matches if (issue.getImplementation().isAdequate(scope)) { list.add(issue); } } } scopeIssues.put(scope, list); } return list; }
/** * Returns the severity for a given issue. This is the same as the * {@link Issue#getDefaultSeverity()} unless the user has selected a custom * severity (which is tool context dependent). * * @param issue the issue to look up the severity from * @return the severity use for issues for the given detector */ public Severity getSeverity(@NonNull Issue issue) { return issue.getDefaultSeverity(); }
writer.write(String.format("%1$d / 10", issue.getPriority())); writer.write("<br/>\n"); writer.write("Category: "); writer.write(issue.getCategory().getFullName()); writer.write("</div>\n"); String description = issue.getBriefDescription(HTML); writer.write(description); if (!description.isEmpty() String explanationHtml = issue.getExplanation(HTML); writer.write(explanationHtml); writer.write("\n</div>\n"); List<String> moreInfo = issue.getMoreInfo(); writer.write("<br/>"); writer.write("<div class=\"moreinfo\">"); "To suppress this error, use the issue id \"%1$s\" as explained in the " + "%2$sSuppressing Warnings and Errors%3$s section.", issue.getId(), "<a href=\"#SuppressInfo\">", "</a>")); writer.write("<br/>\n");
private static boolean isIgnoredInIde(@NonNull Issue issue, @NonNull JavaContext context, @NonNull PsiElement node) { // Historically, the IDE would treat *all* support annotation warnings as // handled by the id "ResourceType", so look for that id too for issues // deliberately suppressed prior to Android Studio 2.0. Issue synonym = Issue.create("ResourceType", issue.getBriefDescription(TextFormat.RAW), issue.getExplanation(TextFormat.RAW), issue.getCategory(), issue.getPriority(), issue.getDefaultSeverity(), issue.getImplementation()); return context.getDriver().isSuppressed(context, synonym, node); }
Issue issue = first.issue; if (issue.getCategory() != previousCategory) { previousCategory = issue.getCategory(); writer.write("\n<a name=\""); writer.write(issue.getCategory().getFullName()); writer.write("\"></a>\n"); writer.write("<div class=\"category\"><a href=\"#\" title=\"Return to top\">"); writer.write(issue.getCategory().getFullName()); writer.write("</a><div class=\"categorySeparator\"></div>\n"); writer.write("</div>\n"); writer.write("<a name=\"" + issue.getId() + "\"></a>\n"); writer.write("<div class=\"issue\">\n"); writer.write(issue.getId()); writer.write(": "); writer.write(issue.getBriefDescription(HTML)); writer.write("</a><div class=\"issueSeparator\"></div>\n"); writer.write("</div>\n"); for (Warning warning : warnings) { if (partialHide && count == SHOWN_COUNT) { String id = warning.issue.getId() + "Div"; writer.write("<button id=\""); writer.write(id);
private boolean findAndMark(@NonNull Issue issue, @NonNull Location location, @NonNull String message, @Nullable Severity severity) { Collection<Entry> entries = messageToEntry.get(message); if (entries == null || entries.isEmpty()) { String issueId = issue.getId(); for (Entry entry : entries) { if (entry.issueId.equals(issueId)) { severity = issue.getDefaultSeverity();
@Override public int compareTo(@NonNull ReportedEntry other) { int categoryDelta = issue.getCategory().compareTo(other.issue.getCategory()); if (categoryDelta != 0) { return categoryDelta; int priorityDelta = other.issue.getPriority() - issue.getPriority(); if (priorityDelta != 0) { return priorityDelta; String id1 = issue.getId(); String id2 = other.issue.getId(); int idDelta = id1.compareTo(id2); if (idDelta != 0) {
@NonNull protected Severity getDefaultSeverity(@NonNull Issue issue) { if (!issue.isEnabledByDefault()) { return Severity.IGNORE; } return issue.getDefaultSeverity(); }
private void explainIssue(@NonNull StringBuilder output, @Nullable Issue issue) throws IOException { if (issue == null || !flags.isExplainIssues() || issue == IssueRegistry.LINT_ERROR) { String explanation = issue.getExplanation(TextFormat.TEXT); if (explanation.trim().isEmpty()) { return; output.append('\n'); output.append(indent); output.append("Explanation for issues of type \"").append(issue.getId()).append("\":\n"); for (String line : Splitter.on('\n').split(formatted)) { if (!line.isEmpty()) { List<String> moreInfo = issue.getMoreInfo(); if (!moreInfo.isEmpty()) { for (String url : moreInfo) {
@NonNull final List<? extends Detector> createDetectors( @NonNull LintClient client, @NonNull Configuration configuration, @NonNull EnumSet<Scope> scope, @Nullable Map<Scope, List<Detector>> scopeToDetectors) { Implementation implementation = issue.getImplementation(); Class<? extends Detector> detectorClass = implementation.getDetectorClass(); EnumSet<Scope> issueScope = implementation.getScope(); assert detectorClass != null : issue.getId(); detectorClasses.add(detectorClass);
@NonNull @Override public List<Issue> getIssues() { List<Issue> issues = super.getIssues(); if (!mInitialized) { mInitialized = true; for (Issue issue : issues) { if (issue.getImplementation().getDetectorClass() == GradleDetector.class) { issue.setImplementation(GroovyGradleDetector.IMPLEMENTATION); } } } return issues; } }
@NonNull private List<Category> createCategoryList() { Set<Category> categorySet = Sets.newHashSetWithExpectedSize(20); for (Issue issue : getIssues()) { categorySet.add(issue.getCategory()); } List<Category> sorted = new ArrayList<>(categorySet); Collections.sort(sorted); return sorted; }
/** * Creates a new issue. The description strings can use some simple markup; * see the {@link TextFormat#RAW} documentation * for details. * * @param id the fixed id of the issue * @param briefDescription short summary (typically 5-6 words or less), typically * describing the <b>problem</b> rather than the <b>fix</b> * (e.g. "Missing minSdkVersion") * @param explanation a full explanation of the issue, with suggestions for * how to fix it * @param category the associated category, if any * @param priority the priority, a number from 1 to 10 with 10 being most * important/severe * @param severity the default severity of the issue * @param implementation the default implementation for this issue * @return a new {@link Issue} */ @NonNull public static Issue create( @NonNull String id, @NonNull String briefDescription, @NonNull String explanation, @NonNull Category category, int priority, @NonNull Severity severity, @NonNull Implementation implementation) { return new Issue(id, briefDescription, explanation, category, priority, severity, implementation); }
@Override public void report( @NonNull Context context, @NonNull Issue issue, @NonNull Severity severity, @NonNull Location location, @NonNull String message, if (issue != IssueRegistry.PARSER_ERROR && issue != IssueRegistry.LINT_ERROR) { mDelegate.log(null, "Incorrect detector reported disabled issue %1$s", issue.toString());
private static void describeIssue(Issue issue) { System.out.println(issue.getId()); for (int i = 0; i < issue.getId().length(); i++) { System.out.print('-'); } System.out.println(); System.out.println(wrap("Summary: " + issue.getBriefDescription(TEXT))); System.out.println("Priority: " + issue.getPriority() + " / 10"); System.out.println("Severity: " + issue.getDefaultSeverity().getDescription()); System.out.println("Category: " + issue.getCategory().getFullName()); if (!issue.isEnabledByDefault()) { System.out.println("NOTE: This issue is disabled by default!"); System.out.println(String.format("You can enable it by adding %1$s %2$s", ARG_ENABLE, issue.getId())); } System.out.println(); System.out.println(wrap(issue.getExplanation(TEXT))); List<String> moreInfo = issue.getMoreInfo(); if (!moreInfo.isEmpty()) { System.out.println("More information: "); for (String uri : moreInfo) { System.out.println(uri); } } }
private static void listIssue(PrintStream out, Issue issue) { out.print(wrapArg("\"" + issue.getId() + "\": " + issue.getBriefDescription(TEXT))); }
if (issue.getCategory() != previousCategory) { writer.write("<tr><td></td><td class=\"categoryColumn\">"); previousCategory = issue.getCategory(); String categoryName = issue.getCategory().getFullName(); writer.write("<a href=\"#"); writer.write(categoryName); writer.write(issue.getId()); writer.write("\">"); writer.write(issue.getId()); writer.write(": "); writer.write(issue.getBriefDescription(HTML)); writer.write("</a>\n");
private static String getExplanationId(Issue issue) { return "explanation" + issue.getId(); }