rubocop-kata 0.3.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +63 -0
- data/README.md +32 -5
- data/config/default.yml +140 -11
- data/data/CSPELL-LICENSE +21 -0
- data/data/SCOWL-COPYRIGHT +248 -0
- data/data/software.txt.gz +0 -0
- data/data/supplement.txt +92 -0
- data/data/words.txt.gz +0 -0
- data/lib/rubocop/cop/kata/good_method_name.rb +46 -0
- data/lib/rubocop/cop/kata/good_variable_name.rb +59 -0
- data/lib/rubocop/cop/kata/real_words.rb +83 -0
- data/lib/rubocop/kata/version.rb +1 -1
- data/lib/rubocop-kata.rb +3 -2
- metadata +15 -6
- data/lib/rubocop/cop/kata/no_abbreviation.rb +0 -25
- data/lib/rubocop/cop/kata/no_nil_return.rb +0 -19
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 30d894b4455161e0ce3dac01fa4c627de974cf89e7d1372a610749ee9ba0ad26
|
|
4
|
+
data.tar.gz: 6bfcc2c6b38d212c8ff6ac0efc16bd4b563a74b972ccc546013619b813c0f6e2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f7c5bd992aa75df3b4f38c9182005dc7f346b4ea0db83e5756fb02f638acbc034b32a7146dece44e7c9421ce4d04cd064e02ce46309d6ba4513a8e5560540c5e
|
|
7
|
+
data.tar.gz: '08f28bf480cf2fcef885db1d5df0c92d3200a53b898dcc01fc026172214276a5a83a1a2b0b6bc807e2e4aed9ac78439cac6c50b7a53643986e44c05bf7a0e388'
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,68 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
## [0.6.0] - 2026-08-15
|
|
6
|
+
|
|
7
|
+
- The base dictionary is now SCOWL en-US size 60 (~83k words including
|
|
8
|
+
inflections — https://wordlist.aspell.net, see data/SCOWL-COPYRIGHT), so the
|
|
9
|
+
hand-rolled stemmer shrank to productive derivations only (-able, -er/-or
|
|
10
|
+
agent nouns, -less, plurals for supplement/software terms).
|
|
11
|
+
- `Kata/RealWords` now also draws on a vendored dictionary of software
|
|
12
|
+
vocabulary (`data/software.txt.gz`, ~4300 words) built from the MIT-licensed
|
|
13
|
+
cspell `software-terms`, `ruby`, and `shell` dictionaries
|
|
14
|
+
(https://github.com/streetsidesoftware/cspell-dicts) — `argv`, `stderr`,
|
|
15
|
+
`klass`, `mutex`, `regex`, and friends no longer need per-project `Terms`.
|
|
16
|
+
- The stemmer understands comparatives (`newer`, `deeper`), superlatives
|
|
17
|
+
(`longest`), and `-ied` pasts (`denied`); common irregular pasts (`held`,
|
|
18
|
+
`paid`, `heard`) joined the supplement.
|
|
19
|
+
- `Kata/GoodMethodName` ignores operator methods (`[]`, `==`, `<=>`, `<<`) —
|
|
20
|
+
Ruby dictates their names.
|
|
21
|
+
- `Kata/GoodVariableName` ships `_include_private` (the `respond_to_missing?`
|
|
22
|
+
protocol argument) in its default `AllowedNames`.
|
|
23
|
+
|
|
24
|
+
## [0.5.0] - 2026-08-15
|
|
25
|
+
|
|
26
|
+
- New cops `Kata/GoodMethodName` and `Kata/GoodVariableName`. One word is the
|
|
27
|
+
default and the goal; a second word is allowed only when it is not hiding a
|
|
28
|
+
missing object — a role prefix (`after_fork`, `each_group`, `to_h`), a role
|
|
29
|
+
suffix (`file_of`, `tests_for`, `points_at`), or a compound noun listed in
|
|
30
|
+
`Terms:`. `Terms:` is a budget you spend consciously, like `max_ignored` in a
|
|
31
|
+
mutation-testing config, not a silent escape hatch. `verb_receiver` names
|
|
32
|
+
(`build_adapter`, `apply_excludes`, `covering_count`) stay offenses, and so do
|
|
33
|
+
three-word names. The variable cop understands `@`, `@@`, `$`, and the
|
|
34
|
+
`_unused`/`@_memo` conventions.
|
|
35
|
+
- New cop `Kata/RealWords` replaces `Kata/NoAbbreviation`. A blocklist has to
|
|
36
|
+
enumerate its whole domain to work: an abbreviation nobody thought to ban
|
|
37
|
+
passed silently, and deleting the underscore (`matching_ids` → `matchingids`)
|
|
38
|
+
dodged the naming cops entirely. The check is now inverted — every
|
|
39
|
+
underscore-separated segment of a name must be a word the gem's shipped
|
|
40
|
+
dictionary knows, so `errorcount` and `cfg` fail with zero configuration
|
|
41
|
+
while `deadline` and `mutant` sail through. The dictionary is the web2
|
|
42
|
+
wordlist (lowercase, 2–16 letters, gzipped in `data/`), a visible
|
|
43
|
+
`data/supplement.txt` of modern vocabulary web2 predates (`json`,
|
|
44
|
+
`memoize`, `timestamp`), and a light stemmer for plurals, `-ed`, `-ing`,
|
|
45
|
+
`-able`, and `un-`/`re-`/`non-`. `BannedWords:` keeps flagging abbreviations
|
|
46
|
+
that happen to be dictionary words (`err`, `res`, `pos`); `Terms:` is the
|
|
47
|
+
reviewed domain-jargon budget and overrides `BannedWords:`; `AllowedNames:`
|
|
48
|
+
exempts names an external protocol dictates (`def pos` on a scanner,
|
|
49
|
+
`def env` for Rack). Operator names, single-letter segments, and the
|
|
50
|
+
`_unused`/`@_memo` shapes are ignored. Method names, ivars, class variables,
|
|
51
|
+
and globals are all checked — `Kata/NoAbbreviation` saw only locals and
|
|
52
|
+
parameters.
|
|
53
|
+
- `Elegant/GoodMethodName` and `Elegant/GoodVariableName` are now disabled:
|
|
54
|
+
Kata owns naming, and the upstream one-word-only rule is what pushed people
|
|
55
|
+
into deleting underscores in the first place.
|
|
56
|
+
- Removed `Kata/NoNilReturn`: duplicate of the bundled `Elegant/NoNilReturn`,
|
|
57
|
+
which covers a superset (blocks, lambdas, `kwbegin` tails).
|
|
58
|
+
|
|
59
|
+
## [0.4.0] - 2026-08-14
|
|
60
|
+
- `Naming/MemoizedInstanceVariableName` enforced with
|
|
61
|
+
`EnforcedStyleForLeadingUnderscores: required`: memoization caches are
|
|
62
|
+
named `@_name`, marking lazy state at the read site.
|
|
63
|
+
- `Elegant/GoodVariableName` pattern extended to accept the `@_word`
|
|
64
|
+
memo shape.
|
|
65
|
+
|
|
3
66
|
## [0.3.0] - 2026-08-14
|
|
4
67
|
|
|
5
68
|
- Ten new house cops in the Elegant Objects spirit, all on by default:
|
data/README.md
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
# rubocop-kata
|
|
2
2
|
|
|
3
|
-
A RuboCop plugin that replaces a pile of linter gems and config with one dependency. Install it and your `.rubocop.yml` shrinks to project-specific overrides. Everything else comes from the gem: a curated stack of RuboCop extensions, opinionated style defaults, and
|
|
3
|
+
A RuboCop plugin that replaces a pile of linter gems and config with one dependency. Install it and your `.rubocop.yml` shrinks to project-specific overrides. Everything else comes from the gem: a curated stack of RuboCop extensions, opinionated style defaults, and fifteen house cops.
|
|
4
|
+
|
|
5
|
+
`Kata/GoodMethodName` asks for one word per method name. A second word is
|
|
6
|
+
allowed only when it is not hiding a missing object: a role prefix
|
|
7
|
+
(`after_fork`), a role suffix (`file_of`), or a compound noun you have added to
|
|
8
|
+
`Terms` on purpose. The wrong way to satisfy the cop is `matching_ids` →
|
|
9
|
+
`matchingids`: if you need two words, that is a modelling smell — the concept is
|
|
10
|
+
missing, or the method belongs on a different object. `Kata/RealWords` catches
|
|
11
|
+
that dodge with a shipped dictionary instead of a word list you maintain:
|
|
12
|
+
`matchingids` is not a word, so it fails with zero configuration — and so does
|
|
13
|
+
`cfg`.
|
|
4
14
|
|
|
5
15
|
- **One dependency.** Bundles rubocop-rspec, rubocop-performance, rubocop-elegant, rubocop-packaging, and rubocop-thread_safety behind a single gem.
|
|
6
16
|
- **Opinionated defaults.** Methods under 5 lines, classes under 100, 4 parameters max, 120-column lines, double quotes, `NewCops: enable`. See [config/default.yml](config/default.yml).
|
|
7
|
-
- **
|
|
17
|
+
- **Fifteen house cops.** Naming, dependency discipline, and data honesty in the Elegant Objects spirit — from `Kata/AgentNoun` to `Kata/ClockDiscipline`.
|
|
8
18
|
|
|
9
19
|
```ruby
|
|
10
20
|
class PaymentProcessor # Kata/AgentNoun: `PaymentProcessor` names a doer;
|
|
@@ -48,13 +58,14 @@ That's it. The plugin loads the bundled extensions and the shared defaults, so y
|
|
|
48
58
|
| `Kata/IoDiscipline` | on | No bare `puts`/`warn`/`pp`/`p` outside specs/scripts; write through an injected `@io` or an explicit receiver. |
|
|
49
59
|
| `Kata/ProsePlacement` | off | Sentence-length strings belong in the presentation layer. Enable with an `Include`/`Exclude` matching your layering. |
|
|
50
60
|
| `Kata/NoUtilName` | on | No junk-drawer names (`Util`, `Helper`, `Manager`, `Service`, …). Tune via `BannedNames`. |
|
|
51
|
-
| `Kata/
|
|
61
|
+
| `Kata/RealWords` | on | Every name segment is a word the shipped dictionary knows — `errorcount` (smash) and `cfg` (abbreviation) both fail, with no word list to maintain. Tune via `Terms`/`BannedWords`/`AllowedNames`. |
|
|
62
|
+
| `Kata/GoodMethodName` | on | One word per method name; a second word needs a role prefix (`after_fork`), a role suffix (`file_of`), or a reviewed `Terms` entry. Tune via `MaxWords`/`Prefixes`/`Suffixes`/`Terms`/`AllowedNames`. |
|
|
63
|
+
| `Kata/GoodVariableName` | on | The same rule for locals, parameters, ivars, class variables, and globals; `_name` and `@_name` stay exempt. |
|
|
52
64
|
| `Kata/BuilderNoun` | on | Builders named for what they return: `total`, not `calculate_total`. Tune via `BannedPrefixes`. |
|
|
53
65
|
| `Kata/NoBooleanFlag` | on | No positional boolean arguments; split the method or use a keyword. |
|
|
54
66
|
| `Kata/ConstructorDiscipline` | on | `initialize` assigns, raises, or freezes — never computes. |
|
|
55
67
|
| `Kata/NoClassMethodLogic` | on | Class methods construct (`build`, `parse`, `of`, `from_*`); instances do the work. |
|
|
56
68
|
| `Kata/NoHashAsObject` | on | A hash with `MaxKeys`+ keys (default 4) wants to be an object. Keyword-argument call sites exempt. |
|
|
57
|
-
| `Kata/NoNilReturn` | on | No `return nil` or trailing `nil`; raise or return a real object. |
|
|
58
69
|
| `Kata/ClockDiscipline` | on | No bare `Time.now`/`Date.today`/`.current`; inject a clock. |
|
|
59
70
|
| `Kata/EnvDiscipline` | on | `ENV` reads only in the boot layer (`config/`, `bin/`, `exe/`). |
|
|
60
71
|
|
|
@@ -68,4 +79,20 @@ spec examples. See
|
|
|
68
79
|
|
|
69
80
|
## License
|
|
70
81
|
|
|
71
|
-
MIT.
|
|
82
|
+
The code is MIT — see [LICENSE.txt](LICENSE.txt). The shipped dictionaries are
|
|
83
|
+
third-party data under their own terms:
|
|
84
|
+
|
|
85
|
+
- **`data/words.txt.gz`** — a *modified* subset of [SCOWL](https://wordlist.aspell.net)
|
|
86
|
+
en-US size 60: filtered, deduplicated, and gzipped. SCOWL is the collective work of
|
|
87
|
+
Kevin Atkinson and the contributors named in
|
|
88
|
+
[data/SCOWL-COPYRIGHT](data/SCOWL-COPYRIGHT), which is distributed with this gem and
|
|
89
|
+
reproduced verbatim. It includes, among others, Copyright 2000–2018 Kevin Atkinson;
|
|
90
|
+
WordNet 1.6 Copyright 1997 by Princeton University, all rights reserved; and Copyright
|
|
91
|
+
1993 Geoff Kuenning, Granada Hills, CA, all rights reserved. Princeton University makes
|
|
92
|
+
no representations or warranties, express or implied, as to this database, and its name
|
|
93
|
+
may not be used in advertising or publicity pertaining to this distribution.
|
|
94
|
+
- **`data/software.txt.gz`** — built from the `software-terms`, `ruby`, and `shell`
|
|
95
|
+
dictionaries of [cspell-dicts](https://github.com/streetsidesoftware/cspell-dicts),
|
|
96
|
+
each MIT-licensed. Copyright (c) 2017–2025 Street Side Software; the notice and
|
|
97
|
+
permission text are reproduced in [data/CSPELL-LICENSE](data/CSPELL-LICENSE).
|
|
98
|
+
- **`data/supplement.txt`** — this project's own additions, MIT.
|
data/config/default.yml
CHANGED
|
@@ -25,6 +25,118 @@ Kata/NoComments:
|
|
|
25
25
|
- "spec/**/*"
|
|
26
26
|
- "*.gemspec"
|
|
27
27
|
|
|
28
|
+
Kata/GoodMethodName:
|
|
29
|
+
Description: >-
|
|
30
|
+
One word per method name. A second word is allowed only when it does not
|
|
31
|
+
hide a missing object: a role prefix (`after_fork`), a role suffix
|
|
32
|
+
(`file_of`), or a reviewed domain term. Do not delete the underscore —
|
|
33
|
+
Kata/RealWords catches the smash.
|
|
34
|
+
Enabled: true
|
|
35
|
+
VersionAdded: "0.5"
|
|
36
|
+
MaxWords: 2
|
|
37
|
+
Pattern: "^[a-z][a-z0-9]{0,15}$"
|
|
38
|
+
Prefixes:
|
|
39
|
+
- after
|
|
40
|
+
- all
|
|
41
|
+
- any
|
|
42
|
+
- around
|
|
43
|
+
- as
|
|
44
|
+
- at
|
|
45
|
+
- before
|
|
46
|
+
- by
|
|
47
|
+
- each
|
|
48
|
+
- every
|
|
49
|
+
- fake
|
|
50
|
+
- for
|
|
51
|
+
- from
|
|
52
|
+
- into
|
|
53
|
+
- "no"
|
|
54
|
+
- non
|
|
55
|
+
- "on"
|
|
56
|
+
- per
|
|
57
|
+
- test
|
|
58
|
+
- the
|
|
59
|
+
- to
|
|
60
|
+
- unless
|
|
61
|
+
- until
|
|
62
|
+
- when
|
|
63
|
+
- while
|
|
64
|
+
- with
|
|
65
|
+
- without
|
|
66
|
+
Suffixes:
|
|
67
|
+
- at
|
|
68
|
+
- by
|
|
69
|
+
- for
|
|
70
|
+
- from
|
|
71
|
+
- in
|
|
72
|
+
- into
|
|
73
|
+
- of
|
|
74
|
+
- on
|
|
75
|
+
- over
|
|
76
|
+
- per
|
|
77
|
+
- to
|
|
78
|
+
- under
|
|
79
|
+
- with
|
|
80
|
+
- without
|
|
81
|
+
Terms: []
|
|
82
|
+
AllowedNames: []
|
|
83
|
+
|
|
84
|
+
Kata/GoodVariableName:
|
|
85
|
+
Description: >-
|
|
86
|
+
One word per variable name. A second word means a missing object, not a
|
|
87
|
+
name to smash together — Kata/RealWords catches the smash. Role prefixes, role
|
|
88
|
+
suffixes, and reviewed domain terms are the three exceptions.
|
|
89
|
+
Enabled: true
|
|
90
|
+
VersionAdded: "0.5"
|
|
91
|
+
MaxWords: 2
|
|
92
|
+
Pattern: "^[a-z][a-z0-9]{0,15}$"
|
|
93
|
+
Prefixes:
|
|
94
|
+
- after
|
|
95
|
+
- all
|
|
96
|
+
- any
|
|
97
|
+
- around
|
|
98
|
+
- as
|
|
99
|
+
- at
|
|
100
|
+
- before
|
|
101
|
+
- by
|
|
102
|
+
- each
|
|
103
|
+
- every
|
|
104
|
+
- fake
|
|
105
|
+
- for
|
|
106
|
+
- from
|
|
107
|
+
- into
|
|
108
|
+
- "no"
|
|
109
|
+
- non
|
|
110
|
+
- "on"
|
|
111
|
+
- per
|
|
112
|
+
- test
|
|
113
|
+
- the
|
|
114
|
+
- to
|
|
115
|
+
- unless
|
|
116
|
+
- until
|
|
117
|
+
- when
|
|
118
|
+
- while
|
|
119
|
+
- with
|
|
120
|
+
- without
|
|
121
|
+
Suffixes:
|
|
122
|
+
- at
|
|
123
|
+
- by
|
|
124
|
+
- for
|
|
125
|
+
- from
|
|
126
|
+
- in
|
|
127
|
+
- into
|
|
128
|
+
- of
|
|
129
|
+
- on
|
|
130
|
+
- over
|
|
131
|
+
- per
|
|
132
|
+
- to
|
|
133
|
+
- under
|
|
134
|
+
- with
|
|
135
|
+
- without
|
|
136
|
+
Terms: []
|
|
137
|
+
AllowedNames:
|
|
138
|
+
- _include_private
|
|
139
|
+
|
|
28
140
|
Kata/IoDiscipline:
|
|
29
141
|
Description: "Write through an injected io, not bare puts/warn/pp/p."
|
|
30
142
|
Enabled: true
|
|
@@ -58,11 +170,15 @@ Kata/NoUtilName:
|
|
|
58
170
|
- Misc
|
|
59
171
|
- Shared
|
|
60
172
|
|
|
61
|
-
Kata/
|
|
62
|
-
Description:
|
|
173
|
+
Kata/RealWords:
|
|
174
|
+
Description: >-
|
|
175
|
+
Every name segment is a dictionary word: `errorcount` is a smash, `cfg`
|
|
176
|
+
is an abbreviation, `mutant` is fine. The dictionary ships with the gem;
|
|
177
|
+
`Terms` holds reviewed domain jargon, `AllowedNames` exempts names an
|
|
178
|
+
external protocol dictates.
|
|
63
179
|
Enabled: true
|
|
64
|
-
VersionAdded: "0.
|
|
65
|
-
|
|
180
|
+
VersionAdded: "0.5"
|
|
181
|
+
BannedWords:
|
|
66
182
|
- usr
|
|
67
183
|
- cfg
|
|
68
184
|
- tmp
|
|
@@ -75,6 +191,12 @@ Kata/NoAbbreviation:
|
|
|
75
191
|
- idx
|
|
76
192
|
- ctx
|
|
77
193
|
- err
|
|
194
|
+
- len
|
|
195
|
+
- msg
|
|
196
|
+
- pos
|
|
197
|
+
- ptr
|
|
198
|
+
Terms: []
|
|
199
|
+
AllowedNames: []
|
|
78
200
|
|
|
79
201
|
Kata/BuilderNoun:
|
|
80
202
|
Description: "Builders are named for what they return; verbs are for side effects."
|
|
@@ -121,13 +243,6 @@ Kata/NoHashAsObject:
|
|
|
121
243
|
- "spec/**/*"
|
|
122
244
|
- "config/**/*"
|
|
123
245
|
|
|
124
|
-
Kata/NoNilReturn:
|
|
125
|
-
Description: "Raise or return a real object; never nil."
|
|
126
|
-
Enabled: true
|
|
127
|
-
VersionAdded: "0.3"
|
|
128
|
-
Exclude:
|
|
129
|
-
- "spec/**/*"
|
|
130
|
-
|
|
131
246
|
Kata/ClockDiscipline:
|
|
132
247
|
Description: "Read time from an injected clock, not the ambient one."
|
|
133
248
|
Enabled: true
|
|
@@ -170,6 +285,20 @@ Style/EndlessMethod:
|
|
|
170
285
|
Naming/RescuedExceptionsVariableName:
|
|
171
286
|
PreferredName: error
|
|
172
287
|
|
|
288
|
+
# Memoization caches are marked with a leading underscore (@_name), so lazy
|
|
289
|
+
# state is visible at the read site; Kata/GoodVariableName knows the
|
|
290
|
+
# same @_word shape.
|
|
291
|
+
Naming/MemoizedInstanceVariableName:
|
|
292
|
+
EnforcedStyleForLeadingUnderscores: required
|
|
293
|
+
|
|
294
|
+
# Kata owns naming now; the upstream cops force strictly one word, which is
|
|
295
|
+
# what drives the underscore-smashing dodge.
|
|
296
|
+
Elegant/GoodMethodName:
|
|
297
|
+
Enabled: false
|
|
298
|
+
|
|
299
|
+
Elegant/GoodVariableName:
|
|
300
|
+
Enabled: false
|
|
301
|
+
|
|
173
302
|
Layout/LineLength:
|
|
174
303
|
Max: 120
|
|
175
304
|
|
data/data/CSPELL-LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-2025 Street Side Software <support@streetsidesoftware.nl>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
The collective work is Copyright 2000-2018 by Kevin Atkinson as well
|
|
2
|
+
as any of the copyrights mentioned below:
|
|
3
|
+
|
|
4
|
+
Copyright 2000-2018 by Kevin Atkinson
|
|
5
|
+
|
|
6
|
+
Permission to use, copy, modify, distribute and sell these word
|
|
7
|
+
lists, the associated scripts, the output created from the scripts,
|
|
8
|
+
and its documentation for any purpose is hereby granted without fee,
|
|
9
|
+
provided that the above copyright notice appears in all copies and
|
|
10
|
+
that both that copyright notice and this permission notice appear in
|
|
11
|
+
supporting documentation. Kevin Atkinson makes no representations
|
|
12
|
+
about the suitability of this array for any purpose. It is provided
|
|
13
|
+
"as is" without express or implied warranty.
|
|
14
|
+
|
|
15
|
+
Alan Beale <biljir@pobox.com> also deserves special credit as he has,
|
|
16
|
+
in addition to providing the 12Dicts package and being a major
|
|
17
|
+
contributor to the ENABLE word list, given me an incredible amount of
|
|
18
|
+
feedback and created a number of special lists (those found in the
|
|
19
|
+
Supplement) in order to help improve the overall quality of SCOWL.
|
|
20
|
+
|
|
21
|
+
The 10 level includes the 1000 most common English words (according to
|
|
22
|
+
the Moby (TM) Words II [MWords] package), a subset of the 1000 most
|
|
23
|
+
common words on the Internet (again, according to Moby Words II), and
|
|
24
|
+
frequently class 16 from Brian Kelk's "UK English Wordlist
|
|
25
|
+
with Frequency Classification".
|
|
26
|
+
|
|
27
|
+
The MWords package was explicitly placed in the public domain:
|
|
28
|
+
|
|
29
|
+
The Moby lexicon project is complete and has
|
|
30
|
+
been place into the public domain. Use, sell,
|
|
31
|
+
rework, excerpt and use in any way on any platform.
|
|
32
|
+
|
|
33
|
+
Placing this material on internal or public servers is
|
|
34
|
+
also encouraged. The compiler is not aware of any
|
|
35
|
+
export restrictions so freely distribute world-wide.
|
|
36
|
+
|
|
37
|
+
You can verify the public domain status by contacting
|
|
38
|
+
|
|
39
|
+
Grady Ward
|
|
40
|
+
3449 Martha Ct.
|
|
41
|
+
Arcata, CA 95521-4884
|
|
42
|
+
|
|
43
|
+
grady@netcom.com
|
|
44
|
+
grady@northcoast.com
|
|
45
|
+
|
|
46
|
+
The "UK English Wordlist With Frequency Classification" is also in the
|
|
47
|
+
Public Domain:
|
|
48
|
+
|
|
49
|
+
Date: Sat, 08 Jul 2000 20:27:21 +0100
|
|
50
|
+
From: Brian Kelk <Brian.Kelk@cl.cam.ac.uk>
|
|
51
|
+
|
|
52
|
+
> I was wondering what the copyright status of your "UK English
|
|
53
|
+
> Wordlist With Frequency Classification" word list as it seems to
|
|
54
|
+
> be lacking any copyright notice.
|
|
55
|
+
|
|
56
|
+
There were many many sources in total, but any text marked
|
|
57
|
+
"copyright" was avoided. Locally-written documentation was one
|
|
58
|
+
source. An earlier version of the list resided in a filespace called
|
|
59
|
+
PUBLIC on the University mainframe, because it was considered public
|
|
60
|
+
domain.
|
|
61
|
+
|
|
62
|
+
Date: Tue, 11 Jul 2000 19:31:34 +0100
|
|
63
|
+
|
|
64
|
+
> So are you saying your word list is also in the public domain?
|
|
65
|
+
|
|
66
|
+
That is the intention.
|
|
67
|
+
|
|
68
|
+
The 20 level includes frequency classes 7-15 from Brian's word list.
|
|
69
|
+
|
|
70
|
+
The 35 level includes frequency classes 2-6 and words appearing in at
|
|
71
|
+
least 11 of 12 dictionaries as indicated in the 12Dicts package. All
|
|
72
|
+
words from the 12Dicts package have had likely inflections added via
|
|
73
|
+
my inflection database.
|
|
74
|
+
|
|
75
|
+
The 12Dicts package and Supplement is in the Public Domain.
|
|
76
|
+
|
|
77
|
+
The WordNet database, which was used in the creation of the
|
|
78
|
+
Inflections database, is under the following copyright:
|
|
79
|
+
|
|
80
|
+
This software and database is being provided to you, the LICENSEE,
|
|
81
|
+
by Princeton University under the following license. By obtaining,
|
|
82
|
+
using and/or copying this software and database, you agree that you
|
|
83
|
+
have read, understood, and will comply with these terms and
|
|
84
|
+
conditions.:
|
|
85
|
+
|
|
86
|
+
Permission to use, copy, modify and distribute this software and
|
|
87
|
+
database and its documentation for any purpose and without fee or
|
|
88
|
+
royalty is hereby granted, provided that you agree to comply with
|
|
89
|
+
the following copyright notice and statements, including the
|
|
90
|
+
disclaimer, and that the same appear on ALL copies of the software,
|
|
91
|
+
database and documentation, including modifications that you make
|
|
92
|
+
for internal use or for distribution.
|
|
93
|
+
|
|
94
|
+
WordNet 1.6 Copyright 1997 by Princeton University. All rights
|
|
95
|
+
reserved.
|
|
96
|
+
|
|
97
|
+
THIS SOFTWARE AND DATABASE IS PROVIDED "AS IS" AND PRINCETON
|
|
98
|
+
UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
|
99
|
+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PRINCETON
|
|
100
|
+
UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES OF MERCHANT-
|
|
101
|
+
ABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE
|
|
102
|
+
LICENSED SOFTWARE, DATABASE OR DOCUMENTATION WILL NOT INFRINGE ANY
|
|
103
|
+
THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
|
|
104
|
+
|
|
105
|
+
The name of Princeton University or Princeton may not be used in
|
|
106
|
+
advertising or publicity pertaining to distribution of the software
|
|
107
|
+
and/or database. Title to copyright in this software, database and
|
|
108
|
+
any associated documentation shall at all times remain with
|
|
109
|
+
Princeton University and LICENSEE agrees to preserve same.
|
|
110
|
+
|
|
111
|
+
The 40 level includes words from Alan's 3esl list found in version 4.0
|
|
112
|
+
of his 12dicts package. Like his other stuff the 3esl list is also in the
|
|
113
|
+
public domain.
|
|
114
|
+
|
|
115
|
+
The 50 level includes Brian's frequency class 1, words appearing
|
|
116
|
+
in at least 5 of 12 of the dictionaries as indicated in the 12Dicts
|
|
117
|
+
package, and uppercase words in at least 4 of the previous 12
|
|
118
|
+
dictionaries. A decent number of proper names is also included: The
|
|
119
|
+
top 1000 male, female, and Last names from the 1990 Census report; a
|
|
120
|
+
list of names sent to me by Alan Beale; and a few names that I added
|
|
121
|
+
myself. Finally a small list of abbreviations not commonly found in
|
|
122
|
+
other word lists is included.
|
|
123
|
+
|
|
124
|
+
The name files form the Census report is a government document which I
|
|
125
|
+
don't think can be copyrighted.
|
|
126
|
+
|
|
127
|
+
The file special-jargon.50 uses common.lst and word.lst from the
|
|
128
|
+
"Unofficial Jargon File Word Lists" which is derived from "The Jargon
|
|
129
|
+
File". All of which is in the Public Domain. This file also contain
|
|
130
|
+
a few extra UNIX terms which are found in the file "unix-terms" in the
|
|
131
|
+
special/ directory.
|
|
132
|
+
|
|
133
|
+
The 55 level includes words from Alan's 2of4brif list found in version
|
|
134
|
+
4.0 of his 12dicts package. Like his other stuff the 2of4brif is also
|
|
135
|
+
in the public domain.
|
|
136
|
+
|
|
137
|
+
The 60 level includes all words appearing in at least 2 of the 12
|
|
138
|
+
dictionaries as indicated by the 12Dicts package.
|
|
139
|
+
|
|
140
|
+
The 70 level includes Brian's frequency class 0 and the 74,550 common
|
|
141
|
+
dictionary words from the MWords package. The common dictionary words,
|
|
142
|
+
like those from the 12Dicts package, have had all likely inflections
|
|
143
|
+
added. The 70 level also included the 5desk list from version 4.0 of
|
|
144
|
+
the 12Dics package which is in the public domain.
|
|
145
|
+
|
|
146
|
+
The 80 level includes the ENABLE word list, all the lists in the
|
|
147
|
+
ENABLE supplement package (except for ABLE), the "UK Advanced Cryptics
|
|
148
|
+
Dictionary" (UKACD), the list of signature words from the YAWL package,
|
|
149
|
+
and the 10,196 places list from the MWords package.
|
|
150
|
+
|
|
151
|
+
The ENABLE package, mainted by M\Cooper <thegrendel@theriver.com>,
|
|
152
|
+
is in the Public Domain:
|
|
153
|
+
|
|
154
|
+
The ENABLE master word list, WORD.LST, is herewith formally released
|
|
155
|
+
into the Public Domain. Anyone is free to use it or distribute it in
|
|
156
|
+
any manner they see fit. No fee or registration is required for its
|
|
157
|
+
use nor are "contributions" solicited (if you feel you absolutely
|
|
158
|
+
must contribute something for your own peace of mind, the authors of
|
|
159
|
+
the ENABLE list ask that you make a donation on their behalf to your
|
|
160
|
+
favorite charity). This word list is our gift to the Scrabble
|
|
161
|
+
community, as an alternate to "official" word lists. Game designers
|
|
162
|
+
may feel free to incorporate the WORD.LST into their games. Please
|
|
163
|
+
mention the source and credit us as originators of the list. Note
|
|
164
|
+
that if you, as a game designer, use the WORD.LST in your product,
|
|
165
|
+
you may still copyright and protect your product, but you may *not*
|
|
166
|
+
legally copyright or in any way restrict redistribution of the
|
|
167
|
+
WORD.LST portion of your product. This *may* under law restrict your
|
|
168
|
+
rights to restrict your users' rights, but that is only fair.
|
|
169
|
+
|
|
170
|
+
UKACD, by J Ross Beresford <ross@bryson.demon.co.uk>, is under the
|
|
171
|
+
following copyright:
|
|
172
|
+
|
|
173
|
+
Copyright (c) J Ross Beresford 1993-1999. All Rights Reserved.
|
|
174
|
+
|
|
175
|
+
The following restriction is placed on the use of this publication:
|
|
176
|
+
if The UK Advanced Cryptics Dictionary is used in a software package
|
|
177
|
+
or redistributed in any form, the copyright notice must be
|
|
178
|
+
prominently displayed and the text of this document must be included
|
|
179
|
+
verbatim.
|
|
180
|
+
|
|
181
|
+
There are no other restrictions: I would like to see the list
|
|
182
|
+
distributed as widely as possible.
|
|
183
|
+
|
|
184
|
+
The 95 level includes the 354,984 single words, 256,772 compound
|
|
185
|
+
words, 4,946 female names and the 3,897 male names, and 21,986 names
|
|
186
|
+
from the MWords package, ABLE.LST from the ENABLE Supplement, and some
|
|
187
|
+
additional words found in my part-of-speech database that were not
|
|
188
|
+
found anywhere else.
|
|
189
|
+
|
|
190
|
+
Accent information was taken from UKACD.
|
|
191
|
+
|
|
192
|
+
The VarCon package was used to create the American, British, Canadian,
|
|
193
|
+
and Australian word list. It is under the following copyright:
|
|
194
|
+
|
|
195
|
+
Copyright 2000-2016 by Kevin Atkinson
|
|
196
|
+
|
|
197
|
+
Permission to use, copy, modify, distribute and sell this array, the
|
|
198
|
+
associated software, and its documentation for any purpose is hereby
|
|
199
|
+
granted without fee, provided that the above copyright notice appears
|
|
200
|
+
in all copies and that both that copyright notice and this permission
|
|
201
|
+
notice appear in supporting documentation. Kevin Atkinson makes no
|
|
202
|
+
representations about the suitability of this array for any
|
|
203
|
+
purpose. It is provided "as is" without express or implied warranty.
|
|
204
|
+
|
|
205
|
+
Copyright 2016 by Benjamin Titze
|
|
206
|
+
|
|
207
|
+
Permission to use, copy, modify, distribute and sell this array, the
|
|
208
|
+
associated software, and its documentation for any purpose is hereby
|
|
209
|
+
granted without fee, provided that the above copyright notice appears
|
|
210
|
+
in all copies and that both that copyright notice and this permission
|
|
211
|
+
notice appear in supporting documentation. Benjamin Titze makes no
|
|
212
|
+
representations about the suitability of this array for any
|
|
213
|
+
purpose. It is provided "as is" without express or implied warranty.
|
|
214
|
+
|
|
215
|
+
Since the original words lists come from the Ispell distribution:
|
|
216
|
+
|
|
217
|
+
Copyright 1993, Geoff Kuenning, Granada Hills, CA
|
|
218
|
+
All rights reserved.
|
|
219
|
+
|
|
220
|
+
Redistribution and use in source and binary forms, with or without
|
|
221
|
+
modification, are permitted provided that the following conditions
|
|
222
|
+
are met:
|
|
223
|
+
|
|
224
|
+
1. Redistributions of source code must retain the above copyright
|
|
225
|
+
notice, this list of conditions and the following disclaimer.
|
|
226
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
227
|
+
notice, this list of conditions and the following disclaimer in the
|
|
228
|
+
documentation and/or other materials provided with the distribution.
|
|
229
|
+
3. All modifications to the source code must be clearly marked as
|
|
230
|
+
such. Binary redistributions based on modified source code
|
|
231
|
+
must be clearly marked as modified versions in the documentation
|
|
232
|
+
and/or other materials provided with the distribution.
|
|
233
|
+
(clause 4 removed with permission from Geoff Kuenning)
|
|
234
|
+
5. The name of Geoff Kuenning may not be used to endorse or promote
|
|
235
|
+
products derived from this software without specific prior
|
|
236
|
+
written permission.
|
|
237
|
+
|
|
238
|
+
THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS IS'' AND
|
|
239
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
240
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
241
|
+
ARE DISCLAIMED. IN NO EVENT SHALL GEOFF KUENNING OR CONTRIBUTORS BE LIABLE
|
|
242
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
243
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
244
|
+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
245
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
246
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
247
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
248
|
+
SUCH DAMAGE.
|
|
Binary file
|
data/data/supplement.txt
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
accessor
|
|
2
|
+
api
|
|
3
|
+
app
|
|
4
|
+
async
|
|
5
|
+
autocorrect
|
|
6
|
+
backend
|
|
7
|
+
began
|
|
8
|
+
blew
|
|
9
|
+
boilerplate
|
|
10
|
+
boolean
|
|
11
|
+
callback
|
|
12
|
+
changelog
|
|
13
|
+
classify
|
|
14
|
+
cli
|
|
15
|
+
config
|
|
16
|
+
cron
|
|
17
|
+
css
|
|
18
|
+
csv
|
|
19
|
+
cwd
|
|
20
|
+
database
|
|
21
|
+
dataset
|
|
22
|
+
debugger
|
|
23
|
+
dequeue
|
|
24
|
+
deserialize
|
|
25
|
+
diff
|
|
26
|
+
download
|
|
27
|
+
email
|
|
28
|
+
endpoint
|
|
29
|
+
enqueue
|
|
30
|
+
formatter
|
|
31
|
+
frontend
|
|
32
|
+
frontmatter
|
|
33
|
+
gemspec
|
|
34
|
+
glyph
|
|
35
|
+
gui
|
|
36
|
+
heard
|
|
37
|
+
held
|
|
38
|
+
html
|
|
39
|
+
http
|
|
40
|
+
https
|
|
41
|
+
initializer
|
|
42
|
+
inline
|
|
43
|
+
internet
|
|
44
|
+
iterator
|
|
45
|
+
json
|
|
46
|
+
jwt
|
|
47
|
+
keyword
|
|
48
|
+
logout
|
|
49
|
+
max
|
|
50
|
+
memoization
|
|
51
|
+
memoize
|
|
52
|
+
metadata
|
|
53
|
+
middleware
|
|
54
|
+
min
|
|
55
|
+
mixin
|
|
56
|
+
multiline
|
|
57
|
+
namespace
|
|
58
|
+
oauth
|
|
59
|
+
offline
|
|
60
|
+
online
|
|
61
|
+
paid
|
|
62
|
+
payload
|
|
63
|
+
plugin
|
|
64
|
+
proc
|
|
65
|
+
queueing
|
|
66
|
+
readme
|
|
67
|
+
refactor
|
|
68
|
+
runtime
|
|
69
|
+
scheduler
|
|
70
|
+
screenshot
|
|
71
|
+
serializer
|
|
72
|
+
sigil
|
|
73
|
+
signup
|
|
74
|
+
sql
|
|
75
|
+
timeout
|
|
76
|
+
timestamp
|
|
77
|
+
tokenizer
|
|
78
|
+
tui
|
|
79
|
+
tuple
|
|
80
|
+
unshift
|
|
81
|
+
uri
|
|
82
|
+
url
|
|
83
|
+
uuid
|
|
84
|
+
validator
|
|
85
|
+
webhook
|
|
86
|
+
webpage
|
|
87
|
+
website
|
|
88
|
+
whitespace
|
|
89
|
+
workflow
|
|
90
|
+
workspace
|
|
91
|
+
xml
|
|
92
|
+
yaml
|
data/data/words.txt.gz
ADDED
|
Binary file
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class RuboCop::Cop::Kata::GoodMethodName < RuboCop::Cop::Base
|
|
4
|
+
MSG = "`%s` needs two words: either a concept is missing, or the method belongs on the object " \
|
|
5
|
+
"the second word names. Say it in one word, move it, give the role a `Prefixes`/`Suffixes` " \
|
|
6
|
+
"word — or, if `%s` is one domain concept here, add it to `Terms`."
|
|
7
|
+
|
|
8
|
+
def on_def(node) = check(node, node.method_name)
|
|
9
|
+
|
|
10
|
+
def on_defs(node) = check(node, node.method_name)
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def check(node, name)
|
|
15
|
+
return unless name.match?(/\A[a-z_]/)
|
|
16
|
+
stem = name.to_s.sub(/[?!=]\z/, "")
|
|
17
|
+
return if allowed?(name.to_s) || allowed?(stem)
|
|
18
|
+
return if good?(stem)
|
|
19
|
+
add_offense(node.loc.name, message: format(MSG, name, name))
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def good?(stem)
|
|
23
|
+
words = stem.split("_")
|
|
24
|
+
return false unless words.all? { pattern.match?(it) }
|
|
25
|
+
core = core(words)
|
|
26
|
+
return words.size == 1 if core.size == words.size
|
|
27
|
+
core.size.between?(1, max)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def core(words)
|
|
31
|
+
rest = prefix?(words.first) && words.size > 1 ? words.drop(1) : words
|
|
32
|
+
suffix?(rest.last) && rest.size > 1 ? rest[0..-2] : rest
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def prefix?(word) = list("Prefixes").include?(word)
|
|
36
|
+
|
|
37
|
+
def suffix?(word) = list("Suffixes").include?(word)
|
|
38
|
+
|
|
39
|
+
def allowed?(name) = list("AllowedNames").include?(name) || list("Terms").include?(name)
|
|
40
|
+
|
|
41
|
+
def list(key) = Array(cop_config[key]).map(&:to_s)
|
|
42
|
+
|
|
43
|
+
def max = Integer(cop_config.fetch("MaxWords", 2))
|
|
44
|
+
|
|
45
|
+
def pattern = Regexp.new(cop_config.fetch("Pattern", "^[a-z][a-z0-9]{0,15}$"))
|
|
46
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class RuboCop::Cop::Kata::GoodVariableName < RuboCop::Cop::Base
|
|
4
|
+
MSG = "`%s` needs two words: the second word names an object you have not introduced yet. " \
|
|
5
|
+
"Name that object, use a `Prefixes`/`Suffixes` role word — or, if `%s` is one domain concept " \
|
|
6
|
+
"here, add it to `Terms`."
|
|
7
|
+
|
|
8
|
+
SIGIL = /\A(@@|@|\$)/
|
|
9
|
+
|
|
10
|
+
def on_lvasgn(node) = check(node, node.name)
|
|
11
|
+
|
|
12
|
+
def on_ivasgn(node) = check(node, node.name)
|
|
13
|
+
|
|
14
|
+
def on_cvasgn(node) = check(node, node.name)
|
|
15
|
+
|
|
16
|
+
def on_gvasgn(node) = check(node, node.name)
|
|
17
|
+
|
|
18
|
+
def on_arg(node) = check(node, node.name)
|
|
19
|
+
|
|
20
|
+
def on_optarg(node) = check(node, node.name)
|
|
21
|
+
|
|
22
|
+
def on_kwarg(node) = check(node, node.name)
|
|
23
|
+
|
|
24
|
+
def on_kwoptarg(node) = check(node, node.name)
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def check(node, name)
|
|
29
|
+
stem = name.to_s.sub(SIGIL, "").delete_prefix("_")
|
|
30
|
+
return if allowed?(name.to_s) || allowed?(stem) || stem.empty?
|
|
31
|
+
return if good?(stem)
|
|
32
|
+
add_offense(node.loc.name, message: format(MSG, name, name))
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def good?(stem)
|
|
36
|
+
words = stem.split("_")
|
|
37
|
+
return false unless words.all? { pattern.match?(it) }
|
|
38
|
+
core = core(words)
|
|
39
|
+
return words.size == 1 if core.size == words.size
|
|
40
|
+
core.size.between?(1, max)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def core(words)
|
|
44
|
+
rest = prefix?(words.first) && words.size > 1 ? words.drop(1) : words
|
|
45
|
+
suffix?(rest.last) && rest.size > 1 ? rest[0..-2] : rest
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def prefix?(word) = list("Prefixes").include?(word)
|
|
49
|
+
|
|
50
|
+
def suffix?(word) = list("Suffixes").include?(word)
|
|
51
|
+
|
|
52
|
+
def allowed?(name) = list("AllowedNames").include?(name) || list("Terms").include?(name)
|
|
53
|
+
|
|
54
|
+
def list(key) = Array(cop_config[key]).map(&:to_s)
|
|
55
|
+
|
|
56
|
+
def max = Integer(cop_config.fetch("MaxWords", 2))
|
|
57
|
+
|
|
58
|
+
def pattern = Regexp.new(cop_config.fetch("Pattern", "^[a-z][a-z0-9]{0,15}$"))
|
|
59
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "zlib"
|
|
4
|
+
|
|
5
|
+
class RuboCop::Cop::Kata::RealWords < RuboCop::Cop::Base
|
|
6
|
+
MSG = "%s is not in the dictionary — restore the underscore between smashed words, spell the " \
|
|
7
|
+
"abbreviation out, or add it to `Terms` if it is one domain term here."
|
|
8
|
+
ABBREVIATION_MSG = "%s is an abbreviation; spell the word out."
|
|
9
|
+
WORDS = File.expand_path("../../../../data/words.txt.gz", __dir__)
|
|
10
|
+
SOFTWARE = File.expand_path("../../../../data/software.txt.gz", __dir__)
|
|
11
|
+
EXTRA = File.expand_path("../../../../data/supplement.txt", __dir__)
|
|
12
|
+
DICTIONARY = Set.new(
|
|
13
|
+
[WORDS, SOFTWARE].flat_map { Zlib.gunzip(File.binread(it)).split("\n") } +
|
|
14
|
+
File.readlines(EXTRA, chomp: true)
|
|
15
|
+
).freeze
|
|
16
|
+
SIGIL = /\A(@@|@|\$)/
|
|
17
|
+
DERIVATIONS = [
|
|
18
|
+
[/s\z/, ""], [/es\z/, ""], [/ies\z/, "y"],
|
|
19
|
+
[/able\z/, ""], [/able\z/, "e"], [/([b-df-hj-np-tv-z])\1able\z/, '\1'],
|
|
20
|
+
[/er\z/, ""], [/[eo]r\z/, "e"], [/ier\z/, "y"],
|
|
21
|
+
[/([b-df-hj-np-tv-z])\1er\z/, '\1'], [/or\z/, ""], [/less\z/, ""]
|
|
22
|
+
].freeze
|
|
23
|
+
|
|
24
|
+
def on_def(node) = check(node, node.method_name)
|
|
25
|
+
|
|
26
|
+
def on_defs(node) = check(node, node.method_name)
|
|
27
|
+
|
|
28
|
+
def on_lvasgn(node) = check(node, node.name)
|
|
29
|
+
|
|
30
|
+
def on_ivasgn(node) = check(node, node.name)
|
|
31
|
+
|
|
32
|
+
def on_cvasgn(node) = check(node, node.name)
|
|
33
|
+
|
|
34
|
+
def on_gvasgn(node) = check(node, node.name)
|
|
35
|
+
|
|
36
|
+
def on_arg(node) = check(node, node.name)
|
|
37
|
+
|
|
38
|
+
def on_optarg(node) = check(node, node.name)
|
|
39
|
+
|
|
40
|
+
def on_kwarg(node) = check(node, node.name)
|
|
41
|
+
|
|
42
|
+
def on_kwoptarg(node) = check(node, node.name)
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def check(node, name)
|
|
47
|
+
stem = name.to_s.sub(SIGIL, "").delete_prefix("_").sub(/[?!=]\z/, "")
|
|
48
|
+
segment = flaw(name.to_s, stem)
|
|
49
|
+
return unless segment
|
|
50
|
+
add_offense(node.loc.name, message: message(name, stem, segment))
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def flaw(name, stem)
|
|
54
|
+
return if allowed?(name) || allowed?(stem) || !stem.match?(/\A[a-z]/)
|
|
55
|
+
stem.split("_").find { !word?(it) }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def message(name, stem, segment)
|
|
59
|
+
format(banned?(segment) ? ABBREVIATION_MSG : MSG, label(name, stem, segment))
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def label(name, stem, segment) = stem == segment ? "`#{name}`" : "`#{segment}` (in `#{name}`)"
|
|
63
|
+
|
|
64
|
+
def word?(segment) = segment.length < 2 || term?(segment) || (known?(segment) && !banned?(segment))
|
|
65
|
+
|
|
66
|
+
def known?(segment) = forms(segment).any? { DICTIONARY.include?(it) }
|
|
67
|
+
|
|
68
|
+
def forms(segment)
|
|
69
|
+
base = segment.sub(/\d+\z/, "")
|
|
70
|
+
[base, base.delete_prefix("un"), base.delete_prefix("re"), base.delete_prefix("non"), base.delete_prefix("sub")]
|
|
71
|
+
.flat_map { [it, *derivations(it)] }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def derivations(base) = DERIVATIONS.map { |pattern, stem| base.sub(pattern, stem) }
|
|
75
|
+
|
|
76
|
+
def term?(segment) = list("Terms").include?(segment)
|
|
77
|
+
|
|
78
|
+
def banned?(segment) = list("BannedWords").include?(segment)
|
|
79
|
+
|
|
80
|
+
def allowed?(name) = list("AllowedNames").include?(name)
|
|
81
|
+
|
|
82
|
+
def list(key) = Array(cop_config[key]).map(&:to_s)
|
|
83
|
+
end
|
data/lib/rubocop/kata/version.rb
CHANGED
data/lib/rubocop-kata.rb
CHANGED
|
@@ -17,14 +17,15 @@ require_relative "rubocop/cop/kata/builder_noun"
|
|
|
17
17
|
require_relative "rubocop/cop/kata/clock_discipline"
|
|
18
18
|
require_relative "rubocop/cop/kata/constructor_discipline"
|
|
19
19
|
require_relative "rubocop/cop/kata/env_discipline"
|
|
20
|
+
require_relative "rubocop/cop/kata/good_method_name"
|
|
21
|
+
require_relative "rubocop/cop/kata/good_variable_name"
|
|
20
22
|
require_relative "rubocop/cop/kata/io_discipline"
|
|
21
|
-
require_relative "rubocop/cop/kata/no_abbreviation"
|
|
22
23
|
require_relative "rubocop/cop/kata/no_boolean_flag"
|
|
23
24
|
require_relative "rubocop/cop/kata/no_class_method_logic"
|
|
24
25
|
require_relative "rubocop/cop/kata/no_comments"
|
|
25
26
|
require_relative "rubocop/cop/kata/no_hash_as_object"
|
|
26
|
-
require_relative "rubocop/cop/kata/no_nil_return"
|
|
27
27
|
require_relative "rubocop/cop/kata/no_util_name"
|
|
28
28
|
require_relative "rubocop/cop/kata/prose_placement"
|
|
29
|
+
require_relative "rubocop/cop/kata/real_words"
|
|
29
30
|
require_relative "rubocop/kata/plugin"
|
|
30
31
|
require_relative "rubocop/kata/version"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop-kata
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Giacomo GK
|
|
@@ -107,9 +107,12 @@ dependencies:
|
|
|
107
107
|
- - "~>"
|
|
108
108
|
- !ruby/object:Gem::Version
|
|
109
109
|
version: '0.7'
|
|
110
|
-
description:
|
|
110
|
+
description: Bundles a curated RuboCop stack (rspec, performance, elegant, packaging,
|
|
111
111
|
thread_safety) behind one dependency, layers opinionated style defaults on top,
|
|
112
|
-
and adds
|
|
112
|
+
and adds fifteen cops of its own — naming (GoodMethodName, GoodVariableName, dictionary-backed
|
|
113
|
+
RealWords, AgentNoun, BuilderNoun, NoUtilName), discipline (IoDiscipline, ClockDiscipline,
|
|
114
|
+
EnvDiscipline, ConstructorDiscipline, NoClassMethodLogic), and shape (NoComments,
|
|
115
|
+
NoBooleanFlag, NoHashAsObject, ProsePlacement).
|
|
113
116
|
email:
|
|
114
117
|
- giaco@hey.com
|
|
115
118
|
executables: []
|
|
@@ -120,21 +123,27 @@ files:
|
|
|
120
123
|
- LICENSE.txt
|
|
121
124
|
- README.md
|
|
122
125
|
- config/default.yml
|
|
126
|
+
- data/CSPELL-LICENSE
|
|
127
|
+
- data/SCOWL-COPYRIGHT
|
|
128
|
+
- data/software.txt.gz
|
|
129
|
+
- data/supplement.txt
|
|
130
|
+
- data/words.txt.gz
|
|
123
131
|
- lib/rubocop-kata.rb
|
|
124
132
|
- lib/rubocop/cop/kata/agent_noun.rb
|
|
125
133
|
- lib/rubocop/cop/kata/builder_noun.rb
|
|
126
134
|
- lib/rubocop/cop/kata/clock_discipline.rb
|
|
127
135
|
- lib/rubocop/cop/kata/constructor_discipline.rb
|
|
128
136
|
- lib/rubocop/cop/kata/env_discipline.rb
|
|
137
|
+
- lib/rubocop/cop/kata/good_method_name.rb
|
|
138
|
+
- lib/rubocop/cop/kata/good_variable_name.rb
|
|
129
139
|
- lib/rubocop/cop/kata/io_discipline.rb
|
|
130
|
-
- lib/rubocop/cop/kata/no_abbreviation.rb
|
|
131
140
|
- lib/rubocop/cop/kata/no_boolean_flag.rb
|
|
132
141
|
- lib/rubocop/cop/kata/no_class_method_logic.rb
|
|
133
142
|
- lib/rubocop/cop/kata/no_comments.rb
|
|
134
143
|
- lib/rubocop/cop/kata/no_hash_as_object.rb
|
|
135
|
-
- lib/rubocop/cop/kata/no_nil_return.rb
|
|
136
144
|
- lib/rubocop/cop/kata/no_util_name.rb
|
|
137
145
|
- lib/rubocop/cop/kata/prose_placement.rb
|
|
146
|
+
- lib/rubocop/cop/kata/real_words.rb
|
|
138
147
|
- lib/rubocop/kata/plugin.rb
|
|
139
148
|
- lib/rubocop/kata/version.rb
|
|
140
149
|
homepage: https://github.com/giacope/rubocop-kata
|
|
@@ -163,5 +172,5 @@ requirements: []
|
|
|
163
172
|
rubygems_version: 4.0.17
|
|
164
173
|
specification_version: 4
|
|
165
174
|
summary: 'Practiced forms for Ruby: a RuboCop plugin with opinionated defaults and
|
|
166
|
-
|
|
175
|
+
fifteen house cops'
|
|
167
176
|
test_files: []
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class RuboCop::Cop::Kata::NoAbbreviation < RuboCop::Cop::Base
|
|
4
|
-
MSG = "`%s` is an abbreviation; spell the word out."
|
|
5
|
-
|
|
6
|
-
def on_lvasgn(node) = check(node)
|
|
7
|
-
|
|
8
|
-
def on_arg(node) = check(node)
|
|
9
|
-
|
|
10
|
-
def on_optarg(node) = check(node)
|
|
11
|
-
|
|
12
|
-
def on_kwarg(node) = check(node)
|
|
13
|
-
|
|
14
|
-
def on_kwoptarg(node) = check(node)
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
def check(node)
|
|
19
|
-
name = node.name.to_s
|
|
20
|
-
return unless banned?(name)
|
|
21
|
-
add_offense(node.loc.name, message: format(MSG, name))
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def banned?(name) = Array(cop_config["BannedNames"]).map(&:to_s).include?(name.sub(/\d+\z/, ""))
|
|
25
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class RuboCop::Cop::Kata::NoNilReturn < RuboCop::Cop::Base
|
|
4
|
-
MSG = "Returning nil hands the caller a bomb; raise or return a real object."
|
|
5
|
-
|
|
6
|
-
def on_return(node)
|
|
7
|
-
add_offense(node, message: MSG) if node.children.first&.nil_type?
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def on_def(node)
|
|
11
|
-
last = tail(node.body)
|
|
12
|
-
add_offense(last, message: MSG) if last&.nil_type?
|
|
13
|
-
end
|
|
14
|
-
alias on_defs on_def
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
def tail(body) = body&.begin_type? ? body.children.last : body
|
|
19
|
-
end
|