fmts

package
v0.0.0-...-b91f67e Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2019 License: MIT Imports: 2 Imported by: 0

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 recoomends 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:

css
	stylelint	A mighty modern CSS linter - https://github.com/stylelint/stylelint
go
	golint	linter for Go source code - https://github.com/golang/lint
	govet	Vet examines Go source code and reports suspicious problems - https://golang.org/cmd/vet/
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
php
	phpstan	(phpstan --errorFormat=raw) PHP Static Analysis Tool - discover bugs in your code without running it! - https://github.com/phpstan/phpstan
puppet
	puppet-lint	Check that your Puppet manifests conform to the style guide - https://github.com/rodjek/puppet-lint
python
	pep8	Python style guide checker - https://pypi.python.org/pypi/pep8
ruby
	rubocop	A Ruby static code analyzer, based on the community Ruby style guide - https://github.com/rubocop-hq/rubocop
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
typescript
	tsc	TypeScript compiler - https://www.typescriptlang.org/
	tslint	An extensible linter for the TypeScript language - https://github.com/palantir/tslint

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