goodcheck 2.5.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +48 -2
- data/LICENSE +1 -1
- data/README.md +7 -444
- data/lib/goodcheck.rb +9 -4
- data/lib/goodcheck/analyzer.rb +13 -9
- data/lib/goodcheck/buffer.rb +11 -16
- data/lib/goodcheck/cli.rb +79 -57
- data/lib/goodcheck/commands/check.rb +41 -27
- data/lib/goodcheck/commands/config_loading.rb +28 -5
- data/lib/goodcheck/commands/init.rb +4 -2
- data/lib/goodcheck/commands/pattern.rb +2 -1
- data/lib/goodcheck/commands/test.rb +38 -30
- data/lib/goodcheck/config.rb +68 -1
- data/lib/goodcheck/config_loader.rb +41 -31
- data/lib/goodcheck/error.rb +3 -0
- data/lib/goodcheck/exit_status.rb +8 -0
- data/lib/goodcheck/glob.rb +14 -3
- data/lib/goodcheck/import_loader.rb +61 -17
- data/lib/goodcheck/issue.rb +3 -3
- data/lib/goodcheck/location.rb +28 -0
- data/lib/goodcheck/logger.rb +4 -4
- data/lib/goodcheck/reporters/json.rb +6 -1
- data/lib/goodcheck/reporters/text.rb +44 -11
- data/lib/goodcheck/rule.rb +3 -1
- data/lib/goodcheck/unarchiver.rb +40 -0
- data/lib/goodcheck/version.rb +1 -1
- metadata +47 -84
- data/.github/workflows/release.yml +0 -16
- data/.github/workflows/test.yml +0 -46
- data/.gitignore +0 -13
- data/.rubocop.yml +0 -5
- data/Dockerfile +0 -13
- data/Gemfile +0 -6
- data/Rakefile +0 -75
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/cheatsheet.pdf +0 -0
- data/docusaurus/.dockerignore +0 -2
- data/docusaurus/.gitignore +0 -12
- data/docusaurus/Dockerfile +0 -10
- data/docusaurus/docker-compose.yml +0 -18
- data/docusaurus/docs/commands.md +0 -69
- data/docusaurus/docs/configuration.md +0 -300
- data/docusaurus/docs/development.md +0 -15
- data/docusaurus/docs/getstarted.md +0 -46
- data/docusaurus/docs/rules.md +0 -79
- data/docusaurus/website/README.md +0 -193
- data/docusaurus/website/core/Footer.js +0 -100
- data/docusaurus/website/package.json +0 -14
- data/docusaurus/website/pages/en/index.js +0 -207
- data/docusaurus/website/pages/en/versions.js +0 -118
- data/docusaurus/website/sidebars.json +0 -11
- data/docusaurus/website/siteConfig.js +0 -171
- data/docusaurus/website/static/css/code-block-buttons.css +0 -39
- data/docusaurus/website/static/css/custom.css +0 -245
- data/docusaurus/website/static/img/favicon.ico +0 -0
- data/docusaurus/website/static/js/code-block-buttons.js +0 -47
- data/docusaurus/website/versioned_docs/version-1.0.0/commands.md +0 -70
- data/docusaurus/website/versioned_docs/version-1.0.0/configuration.md +0 -296
- data/docusaurus/website/versioned_docs/version-1.0.0/development.md +0 -16
- data/docusaurus/website/versioned_docs/version-1.0.0/getstarted.md +0 -47
- data/docusaurus/website/versioned_docs/version-1.0.0/rules.md +0 -81
- data/docusaurus/website/versioned_docs/version-1.0.2/rules.md +0 -79
- data/docusaurus/website/versioned_docs/version-2.4.0/configuration.md +0 -301
- data/docusaurus/website/versioned_docs/version-2.4.3/rules.md +0 -80
- data/docusaurus/website/versioned_sidebars/version-1.0.0-sidebars.json +0 -11
- data/docusaurus/website/versioned_sidebars/version-1.0.2-sidebars.json +0 -11
- data/docusaurus/website/versioned_sidebars/version-2.4.0-sidebars.json +0 -11
- data/docusaurus/website/versions.json +0 -11
- data/docusaurus/website/yarn.lock +0 -6806
- data/goodcheck.gemspec +0 -35
- data/goodcheck.yml +0 -10
- data/logo/GoodCheck Horizontal.pdf +0 -899
- data/logo/GoodCheck Horizontal.png +0 -0
- data/logo/GoodCheck Horizontal.svg +0 -55
- data/logo/GoodCheck logo.png +0 -0
- data/logo/GoodCheck vertical.png +0 -0
- data/sample.yml +0 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa64d7f536fc7b357fbae7aa685827211236015ff9203bc7291847705e4a8189
|
4
|
+
data.tar.gz: bf23ca5741b3e424d064d45b9e16ccc28fbf53d299d8a4966ce7a5566c277a0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d184c5e83feb1b656afdbb2aa71c724b33c584a674de2def35201bbd8a66275b5c2a45b466c477aee38689f53dc6e39a0ee4183a6ad61b3ba587485eeb7f3d89
|
7
|
+
data.tar.gz: 215b0532befa04bdbbdbb0ac24be805fde46ebe51bafda8d6193df1c3a183fbf0faad0495454b9dcfe6dec27015f817b5b52f99b4fa26936f57ac491fa923bf5
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,52 @@
|
|
1
|
-
#
|
1
|
+
# Changelog
|
2
2
|
|
3
|
-
##
|
3
|
+
## HEAD
|
4
|
+
|
5
|
+
## 3.0.0 (2021-06-14)
|
6
|
+
|
7
|
+
Breaking changes:
|
8
|
+
|
9
|
+
* Drop support of Ruby 2.4 [#169](https://github.com/sider/goodcheck/pull/169)
|
10
|
+
* `goodcheck test` exit with `3` on tests failed [#168](https://github.com/sider/goodcheck/pull/168)
|
11
|
+
(a potentially breaking change; the command previously exited with `1`)
|
12
|
+
|
13
|
+
Features:
|
14
|
+
|
15
|
+
* Import `.tar.gz` files [#190](https://github.com/sider/goodcheck/pull/190)
|
16
|
+
* Introduce `exclude_binary` option [#195](https://github.com/sider/goodcheck/pull/195)
|
17
|
+
* Add rule severity [#172](https://github.com/sider/goodcheck/pull/172)
|
18
|
+
|
19
|
+
Bugfixes and others:
|
20
|
+
|
21
|
+
* Update gemspec [#176](https://github.com/sider/goodcheck/pull/176)
|
22
|
+
* Update `psych` requirement allowing 4.0 [#183](https://github.com/sider/goodcheck/pull/183)
|
23
|
+
* Improve output error message on `RegexpError` [#188](https://github.com/sider/goodcheck/pull/188)
|
24
|
+
* Fix importing error with extended glob [#194](https://github.com/sider/goodcheck/pull/194)
|
25
|
+
|
26
|
+
## 2.7.0 (2020-12-02)
|
27
|
+
|
28
|
+
* Goodbye ActiveSupport [#155](https://github.com/sider/goodcheck/pull/155)
|
29
|
+
* Fix zero column [#160](https://github.com/sider/goodcheck/pull/160)
|
30
|
+
* Improve text reporter [#161](https://github.com/sider/goodcheck/pull/161)
|
31
|
+
|
32
|
+
## 2.6.1 (2020-11-19)
|
33
|
+
|
34
|
+
* Add missing doc for importing glob feature [#151](https://github.com/sider/goodcheck/pull/151)
|
35
|
+
* Renewal documentation [#152](https://github.com/sider/goodcheck/pull/152)
|
36
|
+
|
37
|
+
## 2.6.0 (2020-11-17)
|
38
|
+
|
39
|
+
* Improve CLI help and error messages [#141](https://github.com/sider/goodcheck/pull/141)
|
40
|
+
* Fail if missing rules on `goodcheck check` command [#142](https://github.com/sider/goodcheck/pull/142)
|
41
|
+
* Reduce needless files in this gem [#143](https://github.com/sider/goodcheck/pull/143)
|
42
|
+
* Add `Goodcheck::Error` as a base error class [#144](https://github.com/sider/goodcheck/pull/144)
|
43
|
+
* Improve error message when config file is not found [#145](https://github.com/sider/goodcheck/pull/145)
|
44
|
+
* Add `rules[].glob.exclude` option to `goodcheck.yml` [#146](https://github.com/sider/goodcheck/pull/146)
|
45
|
+
* Glob support for importing rules [#149](https://github.com/sider/goodcheck/pull/149)
|
46
|
+
|
47
|
+
## 2.5.2 (2020-08-31)
|
48
|
+
|
49
|
+
* Fix the pattern of disable lines for Slash-asterisk and add support for JSX [#131](https://github.com/sider/goodcheck/pull/131)
|
4
50
|
|
5
51
|
## 2.5.1 (2020-03-09)
|
6
52
|
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -13,458 +13,21 @@ It checks your program and when it detects a piece of text matching with the def
|
|
13
13
|
Some part of the code reviewing process can be automated.
|
14
14
|
With Goodcheck the only thing you have to do is define the rules, pairing patterns with messages, and then those same patterns won’t bother you anymore. 😆
|
15
15
|
|
16
|
-
##
|
16
|
+
## Getting started
|
17
17
|
|
18
|
-
|
19
|
-
- [Quickstart](#quickstart)
|
20
|
-
- [Defining rules](#defining-rules)
|
21
|
-
- [Pattern](#pattern)
|
22
|
-
- [Glob](#glob)
|
23
|
-
- [A rule with _negated_ pattern](#a-rule-with-negated-pattern)
|
24
|
-
- [A rule without pattern](#a-rule-without-pattern)
|
25
|
-
- [Triggers](#triggers)
|
26
|
-
- [Importing rules](#importing-rules)
|
27
|
-
- [Excluding files](#excluding-files)
|
28
|
-
- [Commands](#commands)
|
29
|
-
- [Downloaded rules](#downloaded-rules)
|
30
|
-
- [Disabling rules with inline comments](#disabling-rules-with-inline-comments)
|
31
|
-
- [Docker images](#docker-images)
|
32
|
-
- [Development](#development)
|
33
|
-
- [Contributing](#contributing)
|
18
|
+
Goodcheck is provided as a Ruby gem. To install it, run:
|
34
19
|
|
35
|
-
|
36
|
-
|
37
|
-
```shell-session
|
20
|
+
```console
|
38
21
|
$ gem install goodcheck
|
39
22
|
```
|
40
23
|
|
41
|
-
|
42
|
-
|
43
|
-
If you would not like to install Goodcheck to system (e.g. you would not like to install Ruby 2.4 or higher), you can use a [Docker image](#docker-images).
|
44
|
-
|
45
|
-
## Quickstart
|
46
|
-
|
47
|
-
```shell-session
|
48
|
-
$ goodcheck init
|
49
|
-
$ vim goodcheck.yml
|
50
|
-
$ goodcheck check
|
51
|
-
```
|
52
|
-
|
53
|
-
The `init` command generates a template of `goodcheck.yml` configuration file for you.
|
54
|
-
Edit the config file to define patterns you want to check.
|
55
|
-
Then run `check` command, and it will print matched texts.
|
56
|
-
|
57
|
-
### Cheatsheet
|
58
|
-
|
59
|
-
You can download a [printable cheatsheet](cheatsheet.pdf) from this repository.
|
60
|
-
|
61
|
-
## Defining rules
|
62
|
-
|
63
|
-
A `goodcheck.yml` example of the configuration is like the following:
|
64
|
-
|
65
|
-
```yaml
|
66
|
-
rules:
|
67
|
-
- id: com.example.github
|
68
|
-
pattern: Github
|
69
|
-
message: |
|
70
|
-
GitHub is GitHub, not Github
|
71
|
-
|
72
|
-
You may be misspelling the name of the service!
|
73
|
-
justification:
|
74
|
-
- When you mean a service different from GitHub
|
75
|
-
- When GitHub is renamed
|
76
|
-
glob:
|
77
|
-
- app/views/**/*.html.slim
|
78
|
-
- config/locales/**/*.yaml
|
79
|
-
pass:
|
80
|
-
- <a>Signup via GitHub</a>
|
81
|
-
fail:
|
82
|
-
- <a>Signup via Github</a>
|
83
|
-
```
|
84
|
-
|
85
|
-
A *rule* hash under a `rules` list contains the following keys:
|
86
|
-
|
87
|
-
* `id` - a string to identify rules (required)
|
88
|
-
* [`pattern`](#pattern) - a *pattern* or a sequence of *pattern*s (optional)
|
89
|
-
* `message` - a string to tell writers why the code piece should be revised (required)
|
90
|
-
* `justification` - a sequence of strings to tell writers when an exception can be allowed (optional)
|
91
|
-
* [`glob`](#glob) - a *glob* or a sequence of *glob*s (optional)
|
92
|
-
* `pass` - a string or a sequence of strings, which does not match the given pattern (optional)
|
93
|
-
* `fail` - a string or a sequence of strings, which does match the given pattern (optional)
|
94
|
-
|
95
|
-
### Pattern
|
96
|
-
|
97
|
-
A pattern can be a *literal pattern*, *regexp pattern*, *token pattern*, or a string.
|
98
|
-
|
99
|
-
#### String literal
|
100
|
-
|
101
|
-
A string literal represents a *literal pattern* or *regexp pattern*.
|
102
|
-
|
103
|
-
```yaml
|
104
|
-
pattern:
|
105
|
-
- This is a literal pattern
|
106
|
-
- /This is a regexp pattern/
|
107
|
-
- /This is a regexp pattern with the casefold option/i
|
108
|
-
- /This is a regexp pattern with the multiline option/m
|
109
|
-
```
|
110
|
-
|
111
|
-
If a string value begins with `/` and ends with `/`, it is a *regexp pattern*.
|
112
|
-
You can optionally specify regexp options like `/casefold/i` or `/multiline/m`.
|
113
|
-
|
114
|
-
#### Literal pattern
|
115
|
-
|
116
|
-
A *literal pattern* allows you to construct a regexp which matches exactly to the `literal` string.
|
117
|
-
|
118
|
-
```yaml
|
119
|
-
id: com.sample.GitHub
|
120
|
-
pattern:
|
121
|
-
literal: Github
|
122
|
-
case_sensitive: true
|
123
|
-
message: Write GitHub, not Github
|
124
|
-
```
|
125
|
-
|
126
|
-
All regexp meta characters included in the `literal` value will be escaped.
|
127
|
-
`case_sensitive` is an optional key and the default is `true`.
|
128
|
-
|
129
|
-
#### Regexp pattern
|
130
|
-
|
131
|
-
A *regexp pattern* allows you to write a regexp with meta chars.
|
132
|
-
|
133
|
-
```yaml
|
134
|
-
id: com.sample.digits
|
135
|
-
pattern:
|
136
|
-
regexp: \d{4,}
|
137
|
-
case_sensitive: false
|
138
|
-
multiline: false
|
139
|
-
message: Insert delimiters when writing large numbers
|
140
|
-
justification:
|
141
|
-
- When you are not writing numbers, including phone numbers, zip code, ...
|
142
|
-
```
|
143
|
-
|
144
|
-
It accepts two optional attributes, `case_sensitive` and `multiline`.
|
145
|
-
The default values of `case_sensitive` and `multiline` are `true` and `false` respectively.
|
146
|
-
|
147
|
-
The regexp will be passed to [`Regexp.compile`](https://ruby-doc.org/core-2.7.0/Regexp.html#method-c-compile).
|
148
|
-
The precise definition of regular expressions can be found in the documentation for Ruby.
|
149
|
-
|
150
|
-
#### Token pattern
|
151
|
-
|
152
|
-
A *token pattern* compiles to a *tokenized* regexp.
|
153
|
-
|
154
|
-
```yaml
|
155
|
-
id: com.sample.no-blink
|
156
|
-
pattern:
|
157
|
-
token: "<blink"
|
158
|
-
case_sensitive: false
|
159
|
-
message: Stop using <blink> tag
|
160
|
-
glob: "**/*.html"
|
161
|
-
justification:
|
162
|
-
- If Lynx is the major target of the web site
|
163
|
-
```
|
164
|
-
|
165
|
-
It tries to tokenize the input and generates a regexp which matches a sequence of tokens.
|
166
|
-
The tokenization is heuristic and may not work well for your programming language.
|
167
|
-
In that case, try using *regexp pattern*.
|
168
|
-
|
169
|
-
The generated regexp of `<blink` is `<\s*blink\b/m`.
|
170
|
-
It matches with `<blink />` and `< BLINK>`, but does not match with `https://www.chromium.org/blink`.
|
171
|
-
|
172
|
-
It accepts one optional attribute `case_sensitive`.
|
173
|
-
The default value of `case_sensitive` is `true`.
|
174
|
-
Note that the generated regexp is in multiline mode.
|
175
|
-
|
176
|
-
Token patterns can have an optional `where` attribute and *variable bindings*.
|
177
|
-
|
178
|
-
```yaml
|
179
|
-
pattern:
|
180
|
-
- token: bgcolor=${color:string}
|
181
|
-
where:
|
182
|
-
color: true
|
183
|
-
```
|
184
|
-
|
185
|
-
The variable binding consists of a *name* and *type* (`${name:type}`), where `color` and `string` in the example above respectively. You have to add a key of the variable *name* in `where` attribute.
|
186
|
-
|
187
|
-
We have 8 built-in types:
|
188
|
-
|
189
|
-
* `string`
|
190
|
-
* `int`
|
191
|
-
* `float`
|
192
|
-
* `number`
|
193
|
-
* `url`
|
194
|
-
* `email`
|
195
|
-
* `word`
|
196
|
-
* `identifier`
|
197
|
-
|
198
|
-
You can find the exact definitions of the types in the definition of [`Goodcheck::Pattern::Token`](lib/goodcheck/pattern.rb) (`@@TYPES`).
|
199
|
-
|
200
|
-
You can omit the type of variable binding.
|
201
|
-
|
202
|
-
```yaml
|
203
|
-
pattern:
|
204
|
-
- token: margin-left: ${size}px;
|
205
|
-
where:
|
206
|
-
size: true
|
207
|
-
- token: backgroundColor={${color}}
|
208
|
-
where:
|
209
|
-
color: true
|
210
|
-
```
|
211
|
-
|
212
|
-
In this case, the following character will be used to detect the range of binding. In the first example above, the `px` will be used as the marker for the end of `size` binding.
|
213
|
-
|
214
|
-
If parens or brackets are surrounding the variable, Goodcheck tries to match with nested ones in the variable. It expands five levels of nesting. See the example of matches with the second `backgroundColor` pattern:
|
215
|
-
|
216
|
-
- `backgroundColor={color}` Matches (`color=="color"`)
|
217
|
-
- `backgroundColor={{ red: red(), green: green(), blue: green()-1 }}` Matches (`color=="{ red: red(), green: green(), blue: green()-1 }"`)
|
218
|
-
- `backgroundColor={ {{{{{{}}}}}} }` Matches (`color==" {{{{{{}}}}}"`)
|
219
|
-
|
220
|
-
### Glob
|
221
|
-
|
222
|
-
A *glob* can be a string or a hash.
|
223
|
-
|
224
|
-
```yaml
|
225
|
-
glob: "**/test/**/*.rb"
|
226
|
-
# or
|
227
|
-
glob:
|
228
|
-
pattern: "legacy/**/*.rb"
|
229
|
-
encoding: EUC-JP
|
230
|
-
# or
|
231
|
-
glob:
|
232
|
-
- "**/test/**/*.rb"
|
233
|
-
- pattern: "legacy/**/*.rb"
|
234
|
-
encoding: EUC-JP
|
235
|
-
```
|
236
|
-
|
237
|
-
The hash can have an optional `encoding` attribute.
|
238
|
-
You can specify the encoding of the file by the names defined for Ruby.
|
239
|
-
The list of all available encoding names can be found by `$ ruby -e "puts Encoding.name_list"`.
|
240
|
-
The default value is `UTF-8`.
|
241
|
-
|
242
|
-
If you write a string as a `glob`, the string value can be the `pattern` of the glob, without `encoding` attribute.
|
243
|
-
|
244
|
-
If you omit the `glob` attribute in a rule, the rule will be applied to all files given to `goodcheck`.
|
245
|
-
|
246
|
-
If both your rule and its pattern has `glob`, Goodcheck will scan the pattern with files matching the `glob` condition in the pattern.
|
247
|
-
|
248
|
-
```yaml
|
249
|
-
rules:
|
250
|
-
- id: glob_test
|
251
|
-
pattern:
|
252
|
-
- literal: 123 # This pattern applies to .css files
|
253
|
-
glob: "*.css"
|
254
|
-
- literal: abc # This pattern applies to .txt files
|
255
|
-
glob: "*.txt"
|
256
|
-
```
|
257
|
-
|
258
|
-
### A rule with _negated_ pattern
|
259
|
-
|
260
|
-
Goodcheck rules are usually to detect _something is included in a file_.
|
261
|
-
You can define the _negated_ rules for the opposite, _something is missing in a file_.
|
262
|
-
|
263
|
-
```yaml
|
264
|
-
rules:
|
265
|
-
- id: negated
|
266
|
-
not:
|
267
|
-
pattern: <!DOCTYPE html>
|
268
|
-
message: Write a doctype on HTML files.
|
269
|
-
glob: "**/*.html"
|
270
|
-
```
|
271
|
-
|
272
|
-
### A rule without pattern
|
273
|
-
|
274
|
-
You can define a rule without `pattern`.
|
275
|
-
The rule emits an issue on each file specified with `glob`.
|
276
|
-
You cannot omit `glob` from a rule definition without `pattern`.
|
277
|
-
|
278
|
-
```yaml
|
279
|
-
rules:
|
280
|
-
- id: without_pattern
|
281
|
-
message: |
|
282
|
-
Read the operation manual for DB migration: https://example.com/guides/123
|
283
|
-
glob: db/schema.rb
|
284
|
-
```
|
285
|
-
|
286
|
-
The output will be something like:
|
287
|
-
|
288
|
-
```shell-session
|
289
|
-
$ goodcheck check
|
290
|
-
db/schema.rb:-:# This file is auto-generated from the current state of the database. Instead: Read the operation manual for DB migration: https://example.com/guides/123
|
291
|
-
```
|
292
|
-
|
293
|
-
### Triggers
|
294
|
-
|
295
|
-
Version 2.0.0 introduces a new abstraction to define patterns, called *trigger*.
|
296
|
-
You can continue using `pattern`s in *rule*, but using `trigger` allows more flexible pattern definition and more precise testing.
|
297
|
-
|
298
|
-
```yaml
|
299
|
-
rules:
|
300
|
-
- id: trigger
|
301
|
-
message: Using trigger
|
302
|
-
trigger:
|
303
|
-
- pattern: <blink
|
304
|
-
glob: "**/*.html"
|
305
|
-
fail:
|
306
|
-
- <blink></blink>
|
307
|
-
- not:
|
308
|
-
pattern:
|
309
|
-
token: <meta charset="UTF-8">
|
310
|
-
case_sensitive: false
|
311
|
-
glob: "**/*.html"
|
312
|
-
pass: |
|
313
|
-
<html>
|
314
|
-
<meta charset="utf-8"></meta>
|
315
|
-
</html>
|
316
|
-
```
|
317
|
-
|
318
|
-
You can continue existing `pattern` definitions, but using `goodcheck test` against `pattern`s with `glob` does not work.
|
319
|
-
If your `pattern` definition includes `glob`, switching to `trigger` would make sense.
|
320
|
-
|
321
|
-
## Importing rules
|
322
|
-
|
323
|
-
`goodcheck.yml` can have an optional `import` attribute.
|
324
|
-
|
325
|
-
```yaml
|
326
|
-
import:
|
327
|
-
- /usr/share/goodcheck/rules.yml
|
328
|
-
- lib/goodcheck/rules.yml
|
329
|
-
- https://some.host/shared/rules.yml
|
330
|
-
```
|
331
|
-
|
332
|
-
The value of `import` can be a sequence of:
|
333
|
-
|
334
|
-
- A string which represents an absolute file path,
|
335
|
-
- A string which represents a relative file path from the config file, or
|
336
|
-
- A http/https URL which represents the location of rules.
|
337
|
-
|
338
|
-
The rules file is a YAML file with an sequence of rules:
|
339
|
-
|
340
|
-
```yaml
|
341
|
-
- id: rule1
|
342
|
-
pattern: Some pattern 1
|
343
|
-
message: Some message 1
|
344
|
-
|
345
|
-
- id: rule2
|
346
|
-
pattern: Some pattern 2
|
347
|
-
message: Some message 2
|
348
|
-
|
349
|
-
# ...
|
350
|
-
```
|
351
|
-
|
352
|
-
## Excluding files
|
353
|
-
|
354
|
-
`goodcheck.yml` can have an optional `exclude` attribute.
|
355
|
-
|
356
|
-
```yaml
|
357
|
-
exclude:
|
358
|
-
- node_modules
|
359
|
-
- vendor
|
360
|
-
- **/test/**/*.txt
|
361
|
-
```
|
362
|
-
|
363
|
-
The value of `exclude` can be a string or a sequence of strings representing the glob pattern for excluded files.
|
364
|
-
|
365
|
-
## Commands
|
366
|
-
|
367
|
-
### `goodcheck init [options]`
|
368
|
-
|
369
|
-
The `init` command generates an example of a configuration file.
|
370
|
-
|
371
|
-
Available options are:
|
372
|
-
|
373
|
-
* `-c=[CONFIG]`, `--config=[CONFIG]` to specify the configuration file name to generate.
|
374
|
-
* `--force` to allow overwriting of an existing config file.
|
375
|
-
|
376
|
-
### `goodcheck check [options] targets...`
|
377
|
-
|
378
|
-
The `check` command checks your programs under `targets...`.
|
379
|
-
You can pass:
|
380
|
-
|
381
|
-
* Directory paths, or
|
382
|
-
* Paths to files.
|
383
|
-
|
384
|
-
When you omit `targets`, it checks all files in `.` (the current directory).
|
385
|
-
|
386
|
-
Available options are:
|
387
|
-
|
388
|
-
* `-c [CONFIG]`, `--config=[CONFIG]` to specify the configuration file.
|
389
|
-
* `-R [rule]`, `--rule=[rule]` to specify the rules you want to check.
|
390
|
-
* `--format=[text|json]` to specify output format.
|
391
|
-
* `-v`, `--verbose` to be verbose.
|
392
|
-
* `--debug` to print all debug messages.
|
393
|
-
* `--force` to ignore downloaded caches.
|
394
|
-
|
395
|
-
`goodcheck check` exits with:
|
396
|
-
|
397
|
-
* `0` when it does not find any matching text fragment.
|
398
|
-
* `2` when it finds some matching text.
|
399
|
-
* `1` when it finds some error.
|
400
|
-
|
401
|
-
You can check its exit status to identify if the tool finds some pattern or not.
|
402
|
-
|
403
|
-
### `goodcheck test [options]`
|
404
|
-
|
405
|
-
The `test` command tests rules.
|
406
|
-
The test contains:
|
407
|
-
|
408
|
-
* Validation of rule `id` uniqueness.
|
409
|
-
* If `pass` examples does not match with any of `pattern`s.
|
410
|
-
* If `fail` examples matches with some of `pattern`s.
|
411
|
-
|
412
|
-
Use `test` command when you add a new rule to be sure you are writing rules correctly.
|
413
|
-
|
414
|
-
Available options are:
|
415
|
-
|
416
|
-
* `-c [CONFIG]`, `--config=[CONFIG]` to specify the configuration file.
|
417
|
-
* `-v`, `--verbose` to be verbose.
|
418
|
-
* `--debug` to print all debug messages.
|
419
|
-
* `--force` to ignore downloaded caches.
|
420
|
-
|
421
|
-
### `goodcheck pattern [options] ids...`
|
422
|
-
|
423
|
-
The `pattern` command prints the regular expressions generated from the patterns.
|
424
|
-
The command is for debugging patterns, especially token patterns.
|
425
|
-
|
426
|
-
The available option is:
|
427
|
-
|
428
|
-
* `-c [CONFIG]`, `--config=[CONFIG]` to specify the configuration file.
|
429
|
-
|
430
|
-
## Downloaded rules
|
431
|
-
|
432
|
-
Downloaded rules are cached in `cache` directory in *goodcheck home directory*.
|
433
|
-
The *goodcheck home directory* is `~/.goodcheck`, but you can customize the location with `GOODCHECK_HOME` environment variable.
|
434
|
-
|
435
|
-
The cache expires in 3 minutes.
|
436
|
-
|
437
|
-
## Disabling rules with inline comments
|
438
|
-
|
439
|
-
You can disable rule warnings on a specific line using line comments supported by common languages.
|
440
|
-
|
441
|
-
For example, for Ruby:
|
442
|
-
|
443
|
-
```rb
|
444
|
-
# goodcheck-disable-next-line
|
445
|
-
puts "Github"
|
446
|
-
puts "Github" # goodcheck-disable-line
|
447
|
-
```
|
448
|
-
|
449
|
-
For JavaScript:
|
450
|
-
|
451
|
-
```js
|
452
|
-
// goodcheck-disable-next-line
|
453
|
-
console.log("Github")
|
454
|
-
console.log("Github") // goodcheck-disable-line
|
455
|
-
```
|
456
|
-
|
457
|
-
## Docker images
|
458
|
-
|
459
|
-
We provide Docker images of Goodcheck on [Docker Hub](https://hub.docker.com/r/sider/goodcheck) so that you can try Goodcheck without installing them.
|
24
|
+
If you do not want to install it, you can run it via Docker instead:
|
460
25
|
|
461
|
-
```
|
462
|
-
$ docker
|
463
|
-
$ docker run -t --rm -v "$(pwd):/work" sider/goodcheck check
|
26
|
+
```console
|
27
|
+
$ docker run -t --rm -v "$(pwd):/work" sider/goodcheck
|
464
28
|
```
|
465
29
|
|
466
|
-
|
467
|
-
You can pick a version of Goodcheck from the [Docker Hub tags page](https://hub.docker.com/r/sider/goodcheck/tags).
|
30
|
+
Check out the [documentation](docusaurus/docs/getstarted.md) or [website](https://sider.github.io/goodcheck/) for more details.
|
468
31
|
|
469
32
|
## Development
|
470
33
|
|