Skip to content

Commit

Permalink
Show issues on result view
Browse files Browse the repository at this point in the history
  • Loading branch information
nakabonne committed May 2, 2020
1 parent e9c242e commit c7fd936
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
11 changes: 11 additions & 0 deletions pkg/golangcilint/issue.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package golangcilint

import (
"fmt"

"github.com/golangci/golangci-lint/pkg/result"
)

Expand All @@ -20,3 +22,12 @@ func NewIssues(issues []result.Issue) []Issue {
func (i *Issue) FromLinter() string {
return i.issue.FromLinter
}

func (i *Issue) Message() string {
return fmt.Sprintf("%s:%d:%d: %s",
i.issue.FilePath(),
i.issue.Line(),
i.issue.Column(),
i.issue.Text,
)
}
15 changes: 13 additions & 2 deletions pkg/gui/item/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,21 @@ func (r *Results) addChildren(node *tview.TreeNode, issues []golangcilint.Issue)
}

for linter := range linterIssues {
child := tview.NewTreeNode(linter).
SetText("from " + linter).
// Add a reporting linter to root as children.
child := tview.NewTreeNode("reported by " + linter).
SetReference(linter).
SetSelectable(true).
SetColor(tcell.ColorAqua)
node.AddChild(child)

// Add issues to reporting linters as children.
issues := linterIssues[linter]
for _, i := range issues {
grandchild := tview.NewTreeNode(i.Message()).
SetReference(i).
SetSelectable(true).
SetColor(tcell.ColorWhite)
child.AddChild(grandchild)
}
}
}

0 comments on commit c7fd936

Please sign in to comment.