goodcheck 2.4.0 β†’ 2.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/README.md +37 -37
  4. data/docusaurus/.dockerignore +2 -0
  5. data/docusaurus/.gitignore +12 -0
  6. data/docusaurus/Dockerfile +10 -0
  7. data/docusaurus/docker-compose.yml +18 -0
  8. data/docusaurus/docs/commands.md +69 -0
  9. data/docusaurus/docs/configuration.md +300 -0
  10. data/docusaurus/docs/development.md +15 -0
  11. data/docusaurus/docs/getstarted.md +46 -0
  12. data/docusaurus/docs/rules.md +79 -0
  13. data/docusaurus/website/README.md +193 -0
  14. data/docusaurus/website/core/Footer.js +100 -0
  15. data/docusaurus/website/package.json +14 -0
  16. data/docusaurus/website/pages/en/index.js +207 -0
  17. data/docusaurus/website/pages/en/versions.js +118 -0
  18. data/docusaurus/website/sidebars.json +11 -0
  19. data/docusaurus/website/siteConfig.js +171 -0
  20. data/docusaurus/website/static/css/code-block-buttons.css +39 -0
  21. data/docusaurus/website/static/css/custom.css +245 -0
  22. data/docusaurus/website/static/img/favicon.ico +0 -0
  23. data/docusaurus/website/static/js/code-block-buttons.js +47 -0
  24. data/docusaurus/website/versioned_docs/version-1.0.0/commands.md +70 -0
  25. data/docusaurus/website/versioned_docs/version-1.0.0/configuration.md +296 -0
  26. data/docusaurus/website/versioned_docs/version-1.0.0/development.md +16 -0
  27. data/docusaurus/website/versioned_docs/version-1.0.0/getstarted.md +47 -0
  28. data/docusaurus/website/versioned_docs/version-1.0.0/rules.md +81 -0
  29. data/docusaurus/website/versioned_docs/version-1.0.2/rules.md +79 -0
  30. data/docusaurus/website/versioned_docs/version-2.4.0/configuration.md +301 -0
  31. data/docusaurus/website/versioned_sidebars/version-1.0.0-sidebars.json +11 -0
  32. data/docusaurus/website/versioned_sidebars/version-1.0.2-sidebars.json +11 -0
  33. data/docusaurus/website/versioned_sidebars/version-2.4.0-sidebars.json +11 -0
  34. data/docusaurus/website/versions.json +6 -0
  35. data/docusaurus/website/yarn.lock +6674 -0
  36. data/goodcheck.gemspec +1 -1
  37. data/lib/goodcheck.rb +1 -0
  38. data/lib/goodcheck/version.rb +1 -1
  39. metadata +36 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7da3a85a6dd3f95677661f7863fbc9d51da6ec01272c5e023fa2517aebd7db01
4
- data.tar.gz: 8c5f69286210ead4b2f58cc9d11278afad7c704f9056fb2e29b43dad89859985
3
+ metadata.gz: '0930f29362c1246d4ebf3ab77df6caceae4faf00c794ddf02a4ddc8a46e40ed8'
4
+ data.tar.gz: b5240b5e69734794f4ee1568e42d1c72ee3af54be9a38913d57d5ffe163b374b
5
5
  SHA512:
6
- metadata.gz: b7394690992cdec71af0ad640998142b77fd07814b9266ce148b18ca65d56f76eadde56d70384e5bc46e3d50911e41ef4350532aeab7f7fc8f85168c4bee46e8
7
- data.tar.gz: 9acb5eb4387b21293c2e83501cc8478afd2a5c5e3acf49f6db05660cec6c8da28959bcfe398396f3a08312dad14b666c5b5cef199dffd0be0df9aee2071c80bc
6
+ metadata.gz: 558c3abf6efcd0d56bcfdb751cfddecf494efcbb39d3a9b7161ce2b4f34757e9d40f406ece1b39f773f9c27fe8ff07dd083baa978844aadd6fb6897ac9e77015
7
+ data.tar.gz: aa2657a0fbbb9f0b09c67fffc741c845c856b466c99f568e2e60b6885e2eab2677bf9c1977921315a8ac2aee0c0c2d7c35f7d31f653ee7fb437f4c3a986f4b8b
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 2.4.1 (2019-08-29)
6
+
7
+ * Relax dependency requirement for ActiveSupport [#68](https://github.com/sider/goodcheck/pull/68)
8
+
5
9
  ## 2.4.0 (2019-07-11)
6
10
 
7
11
  * Add `pattern` command to print regexp of patterns [#63](https://github.com/sider/goodcheck/pull/63)
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  # Goodcheck - Regexp based customizable linter
4
4
 
5
5
  Are you reviewing a pull request if the change contains deprecated API calls?
6
- Do you want to post a comment to ask the developer if a method call satisfies some condition to use that without causing an issue?
6
+ Do you want to post a comment to ask the developer if a method call satisfies some condition for use without causing an issue?
7
7
  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! πŸŽ‰
@@ -11,8 +11,8 @@ Give Goodcheck a try to do them instead of you! πŸŽ‰
11
11
  Goodcheck is a customizable linter.
12
12
  You can define pairs of patterns and messages.
13
13
  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
- Some part of code reviewing process can be automated.
15
- Everything you have to do is to define the rules, pairs of patterns and messages, and nothing will bother you. πŸ˜†
14
+ Some part of the code reviewing process can be automated.
15
+ 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
16
 
17
17
  ## Installation
18
18
 
@@ -32,7 +32,7 @@ $ vim goodcheck.yml
32
32
  $ goodcheck check
33
33
  ```
34
34
 
35
- The `init` command generates template of `goodcheck.yml` configuration file for you.
35
+ The `init` command generates a template of `goodcheck.yml` configuration file for you.
36
36
  Edit the config file to define patterns you want to check.
37
37
  Then run `check` command, and it will print matched texts.
38
38
 
@@ -42,7 +42,7 @@ You can download a [printable cheatsheet](cheatsheet.pdf) from this repository.
42
42
 
43
43
  ## `goodcheck.yml`
44
44
 
45
- An example of configuration is like the following:
45
+ An example of the configuration is like the following:
46
46
 
47
47
  ```yaml
48
48
  rules:
@@ -69,10 +69,10 @@ The *rule* hash contains the following keys.
69
69
  * `id`: a string to identify rules (required)
70
70
  * `pattern`: a *pattern* or a sequence of *pattern*s
71
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 a exception can be allowed (optional)
72
+ * `justification`: a sequence of strings to tell writers when an exception can be allowed (optional)
73
73
  * `glob`: a *glob* or a sequence of *glob*s (optional)
74
- * `pass`: a string, or a sequence of strings, which does not match given pattern (optional)
75
- * `fail`: a string, or a sequence of strings, which does match given pattern (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)
76
76
 
77
77
  ### *pattern*
78
78
 
@@ -84,8 +84,8 @@ String literal represents a *literal pattern* or *regexp pattern*.
84
84
 
85
85
  ```yaml
86
86
  pattern:
87
- - This is literal pattern
88
- - /This is regexp pattern/
87
+ - This is a literal pattern
88
+ - /This is a regexp pattern/
89
89
  ```
90
90
 
91
91
  If the string value begins with `/` and ends with `/`, it is a *regexp pattern*.
@@ -125,7 +125,7 @@ It accepts two optional attributes, `case_sensitive` and `multiline`.
125
125
  The default values of `case_sensitive` and `multiline` are `true` and `false` respectively.
126
126
 
127
127
  The regexp will be passed to `Regexp.compile`.
128
- The precise definition of regular expression can be found in the documentation for Ruby.
128
+ The precise definition of regular expressions can be found in the documentation for Ruby.
129
129
 
130
130
  #### *token pattern*
131
131
 
@@ -142,7 +142,7 @@ justification:
142
142
  - If Lynx is the major target of the web site
143
143
  ```
144
144
 
145
- It tries to tokenize the input and generates a regexp which matches sequence of tokens.
145
+ It tries to tokenize the input and generates a regexp which matches a sequence of tokens.
146
146
  The tokenization is heuristic and may not work well for your programming language.
147
147
  In that case, try using *regexp pattern*.
148
148
 
@@ -153,7 +153,7 @@ It accepts one optional attribute `case_sensitive`.
153
153
  The default value of `case_sensitive` is `true`.
154
154
  Note that the generated regexp is in multiline mode.
155
155
 
156
- Token pattern can have optional `where` attribute and *variable bindings*.
156
+ Token patterns can have an optional `where` attribute and *variable bindings*.
157
157
 
158
158
  ```yaml
159
159
  pattern:
@@ -177,7 +177,7 @@ We have 8 built-in patterns:
177
177
 
178
178
  You can find the exact definitions of the types in the definition of `Goodcheck::Pattern::Token` (`@@TYPES`).
179
179
 
180
- You can omit the type of a variable binding.
180
+ You can omit the type of variable binding.
181
181
 
182
182
  ```yaml
183
183
  pattern:
@@ -191,7 +191,7 @@ pattern:
191
191
 
192
192
  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.
193
193
 
194
- If parens are surrounding the variable, Goodcheck tries to match with nested ones in the variable. It expands five levels of nesting of parens. See the example of matches with the second `backgroundColor` pattern:
194
+ 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:
195
195
 
196
196
  - `backgroundColor={color}` Matches (`color=="color"`)
197
197
  - `backgroundColor={{ red: red(), green: green(), blue: green()-1 }}` Matches (`color=="{ red: red(), green: green(), blue: green()-1 }"`)
@@ -208,15 +208,15 @@ glob:
208
208
  ```
209
209
 
210
210
  The hash can have an optional `encoding` attribute.
211
- You can specify encoding of the file by the names defined for ruby.
211
+ You can specify the encoding of the file by the names defined for Ruby.
212
212
  The list of all available encoding names can be found by `$ ruby -e "puts Encoding.name_list"`.
213
213
  The default value is `UTF-8`.
214
214
 
215
215
  If you write a string as a `glob`, the string value can be the `pattern` of the glob, without `encoding` attribute.
216
216
 
217
- If you omit `glob` attribute in a rule, the rule will be applied to all files given to `goodcheck`.
217
+ If you omit the `glob` attribute in a rule, the rule will be applied to all files given to `goodcheck`.
218
218
 
219
- If both of your rule and its pattern has `glob`, Goodcheck will scan the pattern from the `glob` files in the pattern.
219
+ If both your rule and its pattern has `glob`, Goodcheck will scan the pattern with files matching the `glob` condition in the pattern.
220
220
 
221
221
  ```yaml
222
222
  rules:
@@ -246,7 +246,7 @@ rules:
246
246
  ### A rule without `pattern`
247
247
 
248
248
  You can define a rule without `pattern`.
249
- The rule emits a issue on each file specified with `glob`.
249
+ The rule emits an issue on each file specified with `glob`.
250
250
  You cannot omit `glob` from a rule definition without `pattern`.
251
251
 
252
252
  ```yaml
@@ -266,7 +266,7 @@ db/schema.rb:-:# This file is auto-generated from the current state of the datab
266
266
 
267
267
  ### Triggers
268
268
 
269
- Version 2.0.0 introduces new abstruction to define patterns, trigger.
269
+ Version 2.0.0 introduces a new abstraction to define patterns, trigger.
270
270
  You can continue using `pattern`s in `rule`, but using `trigger` allows more flexible pattern definition and more precise testing.
271
271
 
272
272
  ```
@@ -289,12 +289,12 @@ rules:
289
289
  </html>
290
290
  ```
291
291
 
292
- You can continue existing `pattern` definitions, but `goodcheck test` against `pattern`s with `glob` does not work.
293
- If your `pattern` definition includes `glob`, switching `trigger` would make sense.
292
+ You can continue existing `pattern` definitions, but using `goodcheck test` against `pattern`s with `glob` does not work.
293
+ If your `pattern` definition includes `glob`, switching to `trigger` would make sense.
294
294
 
295
295
  ## Importing rules
296
296
 
297
- `goodcheck.yml` can have optional `import` attribute.
297
+ `goodcheck.yml` can have an optional `import` attribute.
298
298
 
299
299
  ```yaml
300
300
  import:
@@ -303,17 +303,17 @@ import:
303
303
  - https://some.host/shared/rules.yml
304
304
  ```
305
305
 
306
- Value of `import` can be an array of:
306
+ The value of `import` can be an array of:
307
307
 
308
308
  - A string which represents an absolute file path,
309
- - A string which represents an relative file path from config file, or
309
+ - A string which represents a relative file path from the config file, or
310
310
  - A http/https URL which represents the location of rules
311
311
 
312
- The rules file is a YAML file with array of rules.
312
+ The rules file is a YAML file with an array of rules.
313
313
 
314
314
  ## Excluding files
315
315
 
316
- `goodcheck.yml` can have optional `exclude` attribute.
316
+ `goodcheck.yml` can have an optional `exclude` attribute.
317
317
 
318
318
  ```yaml
319
319
  exclude:
@@ -321,18 +321,18 @@ exclude:
321
321
  - vendor
322
322
  ```
323
323
 
324
- Value of `exclude` can be a string or an array of strings representing the glob pattern for excluded files.
324
+ The value of `exclude` can be a string or an array of strings representing the glob pattern for excluded files.
325
325
 
326
326
  ## Commands
327
327
 
328
328
  ### `goodcheck init [options]`
329
329
 
330
- The `init` command generates an example of configuration file.
330
+ The `init` command generates an example of a configuration file.
331
331
 
332
332
  Available options are:
333
333
 
334
334
  * `-c=[CONFIG]`, `--config=[CONFIG]` to specify the configuration file name to generate.
335
- * `--force` to allow overwriting existing config file.
335
+ * `--force` to allow overwriting of an existing config file.
336
336
 
337
337
  ### `goodcheck check [options] targets...`
338
338
 
@@ -351,15 +351,15 @@ Available options are:
351
351
  * `--format=[text|json]` to specify output format.
352
352
  * `-v`, `--verbose` to be verbose.
353
353
  * `--debug` to print all debug messages.
354
- * `--force` to ignore downloaded caches
354
+ * `--force` to ignore downloaded caches.
355
355
 
356
356
  `goodcheck check` exits with:
357
357
 
358
- * `0` when it does not find any matching text fragment
359
- * `2` when it finds some matching text
360
- * `1` when it finds some error
358
+ * `0` when it does not find any matching text fragment.
359
+ * `2` when it finds some matching text.
360
+ * `1` when it finds some error.
361
361
 
362
- You can check its exit status to identify if the tool find some pattern or not.
362
+ You can check its exit status to identify if the tool finds some pattern or not.
363
363
 
364
364
  ### `goodcheck test [options]`
365
365
 
@@ -370,7 +370,7 @@ The test contains:
370
370
  * If `pass` examples does not match with any of `pattern`s.
371
371
  * If `fail` examples matches with some of `pattern`s.
372
372
 
373
- Use `test` command when you add new rule to be sure you are writing rules correctly.
373
+ Use `test` command when you add a new rule to be sure you are writing rules correctly.
374
374
 
375
375
  Available options are:
376
376
 
@@ -384,7 +384,7 @@ Available options are:
384
384
  The `pattern` command prints the regular expressions generated from the patterns.
385
385
  The command is for debugging patterns, especially token patterns.
386
386
 
387
- Available option is:
387
+ The available option is:
388
388
 
389
389
  * `-c [CONFIG]`, `--config=[CONFIG]` to specify the configuration file.
390
390
 
@@ -0,0 +1,2 @@
1
+ */node_modules
2
+ *.log
@@ -0,0 +1,12 @@
1
+ .DS_Store
2
+
3
+ node_modules
4
+
5
+ lib/core/metadata.js
6
+ lib/core/MetadataBlog.js
7
+
8
+ website/translated_docs
9
+ website/build/
10
+ website/package-lock.json
11
+ website/node_modules
12
+ website/i18n/*
@@ -0,0 +1,10 @@
1
+ FROM node:8.11.4
2
+
3
+ WORKDIR /app/website
4
+
5
+ EXPOSE 3000 35729
6
+ COPY ./docs /app/docs
7
+ COPY ./website /app/website
8
+ RUN yarn install
9
+
10
+ CMD ["yarn", "start"]
@@ -0,0 +1,18 @@
1
+ version: "3"
2
+
3
+ services:
4
+ docusaurus:
5
+ build: .
6
+ ports:
7
+ - 3000:3000
8
+ - 35729:35729
9
+ volumes:
10
+ - ./docs:/app/docs
11
+ - ./website/blog:/app/website/blog
12
+ - ./website/core:/app/website/core
13
+ - ./website/i18n:/app/website/i18n
14
+ - ./website/pages:/app/website/pages
15
+ - ./website/static:/app/website/static
16
+ - ./website/sidebars.json:/app/website/sidebars.json
17
+ - ./website/siteConfig.js:/app/website/siteConfig.js
18
+ working_dir: /app/website
@@ -0,0 +1,69 @@
1
+ ---
2
+ id: commands
3
+ title: Commands
4
+ sidebar_label: Commands
5
+ ---
6
+
7
+
8
+ ## `goodcheck init [options]`
9
+
10
+ The `init` command generates an example of a configuration file.
11
+
12
+ Available options are:
13
+
14
+ * `-c=[CONFIG]`, `--config=[CONFIG]` to specify the configuration file name to generate.
15
+ * `--force` to allow overwriting of an existing config file.
16
+
17
+ ## `goodcheck check [options] targets...`
18
+
19
+ The `check` command checks your programs under `targets...`.
20
+ You can pass:
21
+
22
+ * Directory paths, or
23
+ * Paths to files.
24
+
25
+ When you omit `targets`, it checks all files in `.`.
26
+
27
+ Available options are:
28
+
29
+ * `-c [CONFIG]`, `--config=[CONFIG]` to specify the configuration file.
30
+ * `-R [rule]`, `--rule=[rule]` to specify the rules you want to check.
31
+ * `--format=[text|json]` to specify output format.
32
+ * `-v`, `--verbose` to be verbose.
33
+ * `--debug` to print all debug messages.
34
+ * `--force` to ignore downloaded caches.
35
+
36
+ `goodcheck check` exits with:
37
+
38
+ * `0` when it does not find any matching text fragment.
39
+ * `2` when it finds some matching text.
40
+ * `1` when it finds some error.
41
+
42
+ You can check its exit status to identify if the tool finds some pattern or not.
43
+
44
+ ## `goodcheck test [options]`
45
+
46
+ The `test` command tests rules.
47
+ The test contains:
48
+
49
+ * Validation of rule `id` uniqueness.
50
+ * If `pass` examples does not match with any of `pattern`s.
51
+ * If `fail` examples matches with some of `pattern`s.
52
+
53
+ Use `test` command when you add a new rule to be sure you are writing rules correctly.
54
+
55
+ Available options are:
56
+
57
+ * `-c [CONFIG]`, `--config=[CONFIG]` to specify the configuration file.
58
+ * `-v`, `--verbose` to be verbose.
59
+ * `--debug` to print all debug messages.
60
+ * `--force` to ignore downloaded caches
61
+
62
+ ## `goodcheck pattern [options] ids...`
63
+
64
+ The `pattern` command prints the regular expressions generated from the patterns.
65
+ The command is for debugging patterns, especially token patterns.
66
+
67
+ The available option is:
68
+
69
+ * `-c [CONFIG]`, `--config=[CONFIG]` to specify the configuration file.
@@ -0,0 +1,300 @@
1
+ ---
2
+ id: configuration
3
+ title: Configuration
4
+ sidebar_label: Configuration
5
+ ---
6
+
7
+ ## `goodcheck.yml`
8
+
9
+ An example of the configuration is like the following:
10
+
11
+ ```yaml
12
+ rules:
13
+ - id: com.example.github
14
+ pattern: Github
15
+ message: |
16
+ GitHub is GitHub, not Github
17
+
18
+ You may misspelling the name of the service!
19
+ justification:
20
+ - When you mean a service different from GitHub
21
+ - When GitHub is renamed
22
+ glob:
23
+ - app/views/**/*.html.slim
24
+ - config/locales/**/*.yaml
25
+ pass:
26
+ - <a>Signup via GitHub</a>
27
+ fail:
28
+ - <a>Signup via Github</a>
29
+ ```
30
+
31
+ The *rule* hash contains the following keys.
32
+
33
+ * `id`: a string to identify rules (required)
34
+ * `pattern`: a *pattern* or a sequence of *pattern*s
35
+ * `message`: a string to tell writers why the code piece should be revised (required)
36
+ * `justification`: a sequence of strings to tell writers when an exception can be allowed (optional)
37
+ * `glob`: a *glob* or a sequence of *glob*s (optional)
38
+ * `pass`: a string, or a sequence of strings, which does not match the given pattern (optional)
39
+ * `fail`: a string, or a sequence of strings, which does match the given pattern (optional)
40
+
41
+ ## *pattern*
42
+
43
+ A *pattern* can be a *literal pattern*, *regexp pattern*, *token pattern*, or a string.
44
+
45
+ ### String literal
46
+
47
+ String literal represents a *literal pattern* or *regexp pattern*.
48
+
49
+ ```yaml
50
+ pattern:
51
+ - This is a literal pattern
52
+ - /This is a regexp pattern/
53
+ ```
54
+
55
+ If the string value begins with `/` and ends with `/`, it is a *regexp pattern*.
56
+ You can optionally specify regexp options like `/casefold/i` or `/multiline/m`.
57
+
58
+ ### *literal pattern*
59
+
60
+ *literal pattern* allows you to construct a regexp which matches exactly to the `literal` string.
61
+
62
+ ```yaml
63
+ id: com.sample.GitHub
64
+ pattern:
65
+ literal: Github
66
+ case_sensitive: true
67
+ message: Write GitHub, not Github
68
+ ```
69
+
70
+ All regexp meta characters included in the `literal` value will be escaped.
71
+ `case_sensitive` is an optional key and the default is `true`.
72
+
73
+ ### *regexp pattern*
74
+
75
+ *regexp pattern* allows you to write a regexp with meta chars.
76
+
77
+ ```yaml
78
+ id: com.sample.digits
79
+ pattern:
80
+ regexp: \d{4,}
81
+ case_sensitive: false
82
+ multiline: false
83
+ message: Insert delimiters when writing large numbers
84
+ justification:
85
+ - When you are not writing numbers, including phone numbers, zip code, ...
86
+ ```
87
+
88
+ It accepts two optional attributes, `case_sensitive` and `multiline`.
89
+ The default values of `case_sensitive` and `multiline` are `true` and `false` respectively.
90
+
91
+ The regexp will be passed to `Regexp.compile`.
92
+ The precise definition of regular expressions can be found in the documentation for Ruby.
93
+
94
+ ### *token pattern*
95
+
96
+ *token pattern* compiles to a *tokenized* regexp.
97
+
98
+ ```yaml
99
+ id: com.sample.no-blink
100
+ pattern:
101
+ token: "<blink"
102
+ case_sensitive: false
103
+ message: Stop using <blink> tag
104
+ glob: "**/*.html"
105
+ justification:
106
+ - If Lynx is the major target of the web site
107
+ ```
108
+
109
+ It tries to tokenize the input and generates a regexp which matches a sequence of tokens.
110
+ The tokenization is heuristic and may not work well for your programming language.
111
+ In that case, try using *regexp pattern*.
112
+
113
+ The generated regexp of `<blink` is `<\s*blink\b/m`.
114
+ It matches with `<blink />` and `< BLINK>`, but does not match with `https://www.chromium.org/blink`.
115
+
116
+ It accepts one optional attribute `case_sensitive`.
117
+ The default value of `case_sensitive` is `true`.
118
+ Note that the generated regexp is in multiline mode.
119
+
120
+ Token patterns can have an optional `where` attribute and *variable bindings*.
121
+
122
+ ```yaml
123
+ pattern:
124
+ - token: bgcolor=${color:string}
125
+ where:
126
+ color: true
127
+ ```
128
+
129
+ 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.
130
+
131
+ We have 8 built-in patterns:
132
+
133
+ * `string`
134
+ * `int`
135
+ * `float`
136
+ * `number`
137
+ * `url`
138
+ * `email`
139
+ * `word`
140
+ * `identifier`
141
+
142
+ You can find the exact definitions of the types in the definition of `Goodcheck::Pattern::Token` (`@@TYPES`).
143
+
144
+ You can omit the type of variable binding.
145
+
146
+ ```yaml
147
+ pattern:
148
+ - token: margin-left: ${size}px;
149
+ where:
150
+ size: true
151
+ - token: backgroundColor={${color}}
152
+ where:
153
+ color: true
154
+ ```
155
+
156
+ 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.
157
+
158
+ 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:
159
+
160
+ - `backgroundColor={color}` Matches (`color=="color"`)
161
+ - `backgroundColor={{ red: red(), green: green(), blue: green()-1 }}` Matches (`color=="{ red: red(), green: green(), blue: green()-1 }"`)
162
+ - `backgroundColor={ {{{{{{}}}}}} }` Matches (`color==" {{{{{{}}}}}"`)
163
+
164
+ ## *glob*
165
+
166
+ A *glob* can be a string, or a hash.
167
+
168
+ ```yaml
169
+ glob:
170
+ pattern: "legacy/**/*.rb"
171
+ encoding: EUC-JP
172
+ ```
173
+
174
+ The hash can have an optional `encoding` attribute.
175
+ You can specify the encoding of the file by the names defined for Ruby.
176
+ The list of all available encoding names can be found by `$ ruby -e "puts Encoding.name_list"`.
177
+ The default value is `UTF-8`.
178
+
179
+ If you write a string as a `glob`, the string value can be the `pattern` of the glob, without `encoding` attribute.
180
+
181
+ If you omit the `glob` attribute in a rule, the rule will be applied to all files given to `goodcheck`.
182
+
183
+ If both your rule and its pattern has `glob`, Goodcheck will scan the pattern with files matching the `glob` condition in the pattern.
184
+
185
+ ```yaml
186
+ rules:
187
+ - id: glob_test
188
+ pattern:
189
+ - literal: 123 # This pattern applies to .css files
190
+ glob: "*.css"
191
+ - literal: abc # This pattern applies to .txt files
192
+ glob: "*.txt"
193
+ ```
194
+
195
+ ## A rule with _negated_ pattern
196
+
197
+ Goodcheck rules are usually to detect _something is included in a file_.
198
+ You can define the _negated_ rules for the opposite, _something is missing in a file_.
199
+
200
+ ```yaml
201
+ rules:
202
+ - id: negated
203
+ not:
204
+ pattern:
205
+ <!DOCTYPE html>
206
+ message: Write a doctype on HTML files.
207
+ glob: "**/*.html"
208
+ ```
209
+
210
+ ## A rule without `pattern`
211
+
212
+ You can define a rule without `pattern`.
213
+ The rule emits an issue on each file specified with `glob`.
214
+ You cannot omit `glob` from a rule definition without `pattern`.
215
+
216
+ ```yaml
217
+ rules:
218
+ - id: without_pattern
219
+ message: |
220
+ Read the operation manual for DB migration: https://example.com/guides/123
221
+ glob: db/schema.rb
222
+ ```
223
+
224
+ The output will be something like:
225
+
226
+ ```
227
+ $ goodcheck check
228
+ 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
229
+ ```
230
+
231
+ ## Triggers
232
+
233
+ Version 2.0.0 introduces a new abstraction to define patterns, trigger.
234
+ You can continue using `pattern`s in `rule`, but using `trigger` allows more flexible pattern definition and more precise testing.
235
+
236
+ ```
237
+ rules:
238
+ - id: trigger
239
+ message: Using trigger
240
+ trigger:
241
+ - pattern: <blink
242
+ glob: "**/*.html"
243
+ fail:
244
+ - <blink></blink>
245
+ - not:
246
+ pattern:
247
+ token: <meta charset="UTF-8">
248
+ case_sensitive: false
249
+ glob: "**/*.html"
250
+ pass: |
251
+ <html>
252
+ <meta charset="utf-8"></meta>
253
+ </html>
254
+ ```
255
+
256
+ You can continue existing `pattern` definitions, but using `goodcheck test` against `pattern`s with `glob` does not work.
257
+ If your `pattern` definition includes `glob`, switching to `trigger` would make sense.
258
+
259
+ ## Importing rules
260
+
261
+ `goodcheck.yml` can have an optional `import` attribute.
262
+
263
+ ```yaml
264
+ import:
265
+ - /usr/share/goodcheck/rules.yml
266
+ - lib/goodcheck/rules.yml
267
+ - https://some.host/shared/rules.yml
268
+ ```
269
+
270
+ The value of `import` can be an array of:
271
+
272
+ - A string which represents an absolute file path,
273
+ - A string which represents a relative file path from the config file, or
274
+ - A http/https URL which represents the location of rules
275
+
276
+ The rules file is a YAML file with an array of rules.
277
+
278
+ ## Downloaded rules
279
+
280
+ Downloaded rules are cached in `cache` directory in *goodcheck home directory*.
281
+ The *goodcheck home directory* is `~/.goodcheck`, but you can customize the location with `GOODCHECK_HOME` environment variable.
282
+
283
+ The cache expires in 3 minutes.
284
+
285
+ ## Excluding files
286
+
287
+ `goodcheck.yml` can have an optional `exclude` attribute.
288
+
289
+ ```yaml
290
+ exclude:
291
+ - node_modules
292
+ - vendor
293
+ ```
294
+
295
+ The value of `exclude` can be a string or an array of strings representing the glob pattern for excluded files.
296
+
297
+
298
+ ## Cheatsheet
299
+
300
+ You can download a [printable cheatsheet](https://github.com/sider/goodcheck/blob/master/cheatsheet.pdf) from this repository.