From 16794747803a2b5d654fd304f8ecc5ca7fff65cb Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Mon, 27 Apr 2020 17:00:01 -0400 Subject: [PATCH] go/analysis: suggest to users how to associate diagnostics with severities MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add to the go/analysis docs the suggestion made by Ian Cottrell that diagnostic severities should be classified by analyzer. Updates golang/go#34508 Change-Id: I9a75fb1400269ece32c9ca52afbf6c7975d3e205 Reviewed-on: https://go-review.googlesource.com/c/tools/+/230312 Run-TryBot: Michael Matloob Reviewed-by: Daniel Martí Reviewed-by: Ian Cottrell TryBot-Result: Gobot Gobot --- go/analysis/doc.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/go/analysis/doc.go b/go/analysis/doc.go index ea56b724e8..fb17a0e415 100644 --- a/go/analysis/doc.go +++ b/go/analysis/doc.go @@ -170,6 +170,15 @@ Diagnostic is defined as: The optional Category field is a short identifier that classifies the kind of message when an analysis produces several kinds of diagnostic. +Many analyses want to associate diagnostics with a severity level. +Because Diagnostic does not have a severity level field, an Analyzer's +diagnostics effectively all have the same severity level. To separate which +diagnostics are high severity and which are low severity, expose multiple +Analyzers instead. Analyzers should also be separated when their +diagnostics belong in different groups, or could be tagged differently +before being shown to the end user. Analyzers should document their severity +level to help downstream tools surface diagnostics properly. + Most Analyzers inspect typed Go syntax trees, but a few, such as asmdecl and buildtag, inspect the raw text of Go source files or even non-Go files such as assembly. To report a diagnostic against a line of a