All Projects → reviewdog → errorformat

reviewdog / errorformat

Licence: MIT license
Vim's quickfix errorformat implementation in Go

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to errorformat

arcanist-linters
A collection of custom Arcanist linters
Stars: ✭ 64 (-22.89%)
Mutual labels:  lint, checkstyle
Okcheck
Incremental scan,integrate Lint、KtLint、UnitTest、Checkstyle、Findbugs、Pmd, powerful and easy to use
Stars: ✭ 285 (+243.37%)
Mutual labels:  lint, checkstyle
Gradle Code Quality Tools Plugin
Gradle plugin that generates ErrorProne, Findbugs, Checkstyle, PMD, CPD, Lint, Detekt & Ktlint Tasks for every subproject.
Stars: ✭ 282 (+239.76%)
Mutual labels:  lint, checkstyle
very good analysis
Lint rules for Dart and Flutter used internally at Very Good Ventures 🦄
Stars: ✭ 194 (+133.73%)
Mutual labels:  lint
breakcheck
Backwards compatibility linter for Go.
Stars: ✭ 66 (-20.48%)
Mutual labels:  lint
prettier-check
Check that all files match prettier code style.
Stars: ✭ 54 (-34.94%)
Mutual labels:  lint
JSR305CheckstylePlugin
a plugin which ensures nullness annotations on methods and constructors
Stars: ✭ 19 (-77.11%)
Mutual labels:  checkstyle
litho-lint-rules
Lint rules for Litho by Facebook http://fblitho.com/
Stars: ✭ 14 (-83.13%)
Mutual labels:  lint
flake8-import-order-spoqa
Spoqa's import order style for flake8-import-order
Stars: ✭ 15 (-81.93%)
Mutual labels:  lint
extra pedantic
Stricter Dart analyzer linter settings and best practices.
Stars: ✭ 28 (-66.27%)
Mutual labels:  lint
Angular-Gulp-Boilerplate
Clean but full-featured AngularJS boilerplate using Gulp workflow and best practices
Stars: ✭ 30 (-63.86%)
Mutual labels:  lint
lint
Linting and formatting for SAS® code
Stars: ✭ 16 (-80.72%)
Mutual labels:  lint
spring-boot-java-swing-reservations
The project aims to present how to connect Spring Boot 2 and Java Swing GUI widget toolkit. All application dependencies are provided by Docker Compose. There are also static code analysis tools like FindBugs and Checkstyle.
Stars: ✭ 86 (+3.61%)
Mutual labels:  checkstyle
arduino-lint
Tool to check for problems with Arduino projects
Stars: ✭ 63 (-24.1%)
Mutual labels:  lint
KaiZen-OpenApi-Parser
High-performance Parser, Validator, and Java Object Model for OpenAPI 3.x
Stars: ✭ 119 (+43.37%)
Mutual labels:  lint
mock-spy-module-import
JavaScript import/require module testing do's and don'ts with Jest
Stars: ✭ 40 (-51.81%)
Mutual labels:  lint
analysis-model
A library to read static analysis reports into a Java object model
Stars: ✭ 74 (-10.84%)
Mutual labels:  checkstyle
relint
General purpose RegEx based file linter.
Stars: ✭ 33 (-60.24%)
Mutual labels:  lint
HTML-Lint
A code quality bookmarklet and command-line tool
Stars: ✭ 20 (-75.9%)
Mutual labels:  lint
diff-check
Incremental code analysis tools based on checkstyle, pmd and jacoco
Stars: ✭ 48 (-42.17%)
Mutual labels:  checkstyle

errorformat - Vim 'errorformat' implementation in Go

Travis Build Status codecov Go Report Card LICENSE GoDoc

errorformat is Vim's quickfix errorformat implementation in golang.

errorformat provides default errorformats for major tools. You can see defined errorformats here. Also, it's easy to add new errorformat in a similar way to Vim's errorformat.

Note that it's highly compatible with Vim implementation, but it doesn't support Vim regex.

▶️ Playground ▶️

Try errorformat on the Playground!

The playground uses gopherjs to try errorformat implementation in Go with JavaScript

Usage

import "github.com/reviewdog/errorformat"

Example

Code:

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 ..."
`
efm, _ := errorformat.NewErrorformat([]string{`%f:%l:%c: %m`, `%-G%.%#`})
s := efm.NewScanner(strings.NewReader(in))
for s.Scan() {
    fmt.Println(s.Entry())
}

Output:

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 ..."

CLI tool

Installation

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

Usage

Usage: errorformat [flags] [errorformat ...]

errorformat reads compiler/linter/static analyzer result from STDIN, formats
them by given 'errorformat' (90% compatible with Vim's errorformat. :h
errorformat), and outputs formated result to STDOUT.

Example:
        $ echo '/path/to/file:14:28: error message\nfile2:3:4: msg' | errorformat "%f:%l:%c: %m"
        /path/to/file|14 col 28| error message
        file2|3 col 4| msg

        $ golint ./... | errorformat -name=golint

The -f flag specifies an alternate format for the entry, using the
syntax of package template.  The default output is equivalent to -f
'{{.String}}'. The struct being passed to the template is:

        type Entry struct {
                // name of a file
                Filename string
                // line number
                Lnum int
                // column number (first column is 1)
                Col int
                // true: "col" is visual column
                // false: "col" is byte index
                Vcol bool
                // error number
                Nr int
                // search pattern used to locate the error
                Pattern string
                // description of the error
                Text string
                // type of the error, 'E', '1', etc.
                Type rune
                // true: recognized error message
                Valid bool

                // Original error lines (often one line. more than one line for multi-line
                // errorformat. :h errorformat-multi-line)
                Lines []string
        }

Flags:
  -f string
        format template for -w=template (default "{{.String}}")
  -list
        list defined errorformats
  -name string
        defined errorformat name
  -sarif.tool-name string
        Tool name for Sarif writer format. Use -name flag if available.
  -w string
        writer format (template|checkstyle|jsonl|sarif) (default "template")
$ cat testdata/sbt.in
[warn] /path/to/F1.scala:203: local val in method f is never used: (warning smaple 3)
[warn]         val x = 1
[warn]             ^
[warn] /path/to/F1.scala:204: local val in method f is never used: (warning smaple 2)
[warn]   val x = 2
[warn]       ^
[error] /path/to/F2.scala:1093: error: value ++ is not a member of Int
[error]     val x = 1 ++ 2
[error]               ^
[warn] /path/to/dir/F3.scala:83: local val in method f is never used
[warn]         val x = 4
[warn]             ^
[error] /path/to/dir/F3.scala:84: error: value ++ is not a member of Int
[error]         val x = 5 ++ 2
[error]                   ^
[warn] /path/to/dir/F3.scala:86: local val in method f is never used
[warn]         val x = 6
[warn]             ^
$ errorformat "%E[%t%.%+] %f:%l: error: %m" "%A[%t%.%+] %f:%l: %m" "%Z[%.%+] %p^" "%C[%.%+] %.%#" "%-G%.%#" < testdata/sbt.in
/path/to/F1.scala|203 col 13 warning| local val in method f is never used: (warning smaple 3)
/path/to/F1.scala|204 col 7 warning| local val in method f is never used: (warning smaple 2)
/path/to/F2.scala|1093 col 15 error| value &#43;&#43; is not a member of Int
/path/to/dir/F3.scala|83 col 13 warning| local val in method f is never used
/path/to/dir/F3.scala|84 col 19 error| value &#43;&#43; is not a member of Int
/path/to/dir/F3.scala|86 col 13 warning| local val in method f is never used
$ cat fmts/testdata/sbt.in | errorformat -name=sbt -w=checkstyle
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="1.0">
  <file name="/home/haya14busa/src/github.com/reviewdog/errorformat/fmts/testdata/resources/scala/scalac.scala">
    <error column="3" line="6" message="missing argument list for method error in object Predef" severity="error"></error>
    <error column="15" line="4" message="private val in object F is never used" severity="warning"></error>
    <error column="15" line="5" message="private method in object F is never used" severity="warning"></error>
  </file>
</checkstyle>
$ cat fmts/testdata/sbt.in | errorformat -name=sbt -w=jsonl
{"filename":"/home/haya14busa/src/github.com/reviewdog/errorformat/fmts/testdata/resources/scala/scalac.scala","lnum":6,"col":3,"vcol":true,"nr":0,"pattern":"","text":"missing argument list for method error in object Predef","type":101,"valid":true,"lines":["[error] /home/haya14busa/src/github.com/reviewdog/errorformat/fmts/testdata/resources/scala/scalac.scala:6: missing argument list for method error in object Predef","[error] Unapplied methods are only converted to functions when a function type is expected.","[error] You can make this conversion explicit by writing `error _` or `error(_)` instead of `error`.","[error]   error","[error]   ^"]}
{"filename":"/home/haya14busa/src/github.com/reviewdog/errorformat/fmts/testdata/resources/scala/scalac.scala","lnum":4,"col":15,"vcol":true,"nr":0,"pattern":"","text":"private val in object F is never used","type":119,"valid":true,"lines":["[warn] /home/haya14busa/src/github.com/reviewdog/errorformat/fmts/testdata/resources/scala/scalac.scala:4: private val in object F is never used","[warn]   private val unused = 1","[warn]               ^"]}
{"filename":"/home/haya14busa/src/github.com/reviewdog/errorformat/fmts/testdata/resources/scala/scalac.scala","lnum":5,"col":15,"vcol":true,"nr":0,"pattern":"","text":"private method in object F is never used","type":119,"valid":true,"lines":["[warn] /home/haya14busa/src/github.com/reviewdog/errorformat/fmts/testdata/resources/scala/scalac.scala:5: private method in object F is never used","[warn]   private def unusedF = {}","[warn]               ^"]}

SARIF Support (experimental)

It supports SARIF (Static Analysis Results Interchange Format) as output experimentally. Use -w=sarif to give it a shot.

Example: errorformat -w=sarif
$ cat fmts/testdata/sbt.in | errorformat -name=sbt -w=sarif
{
  "$schema": "http://json.schemastore.org/sarif-2.1.0-rtm.4",
  "runs": [
    {
      "results": [
        {
          "level": "error",
          "locations": [
            {
              "physicalLocation": {
                "artifactLocation": {
                  "uri": "fmts/testdata/resources/scala/scalac.scala",
                  "uriBaseId": "%SRCROOT%"
                },
                "region": {
                  "startColumn": 3,
                  "startLine": 6
                }
              }
            }
          ],
          "message": {
            "text": "missing argument list for method error in object Predef"
          }
        },
        {
          "level": "warning",
          "locations": [
            {
              "physicalLocation": {
                "artifactLocation": {
                  "uri": "fmts/testdata/resources/scala/scalac.scala",
                  "uriBaseId": "%SRCROOT%"
                },
                "region": {
                  "startColumn": 15,
                  "startLine": 4
                }
              }
            }
          ],
          "message": {
            "text": "private val in object F is never used"
          }
        },
        {
          "level": "warning",
          "locations": [
            {
              "physicalLocation": {
                "artifactLocation": {
                  "uri": "fmts/testdata/resources/scala/scalac.scala",
                  "uriBaseId": "%SRCROOT%"
                },
                "region": {
                  "startColumn": 15,
                  "startLine": 5
                }
              }
            }
          ],
          "message": {
            "text": "private method in object F is never used"
          }
        }
      ],
      "tool": {
        "driver": {
          "name": "sbt"
        }
      }
    }
  ],
  "version": "2.1.0"
}

Use cases of 'errorformat' outside Vim

🐦 Author

haya14busa (https://github.com/haya14busa)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].