Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ private Description checkRestriction(
SeverityLevel level = warn ? SeverityLevel.WARNING : SeverityLevel.ERROR;
Description.Builder description =
buildDescription(where).setMessage(restriction.explanation()).overrideSeverity(level);
if (!restriction.link().isEmpty()) {
description.setLinkUrl(restriction.link());
}
return description.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,31 @@ void foo(RestrictedApiMethods m) {
.doTest();
}

@Test
public void restrictedCallProhibited_withLink() {
helper
.addSourceLines(
"Testcase.java",
"""
package separate.test;

import com.google.errorprone.annotations.RestrictedApi;

class Testcase {
void caller() {
// BUG: Diagnostic contains: test
// (see http://example.com)
restrictedMethod();
}

@RestrictedApi(explanation = "test", link = "http://example.com")
void restrictedMethod() {}
}
""")
.expectResult(Result.ERROR)
.doTest();
}

@Test
public void restrictedCallProhibited_inherited() {
helper
Expand Down
Loading