Skip to content

Commit f2d1946

Browse files
committed
Initial Release
1 parent 9cac9c4 commit f2d1946

File tree

6 files changed

+16
-53
lines changed

6 files changed

+16
-53
lines changed

.goreleaser.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ before:
1414
- go mod tidy
1515
# you may remove this if you don't need go generate
1616
- go generate ./...
17-
- echo '{"version":"{{ .Version }}", "tag":"{{ .Tag }}", "commit":"{{ .Commit }}", "date":"{{ .Date }}"}' >> pkg/VERSION.json
18-
- git add pkg/VERSION.json && git commit -m "Update VERSION.json"
1917

2018
builds:
2119
- env: []

Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build:
88

99
run:
1010
go build -o ${BINARY_PATH}
11-
${BINARY_NAME} ~/src/runbook
11+
${BINARY_NAME} run ~/src/runbook
1212

1313
clean:
1414
go clean
@@ -23,5 +23,8 @@ test-watch:
2323
benchmark:
2424
hyperfine --ignore-failure -- "./bin/polylint --config examples/simple.yaml run ~/src/runbook"
2525

26-
build-dry-run:
26+
release-dry-run:
2727
goreleaser release --clean --skip publish --snapshot
28+
29+
release:
30+
goreleaser release --clean

cmd/root.go

-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
"github.com/spf13/cobra"
1111
"github.com/spf13/viper"
12-
pkg "github.com/zph/polylint/pkg"
1312
)
1413

1514
var (
@@ -43,9 +42,6 @@ func init() {
4342
}
4443

4544
func setVersion() {
46-
if version == "v0.0.1" {
47-
version = pkg.LibMetadata.Version
48-
}
4945
viper.Set("binary_version", version)
5046
rootCmd.Version = version
5147
}

cmd/run.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func Run(cmd *cobra.Command, args []string) (int, []error) {
6767
fmt.Printf("\n%s: violations count %d\n", result.Path, len(result.Findings))
6868
for idx, finding := range result.Findings {
6969
// TODO: figure out why the rule embedded is wrong
70-
fmt.Printf("%d: %s:%d %s %s\n", idx+1, result.Path, finding.LineNo, finding.RuleId, finding.Rule.Description)
70+
fmt.Printf("%d: Line %3d %30s %20s\n", idx+1, finding.LineNo, finding.RuleId, finding.Rule.Description)
7171
}
7272
exitCode = 1
7373
}

examples/simple.yaml

+10-16
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ rules:
1919
type: builtin
2020
scope: line
2121
name: contains
22-
args: ['print(']
22+
args:
23+
- print(
2324
- id: no-logging
2425
description: "Don't use logging"
2526
recommendation: "Use print instead."
@@ -31,7 +32,8 @@ rules:
3132
type: builtin
3233
scope: line
3334
name: regexp
34-
args: ['^logging']
35+
args:
36+
- '^logging'
3537
- id: no-print-js
3638
description: "Don't use print()"
3739
recommendation: "Use logging instead."
@@ -42,11 +44,9 @@ rules:
4244
fn:
4345
type: js
4446
scope: line
45-
name: printRule
47+
name: fn
4648
body: |
47-
function printRule(path, idx, line) {
48-
return line.includes('print')
49-
}
49+
const fn = (_p, _i, line) => line.includes('print')
5050
- id: no-print-js-file-level
5151
description: "Don't use print()"
5252
recommendation: "Use logging instead."
@@ -57,11 +57,8 @@ rules:
5757
fn:
5858
type: js
5959
scope: file
60-
name: printRule
61-
body: |
62-
function printRule(path, idx, line) {
63-
return line.includes('print')
64-
}
60+
name: fn
61+
body: const fn = (_p, _i, file) => file.includes('print')
6562
- id: no-print-js-path-level
6663
description: "Don't use print()"
6764
recommendation: "Use logging instead."
@@ -72,8 +69,5 @@ rules:
7269
fn:
7370
type: js
7471
scope: path
75-
name: printRule
76-
body: |
77-
function printRule(path, _idx, _line) {
78-
return path.includes('print')
79-
}
72+
name: fn
73+
body: const fn = (path, _i, _l) => path.includes('print')

pkg/entry.go

-28
This file was deleted.

0 commit comments

Comments
 (0)