Skip to content

Commit af14e8d

Browse files
author
Charlie Egan
authored
deps: Revert 47c70f0 tablewriter changes (#1579)
These were not possible to include in an OPA build and since this dependency is soon be removed, we should revert this change. Signed-off-by: Charlie Egan <charlie@styra.com>
1 parent 72fb730 commit af14e8d

6 files changed

Lines changed: 51 additions & 59 deletions

File tree

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/google/go-cmp v0.7.0
1515
github.com/google/go-dap v0.12.0
1616
github.com/jstemmer/go-junit-report/v2 v2.1.0
17-
github.com/olekukonko/tablewriter v1.0.7
17+
github.com/olekukonko/tablewriter v0.0.5
1818
github.com/open-policy-agent/opa v1.5.0
1919
github.com/owenrumney/go-sarif/v2 v2.3.3
2020
github.com/pdevine/go-asciisprite v0.1.6
@@ -79,8 +79,6 @@ require (
7979
github.com/mozillazg/go-slugify v0.2.0 // indirect
8080
github.com/mozillazg/go-unidecode v0.2.0 // indirect
8181
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
82-
github.com/olekukonko/errors v0.0.0-20250405072817-4e6d85265da6 // indirect
83-
github.com/olekukonko/ll v0.0.8 // indirect
8482
github.com/pelletier/go-toml v1.9.5 // indirect
8583
github.com/philandstuff/dhall-golang/v6 v6.0.2 // indirect
8684
github.com/pjbgf/sha1cd v0.3.2 // indirect

go.sum

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/
211211
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
212212
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
213213
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
214+
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
214215
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
215216
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
216217
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
@@ -229,12 +230,8 @@ github.com/mozillazg/go-unidecode v0.2.0 h1:vFGEzAH9KSwyWmXCOblazEWDh7fOkpmy/Z4A
229230
github.com/mozillazg/go-unidecode v0.2.0/go.mod h1:zB48+/Z5toiRolOZy9ksLryJ976VIwmDmpQ2quyt1aA=
230231
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
231232
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
232-
github.com/olekukonko/errors v0.0.0-20250405072817-4e6d85265da6 h1:r3FaAI0NZK3hSmtTDrBVREhKULp8oUeqLT5Eyl2mSPo=
233-
github.com/olekukonko/errors v0.0.0-20250405072817-4e6d85265da6/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y=
234-
github.com/olekukonko/ll v0.0.8 h1:sbGZ1Fx4QxJXEqL/6IG8GEFnYojUSQ45dJVwN2FH2fc=
235-
github.com/olekukonko/ll v0.0.8/go.mod h1:En+sEW0JNETl26+K8eZ6/W4UQ7CYSrrgg/EdIYT2H8g=
236-
github.com/olekukonko/tablewriter v1.0.7 h1:HCC2e3MM+2g72M81ZcJU11uciw6z/p82aEnm4/ySDGw=
237-
github.com/olekukonko/tablewriter v1.0.7/go.mod h1:H428M+HzoUXC6JU2Abj9IT9ooRmdq9CxuDmKMtrOCMs=
233+
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
234+
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
238235
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
239236
github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
240237
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=

pkg/reporter/reporter.go

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import (
1212
"github.com/fatih/color"
1313
"github.com/jstemmer/go-junit-report/v2/junit"
1414
"github.com/olekukonko/tablewriter"
15-
"github.com/olekukonko/tablewriter/renderer"
16-
"github.com/olekukonko/tablewriter/tw"
1715
"github.com/owenrumney/go-sarif/v2/sarif"
1816

1917
outil "github.com/open-policy-agent/opa/v1/util"
@@ -208,16 +206,17 @@ func (tr FestiveReporter) Publish(ctx context.Context, r report.Report) error {
208206

209207
func buildPrettyViolationsTable(violations []report.Violation) string {
210208
sb := &strings.Builder{}
211-
table := tablewriter.NewTable(sb, tablewriter.WithConfig(tablewriter.Config{
212-
Row: tw.CellConfig{
213-
Padding: tw.CellPadding{PerColumn: []tw.Padding{{Right: " "}, tw.PaddingDefault}},
214-
},
215-
}), tablewriter.WithRenderer(renderer.NewBlueprint(tw.Rendition{
216-
Borders: tw.BorderNone,
217-
Settings: tw.Settings{
218-
Separators: tw.Separators{BetweenRows: tw.Off, BetweenColumns: tw.Off},
219-
},
220-
})))
209+
table := tablewriter.NewWriter(sb)
210+
211+
table.SetNoWhiteSpace(true)
212+
table.SetTablePadding("\t")
213+
table.SetAlignment(tablewriter.ALIGN_LEFT)
214+
table.SetCenterSeparator("")
215+
table.SetColumnSeparator("")
216+
table.SetRowSeparator("")
217+
table.SetHeaderLine(false)
218+
table.SetBorder(false)
219+
table.SetAutoWrapText(false)
221220

222221
numViolations := len(violations)
223222

@@ -284,15 +283,13 @@ func (tr CompactReporter) Publish(_ context.Context, r report.Report) error {
284283
}
285284

286285
sb := &strings.Builder{}
287-
table := tablewriter.NewTable(sb, tablewriter.WithConfig(tablewriter.Config{
288-
Row: tw.CellConfig{
289-
Formatting: tw.CellFormatting{AutoWrap: tw.WrapNormal},
290-
Alignment: tw.CellAlignment{Global: tw.AlignLeft},
291-
ColMaxWidths: tw.CellWidth{Global: 80},
292-
},
293-
}))
294-
295-
table.Header([]string{"Location", "Description"})
286+
table := tablewriter.NewWriter(sb)
287+
288+
table.SetHeader([]string{"Location", "Description"})
289+
table.SetAutoFormatHeaders(false)
290+
291+
table.SetColWidth(80)
292+
table.SetAutoWrapText(true)
296293

297294
for i := range r.Violations {
298295
table.Append([]string{r.Violations[i].Location.String(), r.Violations[i].Description})

pkg/reporter/reporter_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,12 @@ func TestCompactReporterPublish(t *testing.T) {
157157
t.Fatal(err)
158158
}
159159

160-
expect := `┌──────────────┬──────────────────────────────┐
161-
LOCATION DESCRIPTION
162-
├──────────────┼──────────────────────────────┤
163-
a.rego:1:1 Rego must not break the law!
164-
b.rego:22:18 Questionable decision found
165-
└──────────────┴──────────────────────────────┘
160+
expect := `+--------------+------------------------------+
161+
| Location | Description |
162+
+--------------+------------------------------+
163+
| a.rego:1:1 | Rego must not break the law! |
164+
| b.rego:22:18 | Questionable decision found |
165+
+--------------+------------------------------+
166166
3 files linted , 2 violations found.
167167
`
168168

@@ -219,7 +219,7 @@ func TestGitHubReporterPublish(t *testing.T) {
219219
t.Fatal(err)
220220
}
221221

222-
if expectTable := "Rule: breaking-the-law"; !strings.Contains(buf.String(), expectTable) {
222+
if expectTable := "Rule: \tbreaking-the-law"; !strings.Contains(buf.String(), expectTable) {
223223
t.Errorf("expected table output %q, got %q", expectTable, buf.String())
224224
}
225225

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
Rule: long-violation
2-
Level: warning
3-
Description: violation with a long description
4-
Category: long
5-
Location: b.rego:22:18
6-
Text: long,long,long,long,long,long,long,long,long,long,long,long,long,long,long,long,long,long,long,long,long,long,long,lo...
7-
Documentation: https://example.com/to-long
1+
Rule: long-violation
2+
Level: warning
3+
Description: violation with a long description
4+
Category: long
5+
Location: b.rego:22:18
6+
Text: long,long,long,long,long,long,long,long,long,long,long,long,long,long,long,long,long,long,long,long,long,long,long,lo...
7+
Documentation: https://example.com/to-long
88

99
3 files linted. 1 violation (0 errors, 1 warning) found.

pkg/reporter/testdata/pretty/reporter.txt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
Rule: breaking-the-law
2-
Level: error
3-
Description: Rego must not break the law!
4-
Category: legal
5-
Location: a.rego:1:1
6-
Text: package illegal
7-
Documentation: https://example.com/illegal
8-
9-
Rule: questionable-decision
10-
Level: warning
11-
Description: Questionable decision found
12-
Category: really?
13-
Location: b.rego:22:18
14-
Text: default allow = true
15-
Documentation: https://example.com/questionable
1+
Rule: breaking-the-law
2+
Level: error
3+
Description: Rego must not break the law!
4+
Category: legal
5+
Location: a.rego:1:1
6+
Text: package illegal
7+
Documentation: https://example.com/illegal
8+
9+
Rule: questionable-decision
10+
Level: warning
11+
Description: Questionable decision found
12+
Category: really?
13+
Location: b.rego:22:18
14+
Text: default allow = true
15+
Documentation: https://example.com/questionable
1616

1717
3 files linted. 2 violations (1 error, 1 warning) found in 2 files. 1 rule skipped:
1818
- rule-missing-capability: Rule missing capability bar

0 commit comments

Comments
 (0)