Package: golang-github-reviewdog-errorformat / 0.0~git20220309.b075c45-1

0001-Drop-executable.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
From: Jochen Sprickerhof <jspricke@debian.org>
Date: Sun, 19 Sep 2021 09:50:04 +0200
Subject: Drop executable

---
 cmd/errorformat/.gitignore         |   1 -
 cmd/errorformat/main.go            | 167 -------------------------------------
 cmd/errorformat/main_test.go       | 129 ----------------------------
 cmd/errorformat/testdata/golint.in |   4 -
 cmd/errorformat/testdata/golint.sh |   2 -
 cmd/errorformat/testdata/grep.in   |   7 --
 cmd/errorformat/testdata/grep.sh   |   2 -
 cmd/errorformat/testdata/sbt.in    |  18 ----
 cmd/errorformat/testdata/sbt.sh    |   2 -
 9 files changed, 332 deletions(-)
 delete mode 100644 cmd/errorformat/.gitignore
 delete mode 100644 cmd/errorformat/main.go
 delete mode 100644 cmd/errorformat/main_test.go
 delete mode 100644 cmd/errorformat/testdata/golint.in
 delete mode 100644 cmd/errorformat/testdata/golint.sh
 delete mode 100644 cmd/errorformat/testdata/grep.in
 delete mode 100644 cmd/errorformat/testdata/grep.sh
 delete mode 100644 cmd/errorformat/testdata/sbt.in
 delete mode 100644 cmd/errorformat/testdata/sbt.sh

diff --git a/cmd/errorformat/.gitignore b/cmd/errorformat/.gitignore
deleted file mode 100644
index 95b99b8..0000000
--- a/cmd/errorformat/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-errorformat
diff --git a/cmd/errorformat/main.go b/cmd/errorformat/main.go
deleted file mode 100644
index 30db3dd..0000000
--- a/cmd/errorformat/main.go
+++ /dev/null
@@ -1,167 +0,0 @@
-package main
-
-import (
-	"flag"
-	"fmt"
-	"io"
-	"log"
-	"os"
-	"sort"
-	"strings"
-	"text/template"
-
-	"github.com/reviewdog/errorformat"
-	"github.com/reviewdog/errorformat/fmts"
-	"github.com/reviewdog/errorformat/writer"
-)
-
-const usageMessage = "" +
-	`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
-		// End of line number if the item is multiline
-		EndLnum int
-		// column number (first column is 1)
-		Col int
-		// End of column number if the item has range
-		EndCol 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
-
-		// -- Extensions (Go version only) --
-
-		// Original error lines (often one line. more than one line for multi-line
-		// errorformat. :h errorformat-multi-line)
-		Lines []string
-	}
-`
-
-func usage() {
-	fmt.Fprintln(os.Stderr, usageMessage)
-	fmt.Fprintln(os.Stderr, "Flags:")
-	flag.PrintDefaults()
-	os.Exit(2)
-}
-
-type option struct {
-	entryFmt  string
-	writerFmt string
-	name      string
-	list      bool
-}
-
-func main() {
-	opt := option{}
-	sarifOpt := writer.SarifOption{}
-	flag.StringVar(&opt.entryFmt, "f", "{{.String}}", "format template for -w=template")
-	flag.StringVar(&opt.writerFmt, "w", "template", "writer format (template|checkstyle|jsonl|sarif)")
-	flag.StringVar(&opt.name, "name", "", "defined errorformat name")
-	flag.BoolVar(&opt.list, "list", false, "list defined errorformats")
-	flag.StringVar(&sarifOpt.ToolName, "sarif.tool-name", "", "Tool name for Sarif writer format. Use -name flag if available.")
-	flag.Usage = usage
-	flag.Parse()
-	errorformats := flag.Args()
-	if err := run(os.Stdin, os.Stdout, errorformats, opt, sarifOpt); err != nil {
-		fmt.Fprintln(os.Stderr, err)
-		os.Exit(1)
-	}
-}
-
-func run(r io.Reader, w io.Writer, efms []string, opt option, sarifOpt writer.SarifOption) error {
-	if opt.list {
-		fs := fmts.DefinedFmts()
-		out := make([]string, 0, len(fs))
-		for _, f := range fs {
-			out = append(out, fmt.Sprintf("%s\t\t%s - %s", f.Name, f.Description, f.URL))
-		}
-		sort.Strings(out)
-		fmt.Fprintln(w, strings.Join(out, "\n"))
-		return nil
-	}
-
-	if opt.name != "" {
-		f, ok := fmts.DefinedFmts()[opt.name]
-		if !ok {
-			return fmt.Errorf("%q is not defined", opt.name)
-		}
-		efms = f.Errorformat
-		if sarifOpt.ToolName == "" {
-			sarifOpt.ToolName = opt.name
-		}
-	}
-
-	var ewriter writer.Writer
-
-	switch opt.writerFmt {
-	case "template", "":
-		fm := template.FuncMap{
-			"join": strings.Join,
-		}
-		tmpl, err := template.New("main").Funcs(fm).Parse(opt.entryFmt)
-		if err != nil {
-			return err
-		}
-		ewriter = writer.NewTemplate(tmpl, w)
-	case "checkstyle":
-		ewriter = writer.NewCheckStyle(w)
-	case "jsonl":
-		ewriter = writer.NewJSONL(w)
-	case "sarif":
-		var err error
-		ewriter, err = writer.NewSarif(w, sarifOpt)
-		if err != nil {
-			return err
-		}
-	default:
-		return fmt.Errorf("unknown writer: -w=%v", opt.writerFmt)
-	}
-	if ewriter, ok := ewriter.(writer.BufWriter); ok {
-		defer func() {
-			if err := ewriter.Flush(); err != nil {
-				log.Println(err)
-			}
-		}()
-	}
-
-	efm, err := errorformat.NewErrorformat(efms)
-	if err != nil {
-		return err
-	}
-	s := efm.NewScanner(r)
-	for s.Scan() {
-		if err := ewriter.Write(s.Entry()); err != nil {
-			return err
-		}
-	}
-	return nil
-}
diff --git a/cmd/errorformat/main_test.go b/cmd/errorformat/main_test.go
deleted file mode 100644
index 24ae25c..0000000
--- a/cmd/errorformat/main_test.go
+++ /dev/null
@@ -1,129 +0,0 @@
-package main
-
-import (
-	"bytes"
-	"strings"
-	"testing"
-
-	"github.com/reviewdog/errorformat/writer"
-)
-
-func TestRun(t *testing.T) {
-	tests := []struct {
-		in       string
-		efms     []string
-		entryFmt string
-		name     string
-		want     string
-	}{
-		{
-			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 ..."
-`,
-			efms:     []string{"%f:%l:%c: %m"},
-			entryFmt: "{{.String}}",
-			want: `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 ..."
-`,
-		},
-		{
-			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 ..."
-`,
-			efms:     []string{"%f:%l:%c: %m"},
-			entryFmt: "{{.Filename}}",
-			want: `golint.new.go
-golint.new.go
-golint.new.go
-golint.new.go
-`,
-		},
-		{
-			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 ..."
-`,
-			entryFmt: "{{.Filename}}",
-			name:     "golint",
-			want: `golint.new.go
-golint.new.go
-golint.new.go
-golint.new.go
-`,
-		},
-	}
-
-	for _, tt := range tests {
-		out := new(bytes.Buffer)
-		opt := option{
-			entryFmt: tt.entryFmt,
-			name:     tt.name,
-		}
-		if err := run(strings.NewReader(tt.in), out, tt.efms, opt, writer.SarifOption{}); err != nil {
-			t.Error(err)
-		}
-		if got := out.String(); got != tt.want {
-			t.Errorf("got:\n%v\nwant:\n%v", got, tt.want)
-		}
-	}
-}
-
-func TestRun_checkstyle(t *testing.T) {
-	tests := []struct {
-		in   string
-		efms []string
-		want string
-	}{
-		{
-			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 ..."
-`,
-			efms: []string{"%f:%l:%c: %m"},
-			want: `<?xml version="1.0" encoding="UTF-8"?>
-<checkstyle version="1.0">
-  <file name="golint.new.go">
-    <error column="5" line="3" message="exported var V should have comment or be unexported"></error>
-    <error column="5" line="5" message="exported var NewError1 should have comment or be unexported"></error>
-    <error column="1" line="7" message="comment on exported function F should be of the form &#34;F ...&#34;"></error>
-    <error column="1" line="11" message="comment on exported function F2 should be of the form &#34;F2 ...&#34;"></error>
-  </file>
-</checkstyle>
-`,
-		},
-	}
-	for _, tt := range tests {
-		out := new(bytes.Buffer)
-		opt := option{writerFmt: "checkstyle"}
-		if err := run(strings.NewReader(tt.in), out, tt.efms, opt, writer.SarifOption{}); err != nil {
-			t.Error(err)
-		}
-		if got := out.String(); got != tt.want {
-			t.Errorf("got:\n%v\nwant:\n%v", got, tt.want)
-		}
-	}
-}
-
-func TestRun_unknown_writer(t *testing.T) {
-	opt := option{writerFmt: "unknown"}
-	if err := run(nil, nil, nil, opt, writer.SarifOption{}); err == nil {
-		t.Error("error expected but got nil")
-	}
-}
-
-func TestRun_list(t *testing.T) {
-	out := new(bytes.Buffer)
-	opt := option{list: true}
-	if err := run(nil, out, nil, opt, writer.SarifOption{}); err != nil {
-		t.Error(err)
-	}
-	t.Log(out.String())
-}
diff --git a/cmd/errorformat/testdata/golint.in b/cmd/errorformat/testdata/golint.in
deleted file mode 100644
index fbd1de3..0000000
--- a/cmd/errorformat/testdata/golint.in
+++ /dev/null
@@ -1,4 +0,0 @@
-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 ..."
diff --git a/cmd/errorformat/testdata/golint.sh b/cmd/errorformat/testdata/golint.sh
deleted file mode 100644
index 15a4839..0000000
--- a/cmd/errorformat/testdata/golint.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#/bin/bash
-./errorformat "%f:%l:%c: %m" < testdata/golint.in
diff --git a/cmd/errorformat/testdata/grep.in b/cmd/errorformat/testdata/grep.in
deleted file mode 100644
index 95c451b..0000000
--- a/cmd/errorformat/testdata/grep.in
+++ /dev/null
@@ -1,7 +0,0 @@
-errorformat.go
-1:// Package errorformat provides 'errorformat' functionality of Vim. :h
-398:// NewEfm converts a 'errorformat' string to regular expression pattern with
-
-README.md
-1:## errorformat - vim 'errorformat' implementation in Go
-
diff --git a/cmd/errorformat/testdata/grep.sh b/cmd/errorformat/testdata/grep.sh
deleted file mode 100644
index 68e5fd8..0000000
--- a/cmd/errorformat/testdata/grep.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#/bin/bash
-./errorformat "%l:%m" "%-P%f" "%-Q" < testdata/grep.in
diff --git a/cmd/errorformat/testdata/sbt.in b/cmd/errorformat/testdata/sbt.in
deleted file mode 100644
index 003d191..0000000
--- a/cmd/errorformat/testdata/sbt.in
+++ /dev/null
@@ -1,18 +0,0 @@
-[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]             ^
diff --git a/cmd/errorformat/testdata/sbt.sh b/cmd/errorformat/testdata/sbt.sh
deleted file mode 100644
index 930c0b9..0000000
--- a/cmd/errorformat/testdata/sbt.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#/bin/bash
-./errorformat "%E[%t%.%+] %f:%l: error: %m" "%A[%t%.%+] %f:%l: %m" "%Z[%.%+] %p^" "%C[%.%+] %.%#" "%-G%.%#" < testdata/sbt.in