goodcheck 2.4.3 → 2.5.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: bc42687754f4ad7fe5e48927a75c1a002eef6be5296c9192906e2ae1cfa3ec4e
4
- data.tar.gz: d98d68e23feb34946bb21c17c9568b267842ed24eba012472a9c9b29f5787b7e
3
+ metadata.gz: 5a8fa2f7ee1e8534b3495e3d77a0d0cfb8b49eeaefc77a6507fee9604e0b829a
4
+ data.tar.gz: 5cd0ac1288b2bb90978998410ff93e234ec08bc645b2ace741f339e0e0b811b2
5
5
  SHA512:
6
- metadata.gz: 5ad795cf04626769374ca254f9a86feb63698540c32d4af8efb9e705f74c55a0cf3d3705f99e2a285dbdc156fcb8bae22a74ea4e9aefa5efb24b2368f180197d
7
- data.tar.gz: cfae9d9cd9d5b76bfa03840d66ec2ea3671a77ef5fb98a1e24994c303b57254d22ba80ac0cc91521c51e82d1594e9e12a4ce5d4eb4a3ad4c701634d1e60c253f
6
+ metadata.gz: dbadbb4097eb8ba35fff5845ade562e47830c197297176118f5144ad984132331f890ef9f7b1e30f14e66ae9d43df64819fb7794dd3059f22fe46e75fcd76a6a
7
+ data.tar.gz: 3728f7b3037174382675361fa05be02e0f1bf1ede5cb6aadacef2098c062568a95e560a10eed72bffd12baac171b636279738ecf3cccd78be11526922bba50bb
@@ -0,0 +1,18 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: monthly
7
+ time: "09:00"
8
+ timezone: Asia/Tokyo
9
+ open-pull-requests-limit: 10
10
+ versioning-strategy: increase
11
+ - package-ecosystem: npm
12
+ directory: "/docusaurus/website"
13
+ schedule:
14
+ interval: monthly
15
+ time: "09:00"
16
+ timezone: Asia/Tokyo
17
+ open-pull-requests-limit: 10
18
+ versioning-strategy: increase
@@ -0,0 +1,16 @@
1
+ name: Release
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ release:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - uses: softprops/action-gh-release@v1
11
+ if: startsWith(github.ref, 'refs/tags/')
12
+ with:
13
+ body: |
14
+ See the [changelog](https://github.com/${{ github.repository }}/blob/${{ github.sha }}/CHANGELOG.md) for more details.
15
+ env:
16
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,46 @@
1
+ name: Test
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ ruby: [2.4, 2.5, 2.6, 2.7]
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ - uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: ${{ matrix.ruby }}
16
+ - run: |
17
+ gem install bundler --no-document
18
+ bundle config set path vendor/bundle
19
+ bundle install --jobs=4 --retry=3
20
+ - run: bundle exec rake
21
+
22
+ build-docs:
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+ - uses: ruby/setup-ruby@v1
27
+ with:
28
+ ruby-version: 2.7
29
+ - run: |
30
+ gem install bundler --no-document
31
+ bundle config set path vendor/bundle
32
+ bundle install --jobs=4 --retry=3
33
+ - run: bundle exec rake docs:build
34
+
35
+ benchmark:
36
+ runs-on: ubuntu-latest
37
+ steps:
38
+ - uses: actions/checkout@v2
39
+ - uses: ruby/setup-ruby@v1
40
+ with:
41
+ ruby-version: 2.7
42
+ - run: |
43
+ gem install bundler --no-document
44
+ bundle config set path vendor/bundle
45
+ bundle install --jobs=4 --retry=3
46
+ - run: bundle exec rake benchmark:run[10000]
data/.gitignore CHANGED
@@ -9,4 +9,5 @@
9
9
  /tmp/
10
10
  /.idea
11
11
  /Gemfile.lock
12
+ /.ruby-version
12
13
  .DS_Store
@@ -2,6 +2,27 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 2.5.2 (2020-08-31)
6
+
7
+ * Fix the pattern of disable lines for Slash-asterisk and add support for JSX [#131](https: //github.com/sider/goodcheck/pull/131)
8
+
9
+ ## 2.5.1 (2020-03-09)
10
+
11
+ * Replace `httpclient` with `net/http` [#115](https://github.com/sider/goodcheck/pull/115)
12
+
13
+ ## 2.5.0 (2020-02-27)
14
+
15
+ * Add disable lines via inline comments [#101](https://github.com/sider/goodcheck/pull/101) (thanks to [@dcwither](https://github.com/dcwither)). See [README](https://github.com/sider/goodcheck#disabling-rules-with-inline-comments) for details.
16
+
17
+ ## 2.4.5 (2019-12-13)
18
+
19
+ * Replace ActiveSupport's `Regexp#multiline?` extension [#97](https://github.com/sider/goodcheck/pull/97) (thanks to [@issei126](https://github.com/issei126))
20
+
21
+ ## 2.4.4 (2019-11-19)
22
+
23
+ * Check dot files (except for `.git`, `.svn`, `.hg`) [#91](https://github.com/sider/goodcheck/pull/91)
24
+ * Improve `test` command output [#93](https://github.com/sider/goodcheck/pull/93)
25
+
5
26
  ## 2.4.3 (2019-11-07)
6
27
 
7
28
  * Change LICENSE to MIT [#76](https://github.com/sider/goodcheck/pull/76)
data/README.md CHANGED
@@ -8,25 +8,43 @@ What if a misspelling like `Github` for `GitHub` can be found automatically?
8
8
 
9
9
  Give Goodcheck a try to do them instead of you! 🎉
10
10
 
11
- Goodcheck is a customizable linter.
12
- You can define pairs of patterns and messages.
11
+ Goodcheck is a customizable linter. You can define pairs of patterns and messages.
13
12
  It checks your program and when it detects a piece of text matching with the defined patterns, it prints your message which tells your teammates why it should be revised and how.
14
13
  Some part of the code reviewing process can be automated.
15
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. 😆
16
15
 
16
+ ## Table of contents
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)
34
+
17
35
  ## Installation
18
36
 
19
- ```bash
37
+ ```shell-session
20
38
  $ gem install goodcheck
21
39
  ```
22
40
 
23
- Or you can use `bundler`!
41
+ Or you can use [`bundler`](https://bundler.io)!
24
42
 
25
- 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. [See below](#docker-images).
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).
26
44
 
27
45
  ## Quickstart
28
46
 
29
- ```bash
47
+ ```shell-session
30
48
  $ goodcheck init
31
49
  $ vim goodcheck.yml
32
50
  $ goodcheck check
@@ -40,9 +58,9 @@ Then run `check` command, and it will print matched texts.
40
58
 
41
59
  You can download a [printable cheatsheet](cheatsheet.pdf) from this repository.
42
60
 
43
- ## `goodcheck.yml`
61
+ ## Defining rules
44
62
 
45
- An example of the configuration is like the following:
63
+ A `goodcheck.yml` example of the configuration is like the following:
46
64
 
47
65
  ```yaml
48
66
  rules:
@@ -51,7 +69,7 @@ rules:
51
69
  message: |
52
70
  GitHub is GitHub, not Github
53
71
 
54
- You may misspelling the name of the service!
72
+ You may be misspelling the name of the service!
55
73
  justification:
56
74
  - When you mean a service different from GitHub
57
75
  - When GitHub is renamed
@@ -64,36 +82,38 @@ rules:
64
82
  - <a>Signup via Github</a>
65
83
  ```
66
84
 
67
- The *rule* hash contains the following keys.
85
+ A *rule* hash under a `rules` list contains the following keys:
68
86
 
69
- * `id`: a string to identify rules (required)
70
- * `pattern`: a *pattern* or a sequence of *pattern*s
71
- * `message`: a string to tell writers why the code piece should be revised (required)
72
- * `justification`: a sequence of strings to tell writers when an exception can be allowed (optional)
73
- * `glob`: a *glob* or a sequence of *glob*s (optional)
74
- * `pass`: a string, or a sequence of strings, which does not match the given pattern (optional)
75
- * `fail`: a string, or a sequence of strings, which does match the given pattern (optional)
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)
76
94
 
77
- ### *pattern*
95
+ ### Pattern
78
96
 
79
- A *pattern* can be a *literal pattern*, *regexp pattern*, *token pattern*, or a string.
97
+ A pattern can be a *literal pattern*, *regexp pattern*, *token pattern*, or a string.
80
98
 
81
99
  #### String literal
82
100
 
83
- String literal represents a *literal pattern* or *regexp pattern*.
101
+ A string literal represents a *literal pattern* or *regexp pattern*.
84
102
 
85
103
  ```yaml
86
104
  pattern:
87
105
  - This is a literal pattern
88
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
89
109
  ```
90
110
 
91
- If the string value begins with `/` and ends with `/`, it is a *regexp pattern*.
111
+ If a string value begins with `/` and ends with `/`, it is a *regexp pattern*.
92
112
  You can optionally specify regexp options like `/casefold/i` or `/multiline/m`.
93
113
 
94
- #### *literal pattern*
114
+ #### Literal pattern
95
115
 
96
- *literal pattern* allows you to construct a regexp which matches exactly to the `literal` string.
116
+ A *literal pattern* allows you to construct a regexp which matches exactly to the `literal` string.
97
117
 
98
118
  ```yaml
99
119
  id: com.sample.GitHub
@@ -106,9 +126,9 @@ message: Write GitHub, not Github
106
126
  All regexp meta characters included in the `literal` value will be escaped.
107
127
  `case_sensitive` is an optional key and the default is `true`.
108
128
 
109
- #### *regexp pattern*
129
+ #### Regexp pattern
110
130
 
111
- *regexp pattern* allows you to write a regexp with meta chars.
131
+ A *regexp pattern* allows you to write a regexp with meta chars.
112
132
 
113
133
  ```yaml
114
134
  id: com.sample.digits
@@ -124,12 +144,12 @@ justification:
124
144
  It accepts two optional attributes, `case_sensitive` and `multiline`.
125
145
  The default values of `case_sensitive` and `multiline` are `true` and `false` respectively.
126
146
 
127
- The regexp will be passed to `Regexp.compile`.
147
+ The regexp will be passed to [`Regexp.compile`](https://ruby-doc.org/core-2.7.0/Regexp.html#method-c-compile).
128
148
  The precise definition of regular expressions can be found in the documentation for Ruby.
129
149
 
130
- #### *token pattern*
150
+ #### Token pattern
131
151
 
132
- *token pattern* compiles to a *tokenized* regexp.
152
+ A *token pattern* compiles to a *tokenized* regexp.
133
153
 
134
154
  ```yaml
135
155
  id: com.sample.no-blink
@@ -162,9 +182,9 @@ pattern:
162
182
  color: true
163
183
  ```
164
184
 
165
- The variable binding consists of *variable name* and *variable type*, where `color` and `string` in the example above respectively. You have to add a key of the *variable name* in `where` attribute.
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.
166
186
 
167
- We have 8 built-in patterns:
187
+ We have 8 built-in types:
168
188
 
169
189
  * `string`
170
190
  * `int`
@@ -175,7 +195,7 @@ We have 8 built-in patterns:
175
195
  * `word`
176
196
  * `identifier`
177
197
 
178
- You can find the exact definitions of the types in the definition of `Goodcheck::Pattern::Token` (`@@TYPES`).
198
+ You can find the exact definitions of the types in the definition of [`Goodcheck::Pattern::Token`](lib/goodcheck/pattern.rb) (`@@TYPES`).
179
199
 
180
200
  You can omit the type of variable binding.
181
201
 
@@ -197,14 +217,21 @@ If parens or brackets are surrounding the variable, Goodcheck tries to match wit
197
217
  - `backgroundColor={{ red: red(), green: green(), blue: green()-1 }}` Matches (`color=="{ red: red(), green: green(), blue: green()-1 }"`)
198
218
  - `backgroundColor={ {{{{{{}}}}}} }` Matches (`color==" {{{{{{}}}}}"`)
199
219
 
200
- ### *glob*
220
+ ### Glob
201
221
 
202
- A *glob* can be a string, or a hash.
222
+ A *glob* can be a string or a hash.
203
223
 
204
224
  ```yaml
225
+ glob: "**/test/**/*.rb"
226
+ # or
205
227
  glob:
206
228
  pattern: "legacy/**/*.rb"
207
229
  encoding: EUC-JP
230
+ # or
231
+ glob:
232
+ - "**/test/**/*.rb"
233
+ - pattern: "legacy/**/*.rb"
234
+ encoding: EUC-JP
208
235
  ```
209
236
 
210
237
  The hash can have an optional `encoding` attribute.
@@ -237,13 +264,12 @@ You can define the _negated_ rules for the opposite, _something is missing in a
237
264
  rules:
238
265
  - id: negated
239
266
  not:
240
- pattern:
241
- <!DOCTYPE html>
267
+ pattern: <!DOCTYPE html>
242
268
  message: Write a doctype on HTML files.
243
269
  glob: "**/*.html"
244
270
  ```
245
271
 
246
- ### A rule without `pattern`
272
+ ### A rule without pattern
247
273
 
248
274
  You can define a rule without `pattern`.
249
275
  The rule emits an issue on each file specified with `glob`.
@@ -259,15 +285,15 @@ rules:
259
285
 
260
286
  The output will be something like:
261
287
 
262
- ```
288
+ ```shell-session
263
289
  $ goodcheck check
264
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
265
291
  ```
266
292
 
267
293
  ### Triggers
268
294
 
269
- Version 2.0.0 introduces a new abstraction to define patterns, trigger.
270
- You can continue using `pattern`s in `rule`, but using `trigger` allows more flexible pattern definition and more precise testing.
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.
271
297
 
272
298
  ```yaml
273
299
  rules:
@@ -303,13 +329,25 @@ import:
303
329
  - https://some.host/shared/rules.yml
304
330
  ```
305
331
 
306
- The value of `import` can be an array of:
332
+ The value of `import` can be a sequence of:
307
333
 
308
334
  - A string which represents an absolute file path,
309
335
  - A string which represents a relative file path from the config file, or
310
- - A http/https URL which represents the location of rules
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
311
348
 
312
- The rules file is a YAML file with an array of rules.
349
+ # ...
350
+ ```
313
351
 
314
352
  ## Excluding files
315
353
 
@@ -319,9 +357,10 @@ The rules file is a YAML file with an array of rules.
319
357
  exclude:
320
358
  - node_modules
321
359
  - vendor
360
+ - **/test/**/*.txt
322
361
  ```
323
362
 
324
- The value of `exclude` can be a string or an array of strings representing the glob pattern for excluded files.
363
+ The value of `exclude` can be a string or a sequence of strings representing the glob pattern for excluded files.
325
364
 
326
365
  ## Commands
327
366
 
@@ -342,7 +381,7 @@ You can pass:
342
381
  * Directory paths, or
343
382
  * Paths to files.
344
383
 
345
- When you omit `targets`, it checks all files in `.`.
384
+ When you omit `targets`, it checks all files in `.` (the current directory).
346
385
 
347
386
  Available options are:
348
387
 
@@ -377,7 +416,7 @@ Available options are:
377
416
  * `-c [CONFIG]`, `--config=[CONFIG]` to specify the configuration file.
378
417
  * `-v`, `--verbose` to be verbose.
379
418
  * `--debug` to print all debug messages.
380
- * `--force` to ignore downloaded caches
419
+ * `--force` to ignore downloaded caches.
381
420
 
382
421
  ### `goodcheck pattern [options] ids...`
383
422
 
@@ -395,11 +434,29 @@ The *goodcheck home directory* is `~/.goodcheck`, but you can customize the loca
395
434
 
396
435
  The cache expires in 3 minutes.
397
436
 
398
- ## Docker Images
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
+ ```
399
456
 
400
- We provide Docker images of Goodcheck so that you can try Goodcheck without installing them.
457
+ ## Docker images
401
458
 
402
- - https://hub.docker.com/r/sider/goodcheck/
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.
403
460
 
404
461
  ```bash
405
462
  $ docker pull sider/goodcheck
@@ -407,11 +464,11 @@ $ docker run -t --rm -v "$(pwd):/work" sider/goodcheck check
407
464
  ```
408
465
 
409
466
  The default `latest` tag points to the latest release of Goodcheck.
410
- You can pick a version of Goodcheck from [tags page](https://hub.docker.com/r/sider/goodcheck/tags).
467
+ You can pick a version of Goodcheck from the [Docker Hub tags page](https://hub.docker.com/r/sider/goodcheck/tags).
411
468
 
412
469
  ## Development
413
470
 
414
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
471
+ After checking out the repository, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
415
472
 
416
473
  To install this gem onto your local machine, run `bundle exec rake install`.
417
474
 
@@ -419,8 +476,10 @@ To release a new version, follows the steps below:
419
476
 
420
477
  1. Update the version number in [`version.rb`](lib/goodcheck/version.rb).
421
478
  2. Add the new version's entry to the [changelog](CHANGELOG.md).
422
- 3. Commit the above changes like `git commit -m 'Version 1.2.3'`.
423
- 4. 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).
479
+ 3. Update the documentation via `bundle exec rake docs:update_version`.
480
+ 4. Commit the above changes like `git commit -m 'Version 1.2.3'`.
481
+ 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`.
424
483
 
425
484
  ## Contributing
426
485