goodcheck 2.6.0 β†’ 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de4b1a0cef4a741eeb0307e0df5be2dcf68ad43ed59e5a9b5bf1d16e991b4c5e
4
- data.tar.gz: a9a980614761ccc2bed278df1c51400878330e3ba92d5999a0133502eb8fa47c
3
+ metadata.gz: a0c8afdfe31520eabbb82eeaa32910c656e6447d4f3e13dcfd0ff6f09eb9854c
4
+ data.tar.gz: 361efc3d3596749d09d1c6abca0bea722e1523f55b6d0a01c9750b7a7b2608e3
5
5
  SHA512:
6
- metadata.gz: 2978efccddd1d7132703a1b993aa25d9e3f588a33ed07cadce73aa514d252bdf963b537314d9d20ea509b437a88ce018ea7d7f38b7cb165572c6e8b8cef07880
7
- data.tar.gz: 980698f9a9e94346cc2d727a6c8b3709281747e698e9424f95f00a5c473c75ea16de0026f879f4fde91f3a935004234c712e81913ba0ee5b092b04bef369a58f
6
+ metadata.gz: 51d137db095bc967e0bd2add64b94fccb2d3684bff282dd4f32efd749d39f52669a3e8b7acd58fbf428c83ef274130607a6a457a94415ce8bb58e4213d79d121
7
+ data.tar.gz: de13aa4b155e7fe583f48a49da717c80455132d8dde0691fd9ca2cf075d84c2edb6b228cb9aa8ce3eb7afc2b726e5d93e6a448fb7f7fec36255f84e02a07c832
data/CHANGELOG.md CHANGED
@@ -2,6 +2,46 @@
2
2
 
3
3
  ## HEAD
4
4
 
5
+ ## 3.0.2 (2021-06-23)
6
+
7
+ * Retry importing on Net::OpenTimeout [#202](https://github.com/sider/goodcheck/pull/202)
8
+
9
+ ## 3.0.1 (2021-06-14)
10
+
11
+ * Retry HTTP GET request on importing rules [#197](https://github.com/sider/goodcheck/pull/197)
12
+
13
+ ## 3.0.0 (2021-06-14)
14
+
15
+ Breaking changes:
16
+
17
+ * Drop support of Ruby 2.4 [#169](https://github.com/sider/goodcheck/pull/169)
18
+ * `goodcheck test` exit with `3` on tests failed [#168](https://github.com/sider/goodcheck/pull/168)
19
+ (a potentially breaking change; the command previously exited with `1`)
20
+
21
+ Features:
22
+
23
+ * Import `.tar.gz` files [#190](https://github.com/sider/goodcheck/pull/190)
24
+ * Introduce `exclude_binary` option [#195](https://github.com/sider/goodcheck/pull/195)
25
+ * Add rule severity [#172](https://github.com/sider/goodcheck/pull/172)
26
+
27
+ Bugfixes and others:
28
+
29
+ * Update gemspec [#176](https://github.com/sider/goodcheck/pull/176)
30
+ * Update `psych` requirement allowing 4.0 [#183](https://github.com/sider/goodcheck/pull/183)
31
+ * Improve output error message on `RegexpError` [#188](https://github.com/sider/goodcheck/pull/188)
32
+ * Fix importing error with extended glob [#194](https://github.com/sider/goodcheck/pull/194)
33
+
34
+ ## 2.7.0 (2020-12-02)
35
+
36
+ * Goodbye ActiveSupport [#155](https://github.com/sider/goodcheck/pull/155)
37
+ * Fix zero column [#160](https://github.com/sider/goodcheck/pull/160)
38
+ * Improve text reporter [#161](https://github.com/sider/goodcheck/pull/161)
39
+
40
+ ## 2.6.1 (2020-11-19)
41
+
42
+ * Add missing doc for importing glob feature [#151](https://github.com/sider/goodcheck/pull/151)
43
+ * Renewal documentation [#152](https://github.com/sider/goodcheck/pull/152)
44
+
5
45
  ## 2.6.0 (2020-11-17)
6
46
 
7
47
  * Improve CLI help and error messages [#141](https://github.com/sider/goodcheck/pull/141)
@@ -10,6 +50,7 @@
10
50
  * Add `Goodcheck::Error` as a base error class [#144](https://github.com/sider/goodcheck/pull/144)
11
51
  * Improve error message when config file is not found [#145](https://github.com/sider/goodcheck/pull/145)
12
52
  * Add `rules[].glob.exclude` option to `goodcheck.yml` [#146](https://github.com/sider/goodcheck/pull/146)
53
+ * Glob support for importing rules [#149](https://github.com/sider/goodcheck/pull/149)
13
54
 
14
55
  ## 2.5.2 (2020-08-31)
15
56
 
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 Sleeek Corporation
3
+ Copyright (c) 2019 Sider Corporation
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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
- ## Table of contents
16
+ ## Getting started
17
17
 
18
- - [Installation](#installation)
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
- ## Installation
36
-
37
- ```shell-session
20
+ ```console
38
21
  $ gem install goodcheck
39
22
  ```
40
23
 
41
- Or you can use [`bundler`](https://bundler.io)!
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
- ```bash
462
- $ docker pull sider/goodcheck
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
- The default `latest` tag points to the latest release of Goodcheck.
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
 
@@ -479,7 +42,7 @@ To release a new version, follows the steps below:
479
42
  3. Update the documentation via `bundle exec rake docs:update_version`.
480
43
  4. Commit the above changes like `git commit -m 'Version 1.2.3'`.
481
44
  5. Run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
482
- 6. Publish the updated documentation like `GIT_USER=some_user USE_SSH=true bundle exec rake docs:publish`.
45
+ 6. Publish the updated documentation like `GIT_USER=some_user [USE_SSH=true] bundle exec rake docs:publish`.
483
46
 
484
47
  ## Contributing
485
48