Skip to content

Commit

Permalink
add warnings for unused identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
cezar-guimaraes committed Mar 22, 2024
1 parent 2e54c76 commit 62c1149
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion internal/tekton/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (d *Document) diagnostics(c chan<- *protocol.Diagnostic) {
}

sev := protocol.DiagnosticSeverityError
src := "validation"
src := fmt.Sprintf("unknown-%s", ref.kind)

c <- &protocol.Diagnostic{
Range: protocol.Range{
Expand All @@ -30,6 +30,25 @@ func (d *Document) diagnostics(c chan<- *protocol.Diagnostic) {
Source: &src,
}
}
for _, id := range d.identifiers {
if len(id.references) != 0 {
continue
}

if id.kind == IdentKindPipelineTask {
continue
}

sev := protocol.DiagnosticSeverityWarning
src := fmt.Sprintf("unused-%s", id.kind)

c <- &protocol.Diagnostic{
Range: id.location.Range,
Message: fmt.Sprintf("unused %s %s", id.kind, id.meta.Name()),
Severity: &sev,
Source: &src,
}
}
}

var syntaxErrorRegexp = regexp.MustCompile(`(?s)^\[(\d+):(\d+)\] (.+)`)
Expand Down

0 comments on commit 62c1149

Please sign in to comment.