Documentation
¶
Overview ¶
Rule is the stable name of one clickylint check, so a report can be suppressed, filtered or re-levelled by name instead of by its message text.
Suppression of individual clickylint findings through a source directive, so a deliberate exception is recorded where it is made rather than argued for in a review thread.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( RuleTextStructLiteral = Rule{ID: "text-struct-literal", Severity: SeverityWarning} RuleHelperBackedLiteral = Rule{ID: "helper-backed-literal", Severity: SeverityWarning} RuleContentConcat = Rule{ID: "content-concatenation", Severity: SeverityWarning} RuleContentSprintf = Rule{ID: "content-sprintf", Severity: SeverityWarning} RuleChildrenLiteral = Rule{ID: "children-literal", Severity: SeverityWarning} RuleTextReturnType = Rule{ID: "text-return-type", Severity: SeverityWarning} RuleRenderInPretty = Rule{ID: "render-in-pretty", Severity: SeverityWarning} RuleDirectStdout = Rule{ID: "direct-stdout", Severity: SeverityError} RuleManualCobraCommand = Rule{ID: "manual-cobra-command", Severity: SeverityError} RuleDirectHTTPHandler = Rule{ID: "direct-http-handler", Severity: SeverityWarning} RuleServeMuxParameter = Rule{ID: "servemux-parameter", Severity: SeverityWarning} RuleEntityTableProvider = Rule{ID: "entity-table-provider", Severity: SeverityWarning} )
The rule catalogue. Adding a check means adding its rule here first, so every diagnostic is addressable from the moment it can be emitted.
Functions ¶
Types ¶
type Result ¶
type Result struct {
Linter string `json:"linter"`
WorkDir string `json:"work_dir,omitempty"`
PackageCount int `json:"package_count"`
Success bool `json:"success"`
Duration time.Duration `json:"duration"`
Violations []Violation `json:"violations,omitempty"`
Errors []string `json:"errors,omitempty"`
}
Result is the normalized lint result rendered by the CLI and JSON output.
func Run ¶
func Run(opts RunOptions) (*Result, error)
Run loads the requested Go packages, runs clickylint, and returns normalized diagnostics without printing through the go/analysis default text driver.
func (*Result) ErrorCount ¶ added in v1.21.29
ErrorCount counts error-severity violations.
func (*Result) HasErrors ¶ added in v1.21.29
HasErrors reports whether the run found error-severity violations or execution errors. This — not HasIssues — drives the non-zero exit status; warnings are advisory.
func (*Result) HasIssues ¶
HasIssues reports whether the lint run found any diagnostics (error or warning) or execution errors. Used to decide whether output is worth showing.
func (*Result) WarningCount ¶ added in v1.21.29
WarningCount counts warning-severity violations.
type Rule ¶ added in v1.21.68
Rule names a check and carries the severity it reports at by default. The ID is part of clickylint's contract: it appears in JSON output and is what a //clicky:allow directive and a severity override both address. Message wording is free to change; an ID is not.
type RunOptions ¶
type RunOptions struct {
Packages []string `json:"packages,omitempty"`
WorkDir string `json:"work_dir,omitempty"`
IncludeTests bool `json:"include_tests"`
// Severity re-levels individual rules by ID, so a codebase can adopt a rule
// as advice before it adopts it as a gate. Unknown IDs are reported as run
// errors rather than ignored: a typo that silently kept a rule failing the
// build would be worse than a loud one.
Severity map[string]Severity `json:"severity,omitempty"`
}
RunOptions controls the standalone clickylint runner used by the clicky CLI.
type Severity ¶ added in v1.21.29
type Severity string
Severity classifies a clickylint diagnostic. Errors fail the lint run (non-zero exit); warnings are advisory and do not affect the exit status.
const ( // SeverityError marks violations that fail the run: writes that corrupt the // task renderer, and manual cobra commands that bypass the generated CLI, // REST and MCP surfaces entirely. SeverityError Severity = "error" // SeverityWarning marks advice — how Pretty()/render builders are written, // entities missing a TableProvider, and routes registered outside the // router. A codebase adopting a rule re-levels it with RunOptions.Severity // rather than each rule carrying a second, configurable default. SeverityWarning Severity = "warning" )
type SummaryView ¶
type SummaryView struct {
Result *Result `json:"result"`
Limit int `json:"-"`
// contains filtered or unexported fields
}
SummaryView renders clickylint results as a compact tree, matching the Gavel lint display shape: root -> linter -> rule -> affected files.
func NewSummaryView ¶
func NewSummaryView(result *Result, limit int) *SummaryView
NewSummaryView returns a tree view for a lint result.
func (*SummaryView) GetChildren ¶
func (s *SummaryView) GetChildren() []api.TreeNode
func (*SummaryView) LoadSource ¶ added in v1.21.70
func (s *SummaryView) LoadSource(lineCount int) error
LoadSource preloads source windows for the summary's diagnostic locations. lineCount is the total number of source lines in each window.
func (*SummaryView) Pretty ¶
func (s *SummaryView) Pretty() api.Text
type Violation ¶
type Violation struct {
Package string `json:"package,omitempty"`
File string `json:"file,omitempty"`
Line int `json:"line,omitempty"`
Column int `json:"column,omitempty"`
Severity Severity `json:"severity,omitempty"`
Rule string `json:"rule,omitempty"`
Message string `json:"message,omitempty"`
}
Violation is a display-oriented analysis diagnostic.