format

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package format implements the output formats decolint can write lint issues in: one-line-per-issue text, a JSON array, GitHub Actions workflow command annotations, and a SARIF 2.1.0 log.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GitHubFormat

type GitHubFormat struct{}

GitHubFormat prints one GitHub Actions workflow command (::error/::warning) per issue.

func (GitHubFormat) WriteIssues

func (GitHubFormat) WriteIssues(w io.Writer, issues []linter.Issue) error

WriteIssues writes issues to w as GitHub Actions workflow commands. Paths are written with "/" separators, which is what GitHub matches an annotation against.

type JSONFormat

type JSONFormat struct{}

JSONFormat prints a JSON array of issues.

func (JSONFormat) WriteIssues

func (JSONFormat) WriteIssues(w io.Writer, issues []linter.Issue) error

WriteIssues writes issues to w as a JSON array. It marshals into an in-memory buffer first so that a failure never leaves partial JSON on w.

type SARIFFormat added in v0.4.0

type SARIFFormat struct {
	// Version is the tool version recorded in the run.
	Version string
	// Rules is the rule catalog used to describe the rules referenced by issues.
	Rules []SARIFRule
}

SARIFFormat prints a SARIF 2.1.0 log, suitable for upload to GitHub Code Scanning.

func (SARIFFormat) WriteIssues added in v0.4.0

func (f SARIFFormat) WriteIssues(w io.Writer, issues []linter.Issue) error

WriteIssues writes issues to w as a SARIF 2.1.0 log with a single run. It marshals into an in-memory buffer first so that a failure never leaves partial output on w.

The run's rule catalog lists only the rules referenced by issues, sorted by rule ID; a rule missing from f.Rules is listed with its ID alone. Issue paths are reported as URIs; see [artifactURIFor].

type SARIFRule added in v0.4.0

type SARIFRule struct {
	ID          string
	Description string
	Category    string
}

SARIFRule describes one rule for the SARIF rule catalog. It mirrors the linter.Rule fields the SARIF output needs, so this package does not depend on the rules package.

type TextFormat

type TextFormat struct{}

TextFormat prints one line per issue, matching linter.Issue.String.

func (TextFormat) WriteIssues

func (TextFormat) WriteIssues(w io.Writer, issues []linter.Issue) error

WriteIssues writes issues to w, one line per issue.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL