Coder Social home page Coder Social logo

reviewdog / errorformat Goto Github PK

View Code? Open in Web Editor NEW
105.0 13.0 43.0 269 KB

Vim's quickfix errorformat implementation in Go

Home Page: https://reviewdog.github.io/errorformat-playground/

License: MIT License

Go 100.00%
vim go golang checkstyle lint errorformat

errorformat's Introduction

errorformat - Vim 'errorformat' implementation in Go

Tests codecov Go Report Card LICENSE Go Reference

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)

errorformat's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

errorformat's Issues

Take last match

Sorry, if this is not the right place to ask questions about how the formatting should be done in general 🙇‍♂️

I am trying to setup reviewdog for jest (in github actions). I want reviewdog to tell me about failed tests.
This is e.g. a output when a test has failed:

 PASS  src/store/media/api/__tests__/api.test.ts
A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks.

Summary of all failing tests
 FAIL  src/store/conversation/matrix/middlewares/__tests__/roomDeletePendingCreationOnLastMessage.test.ts
  ● Test suite failed to run

    Cannot find module '../../../../../jobs/memory/upload/job' from 'src/store/conversation/matrix/middlewares/__tests__/roomDeletePendingCreationOnLastMessage.test.ts'

      41 | // Mocking our components that depend on reduxStore and are causing issues.
      42 | jest.mock("src/__dev__/AccountSetup", () => ({}));
    > 43 | jest.mock("src/jobs/memory/upload/job", () => ({}));
         |      ^
      44 | jest.mock("src/store/reduxStore", () => ({}));
      45 |
      46 | it("should remove pending creation when room gets updated with last message", () => {

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:306:11)
      at Object.<anonymous> (src/store/conversation/matrix/middlewares/__tests__/roomDeletePendingCreationOnLastMessage.test.ts:43:6)


Test Suites: 1 failed, 5 skipped, 144 passed, 145 of 150 total
Tests:       9 skipped, 302 passed, 311 total
Snapshots:   138 passed, 138 total
Time:        56.5 s
Ran all test suites.

This is the efm pattern I got, which works nicely:

%-G%[%^ ]%.%#
%E%.%#● %m
%Z%.%#at %.%# (%f:%l:%c)
%C%.%#
%-G%.%#

However, for the failed test above it reports as file:
node_modules/jest-resolve/build/index.js:306:11

This is not correct, the error originates from:
src/store/conversation/matrix/middlewares/__tests__/roomDeletePendingCreationOnLastMessage.test.ts:43:6

There are two at lines at the end:

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:306:11)
      at Object.<anonymous> (src/store/conversation/matrix/middlewares/__tests__/roomDeletePendingCreationOnLastMessage.test.ts:43:6)

How can I tell the errorformat to take the last at match?

Thanks in advance!

remark-lint changed their output

We recently noticed that reviewdog was no longer capturing output from remark-lint, here is a comparison:

I tracked down the issue and it is because the output of remark lint was adjusted last year in vfile/vfile-reporter@f987b52 (and you can see the changes in the documentation here remarkjs/remark@6a43da8#diff-1152eab75d1ca2f7af44b54d8655b0cc01168ea48f5f9de4b346acc526eefb28L155-L160). Most of the whitespace changes is not a big deal but removing the two spaces between warning (or error) and the message causes a failure to match the format. Here is an example of the just that change:

 resources/markdown/README.md
-  25:3  warning  Incorrect list-item indent: add 2 spaces  list-item-indent  remark-lint
+  25:3  warning Incorrect list-item indent: add 2 spaces  list-item-indent  remark-lint

I believe the format in https://github.com/reviewdog/errorformat/blob/master/fmts/markdown.go#L10-L11 needs to drop the extra space to match the changes. I will try to share a pull request to make that change.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Support for `%o` and `%>`

According to documentation %o and %> are valid items in errorformat string:

%o module name (finds a string)
%> for next line start with current pattern again efm-%>

But this application does not support this items

Multiline note `%N`

Hey there, is there support for multiline notes with %N? When I try this in the playground, I get the error E376: Invalid %N in format string prefix

pmd integration

It would be nice if reviewdog supported pmd. It has very similar report format as checkstyle, so it should not be too hard.

Panic with incorrect input

How to reproduce

package errorformat_test

import (
	"testing"

	"github.com/reviewdog/errorformat"
)

func TestPanic(t *testing.T) {
	_, err := errorformat.NewEfm("%")
	if err == nil {
		t.Fatal("should return error")
	}
}
--- FAIL: TestPanic (0.00s)
panic: runtime error: index out of range [1] with length 1 [recovered]
        panic: runtime error: index out of range [1] with length 1

goroutine 33 [running]:
testing.tRunner.func1.1(0x5406c0, 0xc000154020)
        /home/linuxbrew/.linuxbrew/Cellar/go/1.15.7_1/libexec/src/testing/testing.go:1072 +0x30d
testing.tRunner.func1(0xc000102480)
        /home/linuxbrew/.linuxbrew/Cellar/go/1.15.7_1/libexec/src/testing/testing.go:1075 +0x41a
panic(0x5406c0, 0xc000154020)
        /home/linuxbrew/.linuxbrew/Cellar/go/1.15.7_1/libexec/src/runtime/panic.go:969 +0x1b9
github.com/reviewdog/errorformat.NewEfm.func1(...)
        /home/heijo/ghq/github.com/reviewdog/errorformat/errorformat.go:435
github.com/reviewdog/errorformat.NewEfm(0x54feb1, 0x1, 0xc00005e770, 0x47e246, 0x60281766)
        /home/heijo/ghq/github.com/reviewdog/errorformat/errorformat.go:442 +0x93f
github.com/reviewdog/errorformat_test.TestPanic(0xc000102480)
        /home/heijo/ghq/github.com/reviewdog/errorformat/panic_test.go:10 +0x3a
testing.tRunner(0xc000102480, 0x55b548)
        /home/linuxbrew/.linuxbrew/Cellar/go/1.15.7_1/libexec/src/testing/testing.go:1123 +0xef
created by testing.(*T).Run
        /home/linuxbrew/.linuxbrew/Cellar/go/1.15.7_1/libexec/src/testing/testing.go:1168 +0x2b3
exit status 2
FAIL    github.com/reviewdog/errorformat        0.004s

Playground link broken

Hi,

First of all thank you for your application that looks very promising.

I wanted to test the playground, but most of the examples are broken, probably due to git.io links not really working anymore.

Working links

  • golint
  • tsc
  • end line/column support

Not working links:

  • eslint (500 error : Invalid character in header content [\"location\"])
  • rubocop (404)
  • stylelint (404)
  • sbt (404)

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/code-scanning.yml
  • actions/checkout v4
  • actions/setup-go v5
  • github/codeql-action v3
.github/workflows/reviewdog.yml
  • actions/checkout v4
  • reviewdog/action-golangci-lint v2
.github/workflows/tests.yml
  • actions/setup-go v5
  • actions/checkout v4
  • codecov/codecov-action v3
  • actions/setup-go v5
  • actions/checkout v4
gomod
go.mod
  • go 1.13
  • github.com/haya14busa/go-checkstyle v0.0.0-20170303121022-5e9d09f51fa1@5e9d09f51fa1
  • github.com/haya14busa/go-sarif v0.0.0-20210102043135-e2c5fed2fa3d@e2c5fed2fa3d
npm
fmts/testdata/resources/javascript/package.json
sbt
fmts/testdata/resources/scala/build.sbt
  • scala 2.13.12
fmts/testdata/resources/scala/project/plugins.sbt
  • org.scalastyle:scalastyle-sbt-plugin 1.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

go get golint failed with golang v1.8 on TravisCI

Currently the test for golang v1.8 is failing due to installing golint.

# golang.org/x/tools/go/internal/gcimporter
../../../golang.org/x/tools/go/internal/gcimporter/bexport.go:212: obj.IsAlias undefined (type *types.TypeName has no field or method IsAlias)
The command "go get github.com/golang/lint/golint" failed and exited with 2 during .

Already Go 1.12 released, Go 1.8 is no longer supported by the Go team.
https://golang.org/doc/devel/release.html#policy
And golint has same support policy as golang. golang/lint@470b6b0
I think that it is better to support only the latest version and 2 former versions.

Support for spaces in file names

Currently, the regex explicitly only allows escaped spaces in filenames.

'f': `(?P<f>(?:[[:alpha:]]:)?(?:\\ |[^ ])+?)`,

But some tools like flake8 print the output with unescaped file names, even if the input was escaped.
Currently, there is no way to match those filenames.

example

cat foo\ bar/a.py | flake8 --stdin-display-name foo\ bar/a.py -

foo bar/a.py:1:80: E501 line too long (144 > 79 characters)

Not really sure if there is a good solution for this

Fail to parse TypeScript errors when using tsc without the silent option in yarn

If I run tsc using yarn without silent option, I will get the following output.

yarn run v1.22.10
$ /Users/odan/source/github.com/odan-sandbox/reviewdog-later-strict-example/node_modules/.bin/tsc --project tsconfig.strict.json --noEmit
src/app.ts(1,29): error TS7006: Parameter 'x' implicitly has an 'any' type.
src/app.ts(5,30): error TS7006: Parameter 'x' implicitly has an 'any' type.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Analyzing this with typescript's Errorformat will fail to parse it.
ref: https://reviewdog.github.io/errorformat-playground/?efms=%25E%25f+%25%23%28%25l%2C%25c%29%3A+error+TS%25n%3A+%25m&text=yarn+run+v1.22.10%0A%24+%2FUsers%2Fodan%2Fsource%2Fgithub.com%2Fodan-sandbox%2Freviewdog-later-strict-example%2Fnode_modules%2F.bin%2Ftsc+--project+tsconfig.strict.json+--noEmit%0Asrc%2Fapp.ts%281%2C29%29%3A+error+TS7006%3A+Parameter+%27x%27+implicitly+has+an+%27any%27+type.%0Asrc%2Fapp.ts%285%2C30%29%3A+error+TS7006%3A+Parameter+%27x%27+implicitly+has+an+%27any%27+type.%0Ainfo+Visit+https%3A%2F%2Fyarnpkg.com%2Fen%2Fdocs%2Fcli%2Frun+for+documentation+about+this+command.%0A

If yarn's silent option is enabled, only error messages will be printed and the parsing will succeed.

src/app.ts(1,29): error TS7006: Parameter 'x' implicitly has an 'any' type.
src/app.ts(5,30): error TS7006: Parameter 'x' implicitly has an 'any' type.

ref: https://reviewdog.github.io/errorformat-playground/?efms=%25E%25f+%25%23%28%25l%2C%25c%29%3A+error+TS%25n%3A+%25m&text=src%2Fapp.ts%281%2C29%29%3A+error+TS7006%3A+Parameter+%27x%27+implicitly+has+an+%27any%27+type.%0Asrc%2Fapp.ts%285%2C30%29%3A+error+TS7006%3A+Parameter+%27x%27+implicitly+has+an+%27any%27+type.%0A

This problem does not occur on npx.

"raw" errorformat ?

Hello,
Is it possible for reviewdog to directly consume a JSON array of errorformat.Entry ?
Thanks.

Escape ANSI-codes

Hi. Many CLI tools output highlighted, colorized text. Special ANSI-codes are used in this cases. For example ruby linter fasterer output:

fasterer | cat -A
^[[0;31;49mtestdata/examples.rb:3^[[0m Array#shuffle.first is slower than Array#sample.$

where ^[[0;31;49m ... ^[[0m - red-color ANSI-codes.
I tried to handle this ANSI-codes via efm masks, but i didn't cope with it. May be is there solution for escaping ANSI-codes?

Should this format work?

Given this error log:

FAILURE: Schema [/github/workspace/schemas/meta-info/jsonschema/1-0-0] contains following errors:
1. error: "objecta" is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])
    level: "error"
    domain: "syntax"
    schema: {"loadingURI":"#","pointer":""}
    keyword: "type"
    found: "objecta"
    valid: ["array","boolean","integer","null","number","object","string"]

2. Error: JSON Schema [iglu:root/meta-info/jsonschema/1-0-0] doesn't conform path [schemas/meta-info/jsonschema/1-0-0]
FAILURE: Schema [/github/workspace/schemas/view_info/jsonschema/1-0-0] contains following errors:
1. Error: JSON Schema [iglu:root/view_info/jsonschema/1-0-0] doesn't conform path [schemas/view_info/jsonschema/1-0-0]
FAILURE: Schema [/github/workspace/schemas/page_info/jsonschema/1-0-0] contains following errors:
1. error: "String" is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])
    level: "error"
    domain: "syntax"
    schema: {"loadingURI":"#","pointer":"/properties/page_access"}
    keyword: "type"
    found: "String"
    valid: ["array","boolean","integer","null","number","object","string"]

2. Error: JSON Schema [iglu:root/page_info/jsonschema/1-0-0] doesn't conform path [schemas/page_info/jsonschema/1-0-0]
FAILURE: Schema [/github/workspace/schemas/user_info/jsonschema/1-0-0] contains following errors:
1. Error: JSON Schema [iglu:root/user_info/jsonschema/1-0-0] doesn't conform path [schemas/user_info/jsonschema/1-0-0]
TOTAL: 0 Schemas were successfully validated
TOTAL: 4 invalid Schemas were encountered
TOTAL: 6 errors were encountered

and errorformat string

%EFAILURE:\ Schema\ [%-P%f]%.%#,%#.\ %m,%C%.%#,%-G%.%#

the playground can parse errors correctly

[
  {
    "filename": "/github/workspace/schemas/meta-info/jsonschema/1-0-0",
    "lnum": 0,
    "col": 0,
    "vcol": false,
    "nr": 0,
    "pattern": "",
    "text": "error: \"objecta\" is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])",
    "type": 0,
    "valid": true,
    "lines": [
      "1. error: \"objecta\" is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])"
    ]
  },
  {
    "filename": "/github/workspace/schemas/meta-info/jsonschema/1-0-0",
    "lnum": 0,
    "col": 0,
    "vcol": false,
    "nr": 0,
    "pattern": "",
    "text": "Error: JSON Schema [iglu:root/meta-info/jsonschema/1-0-0] doesn't conform path [schemas/meta-info/jsonschema/1-0-0]",
    "type": 0,
    "valid": true,
    "lines": [
      "2. Error: JSON Schema [iglu:root/meta-info/jsonschema/1-0-0] doesn't conform path [schemas/meta-info/jsonschema/1-0-0]"
    ]
  },
  {
    "filename": "/github/workspace/schemas/view_info/jsonschema/1-0-0",
    "lnum": 0,
    "col": 0,
    "vcol": false,
    "nr": 0,
    "pattern": "",
    "text": "Error: JSON Schema [iglu:root/view_info/jsonschema/1-0-0] doesn't conform path [schemas/view_info/jsonschema/1-0-0]",
    "type": 0,
    "valid": true,
    "lines": [
      "1. Error: JSON Schema [iglu:root/view_info/jsonschema/1-0-0] doesn't conform path [schemas/view_info/jsonschema/1-0-0]"
    ]
  },
  {
    "filename": "/github/workspace/schemas/page_info/jsonschema/1-0-0",
    "lnum": 0,
    "col": 0,
    "vcol": false,
    "nr": 0,
    "pattern": "",
    "text": "error: \"String\" is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])",
    "type": 0,
    "valid": true,
    "lines": [
      "1. error: \"String\" is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])"
    ]
  },
  {
    "filename": "/github/workspace/schemas/page_info/jsonschema/1-0-0",
    "lnum": 0,
    "col": 0,
    "vcol": false,
    "nr": 0,
    "pattern": "",
    "text": "Error: JSON Schema [iglu:root/page_info/jsonschema/1-0-0] doesn't conform path [schemas/page_info/jsonschema/1-0-0]",
    "type": 0,
    "valid": true,
    "lines": [
      "2. Error: JSON Schema [iglu:root/page_info/jsonschema/1-0-0] doesn't conform path [schemas/page_info/jsonschema/1-0-0]"
    ]
  },
  {
    "filename": "/github/workspace/schemas/user_info/jsonschema/1-0-0",
    "lnum": 0,
    "col": 0,
    "vcol": false,
    "nr": 0,
    "pattern": "",
    "text": "Error: JSON Schema [iglu:root/user_info/jsonschema/1-0-0] doesn't conform path [schemas/user_info/jsonschema/1-0-0]",
    "type": 0,
    "valid": true,
    "lines": [
      "1. Error: JSON Schema [iglu:root/user_info/jsonschema/1-0-0] doesn't conform path [schemas/user_info/jsonschema/1-0-0]"
    ]
  }
]

But the CLI tool

cat err.log | errorformat '%EFAILURE:\ Schema\ [%-P%f]%.%#,%#.\ %m,%C%.%#,%-G%.%#'  

doesn't output the filename properly:

|| FAILURE: Schema [/github/workspace/schemas/meta-info/jsonschema/1-0-0] contains following errors:
|| 1. error: "objecta" is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])
||     level: "error"
||     domain: "syntax"
||     schema: {"loadingURI":"#","pointer":""}
||     keyword: "type"
||     found: "objecta"
||     valid: ["array","boolean","integer","null","number","object","string"]
||
|| 2. Error: JSON Schema [iglu:root/meta-info/jsonschema/1-0-0] doesn't conform path [schemas/meta-info/jsonschema/1-0-0]
|| FAILURE: Schema [/github/workspace/schemas/view_info/jsonschema/1-0-0] contains following errors:
|| 1. Error: JSON Schema [iglu:root/view_info/jsonschema/1-0-0] doesn't conform path [schemas/view_info/jsonschema/1-0-0]  
|| FAILURE: Schema [/github/workspace/schemas/page_info/jsonschema/1-0-0] contains following errors:
|| 1. error: "String" is not a valid primitive type (valid values are: [array, boolean, integer, null, number, object, string])
||     level: "error"
||     domain: "syntax"
||     schema: {"loadingURI":"#","pointer":"/properties/page_access"}
||     keyword: "type"
||     found: "String"
||     valid: ["array","boolean","integer","null","number","object","string"]
||
|| 2. Error: JSON Schema [iglu:root/page_info/jsonschema/1-0-0] doesn't conform path [schemas/page_info/jsonschema/1-0-0]
|| FAILURE: Schema [/github/workspace/schemas/user_info/jsonschema/1-0-0] contains following errors:
|| 1. Error: JSON Schema [iglu:root/user_info/jsonschema/1-0-0] doesn't conform path [schemas/user_info/jsonschema/1-0-0]
|| TOTAL: 0 Schemas were successfully validated
|| TOTAL: 4 invalid Schemas were encountered
|| TOTAL: 6 errors were encountered

README says ...but it doesn't support Vim regex. but I see this too

efm, _ := errorformat.NewErrorformat([]string{`%f:%l:%c: %m`, `%-G%.%#`})

which is using a regex pattern %.%#.

Not a vim user and up until yesterday, I had no idea what an errorformat was. So I'm not sure what's going on here.

The ultimate issue is that reviewdog is not reporting any findings despite errors so I'm trying to debug that.

SARIF: parse and populate ruleId

I run a linter that produces a report file containing

docs/platform/training/index.md:32:73:Google.We:Try to avoid using first-person plural like 'we'.

The Google:We is the identifier for which lint rule was violated.

The underlying quickfix implementation in vim only supports:

        %n              error number (finds a number)
        %m              error message (finds a string)

but many tools produce an error code like that which is alphanumeric and can't be parsed with %n.

In the SARIF output I'd like to use ruleId to capture this field, so the message doesn't get the code jammed in it.

https://github.com/microsoft/sarif-tutorials/blob/main/docs/3-Beyond-basics.md#related-locations
shows a sample of how this may be reported.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.