Skip to content

Commit

Permalink
github-check: support diagnostic code
Browse files Browse the repository at this point in the history
  • Loading branch information
haya14busa committed Jul 26, 2020
1 parent a8c662f commit 60cf0d9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
7 changes: 7 additions & 0 deletions doghouse/server/doghouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,13 @@ func (ch *Checker) buildTitle(c *filter.FilteredDiagnostic) string {
sb.WriteString(fmt.Sprintf("-L%d", endLine))
}
}
if code := c.Diagnostic.GetCode().GetValue(); code != "" {
if url := c.Diagnostic.GetCode().GetUrl(); url != "" {
sb.WriteString(fmt.Sprintf(" <%s>(%s)", code, url))
} else {
sb.WriteString(fmt.Sprintf(" <%s>", code))
}
}
return sb.String()
}

Expand Down
36 changes: 36 additions & 0 deletions doghouse/server/doghouse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,26 @@ func TestCheck_OK(t *testing.T) {
},
},
},
{
Diagnostic: &rdf.Diagnostic{
Message: "code test w/o URL",
Location: &rdf.Location{
Path: "sample.new.txt",
Range: &rdf.Range{Start: &rdf.Position{Line: 2}},
},
Code: &rdf.Code{Value: "CODE14"},
},
},
{
Diagnostic: &rdf.Diagnostic{
Message: "code test w/ URL",
Location: &rdf.Location{
Path: "sample.new.txt",
Range: &rdf.Range{Start: &rdf.Position{Line: 2}},
},
Code: &rdf.Code{Value: "CODE14", Url: "https://github.com/reviewdog#CODE14"},
},
},
{
Path: "sample.new.txt",
Line: 2,
Expand Down Expand Up @@ -247,6 +267,22 @@ func TestCheck_OK(t *testing.T) {
Message: github.String("source test"),
Title: github.String("[awesome-linter] sample.new.txt#L2"),
},
{
Path: github.String("sample.new.txt"),
StartLine: github.Int(2),
EndLine: github.Int(2),
AnnotationLevel: github.String("warning"),
Message: github.String("code test w/o URL"),
Title: github.String("[haya14busa-linter] sample.new.txt#L2 <CODE14>"),
},
{
Path: github.String("sample.new.txt"),
StartLine: github.Int(2),
EndLine: github.Int(2),
AnnotationLevel: github.String("warning"),
Message: github.String("code test w/ URL"),
Title: github.String("[haya14busa-linter] sample.new.txt#L2 <CODE14>(https://github.com/reviewdog#CODE14)"),
},
{
Path: github.String("sample.new.txt"),
StartLine: github.Int(2),
Expand Down

0 comments on commit 60cf0d9

Please sign in to comment.