Skip to content

Commit

Permalink
Update Description#getLink() to use the raw link URL, not " (see $link)"
Browse files Browse the repository at this point in the history
RELNOTES: N/A

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=154782117
  • Loading branch information
nick-someone authored and ronshapiro committed May 2, 2017
1 parent 39e530b commit 6a53645
Showing 1 changed file with 22 additions and 22 deletions.
Expand Up @@ -60,12 +60,8 @@ public class Description {
*/ */
private final String rawMessage; private final String rawMessage;


/** /** The raw link URL for the check. May be null if there is no link. */
* The link to include in the error message. May be null if there is no link. @Nullable private final String linkUrl;
*/
@Nullable
private final String link;

/** /**
* A list of fixes to suggest in an error message or use in automated refactoring. Fixes are * A list of fixes to suggest in an error message or use in automated refactoring. Fixes are
* in order of decreasing preference, from most preferred to least preferred. * in order of decreasing preference, from most preferred to least preferred.
Expand All @@ -85,12 +81,10 @@ public String getMessage() {
return String.format("[%s] %s", checkName, getMessageWithoutCheckName()); return String.format("[%s] %s", checkName, getMessageWithoutCheckName());
} }


/** /** Returns a link associated with this finding or null if there is no link. */
* Returns link to be included in the error message or null if there is no link.
*/
@Nullable @Nullable
public String getLink() { public String getLink() {
return link; return linkUrl;
} }


/** Returns the raw message, not including a link or check name. */ /** Returns the raw message, not including a link or check name. */
Expand All @@ -102,41 +96,48 @@ public String getRawMessage() {
* Returns the message, not including the check name but including the link. * Returns the message, not including the check name but including the link.
*/ */
public String getMessageWithoutCheckName() { public String getMessageWithoutCheckName() {
return link != null return linkUrl != null
? String.format("%s\n%s", rawMessage, link) ? String.format("%s\n%s", rawMessage, linkTextForDiagnostic(linkUrl))
: String.format("%s", rawMessage); : String.format("%s", rawMessage);
} }


/** TODO(cushon): Remove this constructor and ensure that there's always a check name. */ /** TODO(cushon): Remove this constructor and ensure that there's always a check name. */
public Description(Tree node, String message, Fix suggestedFix, @Deprecated
BugPattern.SeverityLevel severity) { public Description(
Tree node, String message, Fix suggestedFix, BugPattern.SeverityLevel severity) {
this(node, UNDEFINED_CHECK_NAME, message, message, ImmutableList.of(suggestedFix), severity); this(node, UNDEFINED_CHECK_NAME, message, message, ImmutableList.of(suggestedFix), severity);
if (suggestedFix == null) { if (suggestedFix == null) {
throw new IllegalArgumentException("suggestedFix must not be null."); throw new IllegalArgumentException("suggestedFix must not be null.");
} }
} }


private Description(Tree node, String checkName, String rawMessage, String link, private Description(
ImmutableList<Fix> fixes, BugPattern.SeverityLevel severity) { Tree node,
String checkName,
String rawMessage,
String linkUrl,
ImmutableList<Fix> fixes,
SeverityLevel severity) {
this.node = node; this.node = node;
this.checkName = checkName; this.checkName = checkName;
this.rawMessage = rawMessage; this.rawMessage = rawMessage;
this.link = link; this.linkUrl = linkUrl;
this.fixes = fixes; this.fixes = fixes;
this.severity = severity; this.severity = severity;
} }


@CheckReturnValue @CheckReturnValue
public Description applySeverityOverride(SeverityLevel severity) { public Description applySeverityOverride(SeverityLevel severity) {
return new Description(node, checkName, rawMessage, link, fixes, severity); return new Description(node, checkName, rawMessage, linkUrl, fixes, severity);
} }


@CheckReturnValue @CheckReturnValue
public Description filterFixes(Predicate<? super Fix> predicate) { public Description filterFixes(Predicate<? super Fix> predicate) {
return new Description(node, return new Description(
node,
checkName, checkName,
rawMessage, rawMessage,
link, linkUrl,
ImmutableList.copyOf(Iterables.filter(fixes, predicate)), ImmutableList.copyOf(Iterables.filter(fixes, predicate)),
severity); severity);
} }
Expand Down Expand Up @@ -225,8 +226,7 @@ public Builder setMessage(String message) {
} }


public Description build() { public Description build() {
return new Description(node, name, rawMessage, linkTextForDiagnostic(linkUrl), return new Description(node, name, rawMessage, linkUrl, fixListBuilder.build(), severity);
fixListBuilder.build(), severity);
} }
} }


Expand Down

0 comments on commit 6a53645

Please sign in to comment.