fmts

package
v0.0.0-...-739e471 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 2 Imported by: 17

README

How to add errorformat for new tool

1) Download errorformat CLI tool for debugging (optional)

go get -u github.com/reviewdog/errorformat/cmd/errorformat

2) Write errorformat for the target output

Note that https://github.com/reviewdog/errorformat doesn't support Vim regex, and efm-%> feature (currently). Other syntax are supported.

Example (add errorformat for golint)

Prepare output of golint.

$ golint ./... > golint.in
golint.in
golint.new.go:3:5: exported var V should have comment or be unexported
golint.new.go:5:5: exported var NewError1 should have comment or be unexported
golint.new.go:7:1: comment on exported function F should be of the form "F ..."
golint.new.go:11:1: comment on exported function F2 should be of the form "F2 ..."

Write errorformat for it.

$ errorformat "%f:%l:%c: %m" < golint.in
golint.new.go|3 col 5| exported var V should have comment or be unexported
golint.new.go|5 col 5| exported var NewError1 should have comment or be unexported
golint.new.go|7 col 1| comment on exported function F should be of the form "F ..."
golint.new.go|11 col 1| comment on exported function F2 should be of the form "F2 ..."

3) Add errorformat with test

Add errorformat in fmts/{lang}.go, where {lang} is target programming language (or filetype) of the command.

fmts/go.go
func init() {
	const lang = "go"

  // ...

	register(&Fmt{
		Name: "golint",
		Errorformat: []string{
			`%f:%l:%c: %m`,
		},
		Description: "linter for Go source code",
		URL:         "https://github.com/golang/lint",
		Language:    lang,
	})

  // ...
}

Required fields are self descriptive. See https://godoc.org/github.com/reviewdog/errorformat/fmts#Fmt

fmts/testdata/golint.in

Add input file in fmts/testdata/{name}.in

golint.new.go:3:5: exported var V should have comment or be unexported
golint.new.go:5:5: exported var NewError1 should have comment or be unexported
golint.new.go:7:1: comment on exported function F should be of the form "F ..."
golint.new.go:11:1: comment on exported function F2 should be of the form "F2 ..."

I also recommend to add resource code to reproduce this input file in fmts/testdata/resources/{lang}/{name}

fmts/testdata/golint.ok

Add ok file in fmts/testdata/{name}.ok

golint.new.go|3 col 5| exported var V should have comment or be unexported
golint.new.go|5 col 5| exported var NewError1 should have comment or be unexported
golint.new.go|7 col 1| comment on exported function F should be of the form "F ..."
golint.new.go|11 col 1| comment on exported function F2 should be of the form "F2 ..."

You can run test by go test ./...

4) go generate ./...

Run go generate ./... to update document file.

5) Open Pull-Request!

Documentation

Overview

Package fmts holds defined errorformats.

Defined formats:

ansible
	ansible-lint	(ansible-lint -p playbook.yml) Checks playbooks for practices and behaviour that could potentially be improved - https://github.com/ansible/ansible-lint
common
	misspell	Correct commonly misspelled English words in source files - https://github.com/client9/misspell
	typos	Source code spell checker - https://github.com/crate-ci/typos
csharp
	dotnet	(dotnet build -clp:NoSummary -p:GenerateFullPaths=true --no-incremental --nologo -v q) .NET Core CLI - https://docs.microsoft.com/en-us/dotnet/core/tools/
	msbuild	(msbuild /property:GenerateFullPaths=true /nologo /v:q) Microsoft Build Engine - https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild
css
	stylelint	A mighty modern CSS linter - https://github.com/stylelint/stylelint
env
	dotenv-linter	Lightning-fast linter for .env files. Written in Rust - https://github.com/dotenv-linter/dotenv-linter
go
	go-consistent	Source code analyzer that helps you to make your Go programs more consistent - https://github.com/quasilyte/go-consistent
	golangci-lint	(golangci-lint run --out-format=line-number) GolangCI-Lint is a linters aggregator. - https://github.com/golangci/golangci-lint
	golint	linter for Go source code - https://github.com/golang/lint
	gosec	(gosec -fmt=golint) Golang Security Checker - https://github.com/securego/gosec
	govet	Vet examines Go source code and reports suspicious problems - https://golang.org/cmd/vet/
	staticcheck	Golang Static Analysis - https://staticcheck.io
haml
	haml-lint	Tool for writing clean and consistent HAML - https://github.com/sds/haml-lint
haskell
	hlint	Linter for Haskell source code - https://github.com/ndmitchell/hlint
javascript
	eslint	(eslint [-f stylish]) A fully pluggable tool for identifying and reporting on patterns in JavaScript - https://github.com/eslint/eslint
	eslint-compact	(eslint -f compact) A fully pluggable tool for identifying and reporting on patterns in JavaScript - https://github.com/eslint/eslint
	standardjs	(standard) JavaScript style guide, linter, and formatter - https://github.com/standard/standard
lua
	luacheck	(luacheck --formatter=plain) Lua linter and static analyzer - https://github.com/luarocks/luacheck
markdown
	remark-lint	Tool for writing clean and consistent markdown code - https://github.com/remarkjs/remark-lint
php
	phpstan	(phpstan --error-format=raw) PHP Static Analysis Tool - discover bugs in your code without running it! - https://github.com/phpstan/phpstan
	psalm	(psalm --output-format=text) Psalm is a static analysis tool for finding errors in PHP - https://github.com/vimeo/psalm
protocolbuffer
	buf	A new way of working with Protocol Buffers. - https://github.com/bufbuild/buf
	protolint	A pluggable linting utility for Protocol Buffer files - https://github.com/yoheimuta/protolint
puppet
	puppet-lint	Check that your Puppet manifests conform to the style guide - https://github.com/rodjek/puppet-lint
python
	bandit	A tool designed to find common security issues in Python code. - https://github.com/PyCQA/bandit.git
	black	A uncompromising Python code formatter - https://github.com/psf/black
	flake8	Tool for python style guide enforcement - https://flake8.pycqa.org/
	isort	A Python utility / library to sort Python imports - https://github.com/PyCQA/isort
	mypy	An optional static type checker for Python - http://mypy-lang.org/
	pep8	Python style guide checker - https://pypi.python.org/pypi/pep8
	pydocstyle	A static analysis tool for checking compliance with Python docstring conventions - https://github.com/PyCQA/pydocstyle
ruby
	brakeman	(brakeman --quiet --format tabs) A static analysis security vulnerability scanner for Ruby on Rails applications - https://github.com/presidentbeef/brakeman
	erb-lint	(erblint --format compact) Lint your ERB or HTML files - https://github.com/Shopify/erb-lint
	fasterer	Speed improvements suggester - https://github.com/DamirSvrtan/fasterer
	reek	(reek --single-line) Code smell detector for Ruby - https://github.com/troessner/reek
	rubocop	A Ruby static code analyzer, based on the community Ruby style guide - https://github.com/rubocop-hq/rubocop
	sorbet	A fast, powerful type checker designed for Ruby - https://github.com/sorbet/sorbet
	standardrb	(standard) Ruby style guide, linter, and formatter - https://github.com/testdouble/standard
rust
	cargo-check	(cargo check -q --message-format=short) Check a local package and all of its dependencies for errors - https://github.com/rust-lang/cargo
	clippy	(cargo clippy -q --message-format=short) A bunch of lints to catch common mistakes and improve your Rust code - https://github.com/rust-lang/rust-clippy
scala
	sbt	the interactive build tool - http://www.scala-sbt.org/
	sbt-scalastyle	Scalastyle - SBT plugin - http://www.scalastyle.org/sbt.html
	scalac	Scala compiler - http://www.scala-lang.org/
	scalastyle	Scalastyle - Command line - http://www.scalastyle.org/command-line.html
slim
	slim-lint	Tool to help keep your Slim files clean and readable - https://github.com/sds/slim-lint
typescript
	tsc	TypeScript compiler - https://www.typescriptlang.org/
	tslint	An extensible linter for the TypeScript language - https://github.com/palantir/tslint
yaml
	yamllint	(yamllint -f parsable) A linter for YAML files - https://github.com/adrienverge/yamllint

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefinedFmtsByLang

func DefinedFmtsByLang() map[string]Fmts

DefinedFmtsByLang returns all defined errorformats by language.

Types

type Fmt

type Fmt struct {
	// name of this errorformat (recommends program name and must be uniq)
	Name string

	// Errorformat is list of 'errorformat'
	Errorformat []string

	// one-line description
	Description string

	// Reference URL if any
	URL string

	// Target Programming Language of the program.
	Language string
}

Fmt represents defined errorformat

type Fmts

type Fmts map[string]*Fmt

Fmts holds all defined Fmt in this package. key is Fmt.Name.

func DefinedFmts

func DefinedFmts() Fmts

DefinedFmts returns all defined errorformats.

Jump to

Keyboard shortcuts

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