rubocop-codetakt 0.8.3 → 0.84.0.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 +5 -5
- data/.gitignore +10 -0
- data/.rspec +1 -0
- data/.rubocop.yml +4 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +208 -43
- data/Gemfile +10 -0
- data/{LICENSE → LICENSE.txt} +3 -1
- data/README.md +36 -19
- data/Rakefile +4 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/performance.yml +6 -0
- data/config/rails.yml +53 -3
- data/config/rspec.yml +62 -11
- data/config/rubocop.yml +364 -15
- data/exe/rubocop-codetakt +10 -0
- data/lib/rubocop/codetakt.rb +4 -0
- data/lib/rubocop/codetakt/cli.rb +47 -0
- data/lib/rubocop/codetakt/version.rb +5 -0
- data/lib/rubocop_codetakt.rb +2 -0
- data/rubocop-codetakt.gemspec +25 -0
- data/templates/.rubocop.yml +12 -0
- metadata +35 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c3e05cc34a03191e9f9953b257f39c35153ca6381136a483d60600c85bfc361e
|
4
|
+
data.tar.gz: 9773cc51adb3e99928a210852738e472bdae56aee88eb9123eede5c587a5f8e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 620f002d2100d5f3b04a7143be1adb6a36db98c083e73fa460225cd6dfdd67765562e805135d7f74dc555f181d3415fa85bcb4d8e398fd4b640451a004f17d32
|
7
|
+
data.tar.gz: 12fc69e7d802f3bc46a574bb6aabcbe749d6778561264a28f90e62ca4dec1ea7b7bddefc64c817a88e37520c23c79aae9b2f8435234e1363d5db87ca33687ab4
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,73 +1,238 @@
|
|
1
|
-
# rubocop-codetakt
|
1
|
+
# rubocop-codetakt:
|
2
2
|
|
3
|
-
## v0.
|
3
|
+
## v0.84.0.0 (2020-06-04)
|
4
4
|
|
5
|
-
|
5
|
+
* Update `rubocop` v0.84.0, `rubocop-rspec` v1.39.0, `rubocop-rails` v2.5.0 and `rubocop-performance` v1.6.0
|
6
|
+
* Clarify `Layout/HashAlignment` cop option
|
6
7
|
|
7
|
-
|
8
|
-
* Backport "Disable RSpec/EmptyLineAfterFinalLet cop"
|
9
|
-
* From: https://github.com/onk/onkcop/pull/30
|
8
|
+
## v0.83.0.1 (2020-06-03)
|
10
9
|
|
11
|
-
|
10
|
+
* Disable `RSpec/MultipleExpectations:` cop
|
12
11
|
|
13
|
-
|
12
|
+
## v0.83.0.0 (2020-05-18)
|
14
13
|
|
15
|
-
*
|
14
|
+
* Update `rubocop` v0.83.0
|
16
15
|
|
17
|
-
## v0.
|
16
|
+
## v0.82.0.1 (2020-06-01)
|
18
17
|
|
19
|
-
|
18
|
+
* Make the code in this repository to no offenses
|
19
|
+
* Accept the default setting of new cops
|
20
20
|
|
21
|
-
|
22
|
-
* Disable the RSpec/DescribedClass cop for the request specs.
|
21
|
+
## v0.82.0.0 (2020-04-20)
|
23
22
|
|
24
|
-
|
23
|
+
* Fork from onk/onkcop to codetakt/rubocop-codetakt
|
24
|
+
* Update `rubocop` v0.82.0, `rubocop-rspec` v1.38.0, `rubocop-rails` v2.5.0 and `rubocop-performance` v1.5.0
|
25
|
+
* Follow upstream renamings
|
26
|
+
* Separate the file of performance settings
|
27
|
+
* Clarify requiring the `rubocop-rails` gem in the Rails settings file
|
28
|
+
* Refine dependency settings
|
29
|
+
* Remove `Layout/DotPosition` cop
|
30
|
+
* Remove `Layout/IndentationConsistency` cop
|
31
|
+
* Remove `Style/BracesAroundHashParameters` cop
|
32
|
+
* Remove `Style/MethodCalledOnDoEndBlock`
|
33
|
+
* Remove `Style/StringLiteralsInInterpolation` cop
|
34
|
+
* Remove `Style/StringLiterals` cop
|
35
|
+
* Change `Metrics/AbcSize` cop option
|
36
|
+
* Change `Metrics/PerceivedComplexity` cop option
|
37
|
+
* Change `Layout/MultilineMethodCallIndentation` cop option
|
38
|
+
* Change `Style/TrailingCommaInArguments` cop option
|
39
|
+
* Change `Style/TrailingCommaInArrayLiteral` cop option
|
40
|
+
* Change `Style/TrailingCommaInHashLiteral` cop option
|
41
|
+
* Change `Rails/ApplicationRecord` cop option
|
25
42
|
|
26
|
-
|
43
|
+
## v0.53.0.3 (2019-01-20)
|
27
44
|
|
28
|
-
*
|
45
|
+
* Ignored `Style/YodaCondition` (@sue445)
|
29
46
|
|
30
|
-
## v0.
|
47
|
+
## v0.53.0.2 (2018-10-11)
|
31
48
|
|
32
|
-
|
49
|
+
* Remove `Style/EmptyLineAfterGuardClause` cop's configuration
|
33
50
|
|
34
|
-
|
35
|
-
* Update the Changelog.
|
51
|
+
## v0.53.0.1 (2018-08-17)
|
36
52
|
|
37
|
-
|
53
|
+
* Relax rubocop dependency for `rubocop-rspec` (@sue445)
|
38
54
|
|
39
|
-
|
55
|
+
## v0.53.0.0 (2018-03-09)
|
40
56
|
|
41
|
-
*
|
42
|
-
|
57
|
+
* Update `rubocop` v0.53.0 and `rubocop-rspec` v1.24.0
|
58
|
+
* `Style/TrailingCommaInLiteral` cop is separated to `Style/TrailingCommaInArrayLiteral` and `Style/TrailingCommaInHashLiteral`
|
59
|
+
* `Performance/HashEachMethods` cop is removed
|
60
|
+
* Disable new `Naming/UncommunicativeMethodParamName` cop
|
61
|
+
* Enable `Style/FormatStringToken` cop
|
62
|
+
* Enable new `Style/EmptyLineAfterGuardClause` cop
|
63
|
+
* Enable `Lint/Void` cop's mutating methods check
|
64
|
+
* Remove `TargetRailsVersion` from template
|
65
|
+
* Change `Layout/SpaceInsideBlockBraces` cop option
|
43
66
|
|
44
|
-
## v0.
|
67
|
+
## v0.52.1.1 (2018-01-11)
|
45
68
|
|
46
|
-
|
69
|
+
* Update `rubocop-rspec` to v1.22.0
|
70
|
+
* Change new `RSpec/ExpectChange` cop to `block` style
|
47
71
|
|
48
|
-
* Follow the RuboCop updates to the version 0.48.
|
49
72
|
|
50
|
-
|
73
|
+
## v0.52.1.0 (2017-12-28)
|
51
74
|
|
52
|
-
|
75
|
+
* Update `rubocop` to v0.52.1
|
76
|
+
* Use `Layout/SpaceBeforeBlockBraces` cop's default configuration
|
77
|
+
* Update `TargetRubyVersion` of auto-generate configuration to 2.5
|
78
|
+
* `Lint/AmbiguousBlockAssociation`, `Style/BlockDelimiters` and
|
79
|
+
`Style/Semicolon` cops are now exclude only `spec/**/*_spec.rb` instead of `spec/**/*`
|
53
80
|
|
54
|
-
[full changelog](https://github.com/codetakt/rubocop-codetakt/compare/v0.2.0...v0.2.1)
|
55
81
|
|
56
|
-
|
82
|
+
## v0.52.0.0 (2017-12-20)
|
57
83
|
|
58
|
-
|
84
|
+
* Update `rubocop` v0.52.0 and `rubocop-rspec` v1.21.0
|
85
|
+
* Remove `DisplayCopNames` configuration
|
86
|
+
* Enable new `Style/ClassStructure` cop
|
87
|
+
* Disable `Style/FormatStringToken` cop
|
88
|
+
* Change `Layout/SpaceBeforeBlockBraces` cop's empty braces style to `space`
|
89
|
+
* Change `Style/RescueStandardError` cop to implicit style
|
90
|
+
* Change `RSpec/MultipleExpectations` cop to `AggregateFailuresByDefault` style
|
91
|
+
* Exclude `bin/setup`, `bin/update` from `Style/MixinUsage` cop
|
59
92
|
|
60
|
-
[full changelog](https://github.com/codetakt/rubocop-codetakt/compare/v0.1.0...v0.2.0)
|
61
93
|
|
62
|
-
|
63
|
-
* `DisplayCopNames`
|
94
|
+
## v0.51.0.1 (2017-11-11)
|
64
95
|
|
65
|
-
*
|
66
|
-
|
96
|
+
* Update `rubocop-rspec` to v1.20.0
|
97
|
+
* Disable new `RSpec/ContextWording` cop
|
98
|
+
* Disable `Rails/Delegate`, `Rails/Exit`, `Rails/FilePath`,
|
99
|
+
`Rails/PluralizationGrammar` and `Rails/Present` cops
|
100
|
+
* Enable `Rails/NotNullColumn` cop
|
67
101
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
102
|
+
|
103
|
+
## v0.51.0.0 (2017-10-20)
|
104
|
+
|
105
|
+
* Update `rubocop` v0.51.0 and `rubocop-rspec` v1.19.0
|
106
|
+
* Enable `Lint/ReturnInVoidContext` cop
|
107
|
+
* Add `staging` env to `Rails/UnknownEnv` cop
|
108
|
+
* Add comments to `Style/SafeNavigation` and `Lint/UnusedMethodArgument` cop
|
109
|
+
|
110
|
+
|
111
|
+
## v0.50.0.0 (2017-10-12)
|
112
|
+
|
113
|
+
* Update `rubocop` v0.50.0 and `rubocop-rspec` v1.18.0
|
114
|
+
* Disable `Performance/HashEachMethods` cop
|
115
|
+
* Disable new `Style/OrAssignment` cop
|
116
|
+
* Change cop's department from `Style` to `Naming`
|
117
|
+
* Disable new `Lint/RescueWithoutErrorClass` cop
|
118
|
+
* `node_modules` directory is now excluded by rubocop as default
|
119
|
+
* Enable `Style/YodaCondition` cop with `equality_operators_only` style
|
120
|
+
|
121
|
+
|
122
|
+
## v0.49.1.1 (2017-09-11)
|
123
|
+
|
124
|
+
[full changelog](https://github.com/onk/onkcop/compare/v0.49.1.0...v0.49.1.1)
|
125
|
+
|
126
|
+
* Update `rubocop-rspec` v1.16.0
|
127
|
+
* Disable new `RSpec/ReturnFromStub` cop.
|
128
|
+
* Exclude `config/environments/*.rb` from Metrics/BlockLength cop.
|
129
|
+
* Disable `Performance/Casecmp` cop.
|
130
|
+
* Disable `RSpec/EmptyLineAfterFinalLet` cop.
|
131
|
+
* Relax `RSpec/NestedGroups` cop.
|
132
|
+
|
133
|
+
|
134
|
+
## v0.49.1.0 (2017-05-31)
|
135
|
+
|
136
|
+
[full changelog](https://github.com/onk/onkcop/compare/v0.49.0.0...v0.49.1.0)
|
137
|
+
|
138
|
+
* Update `rubocop` v0.49.1.
|
139
|
+
* Change `Style/TrailingCommaInArguments` to `comma` style.
|
140
|
+
|
141
|
+
|
142
|
+
## v0.49.0.0 (2017-05-25)
|
143
|
+
|
144
|
+
[full changelog](https://github.com/onk/onkcop/compare/v0.48.1.1...v0.49.0.0)
|
145
|
+
|
146
|
+
* Update `rubocop` v0.49.0 and `rubocop-rspec` v1.15.1
|
147
|
+
* Enable `Lint/AmbiguousBlockAssociation` cop except `spec/**/*`
|
148
|
+
* Change some cops to `Layout` department
|
149
|
+
* Disable new `Style/YodaCondition` cop
|
150
|
+
|
151
|
+
|
152
|
+
## v0.48.1.1 (2017-04-18)
|
153
|
+
|
154
|
+
[full changelog](https://github.com/onk/onkcop/compare/v0.48.1.0...v0.48.1.1)
|
155
|
+
|
156
|
+
* Disable `Lint/AmbiguousBlockAssociation` cop.
|
157
|
+
|
158
|
+
|
159
|
+
## v0.48.1.0 (2017-04-17)
|
160
|
+
|
161
|
+
[full changelog](https://github.com/onk/onkcop/compare/v0.48.0.0...v0.48.1.0)
|
162
|
+
|
163
|
+
* Update `rubocop` v0.48.1.
|
164
|
+
* Enable `Rails/Blank` cop.
|
165
|
+
* Enable `Lint/AmbiguousBlockAssociation` cop.
|
166
|
+
* Remove Exclude option from `Style/MixinGrouping` cop.
|
167
|
+
* Change `Style/NumericLiterals` cop to `Strict`.
|
168
|
+
|
169
|
+
|
170
|
+
## v0.48.0.0 (2017-03-29)
|
171
|
+
|
172
|
+
[full changelog](https://github.com/onk/onkcop/compare/v0.47.1.2...v0.48.0.0)
|
173
|
+
|
174
|
+
* Update `rubocop` v0.48.0.
|
175
|
+
* Disable new `Lint/AmbiguousBlockAssociation` cop.
|
176
|
+
* Disable new `Rails/Blank` cop.
|
177
|
+
* Disable `Style/SymbolArray`, `StyleWordArray` cop.
|
178
|
+
* Change `Style/MultilineMethodCallIndentation` to `indented_relative_to_receiver` style.
|
179
|
+
* Exclude RSpec directory from new `Style/MixinGrouping` cop.
|
180
|
+
* Ignore `node_modules` dir.
|
181
|
+
* Add `TargetRailsVersion` to README and template
|
182
|
+
|
183
|
+
|
184
|
+
## v0.47.1.2 (2017-03-01)
|
185
|
+
|
186
|
+
[full changelog](https://github.com/onk/onkcop/compare/v0.47.1.1...v0.47.1.2)
|
187
|
+
|
188
|
+
* Change `Style/StringLiteralsInInterpolation` to `double_quotes` style.
|
189
|
+
|
190
|
+
|
191
|
+
## v0.47.1.1 (2017-03-01)
|
192
|
+
|
193
|
+
[full changelog](https://github.com/onk/onkcop/compare/v0.47.1.0...v0.47.1.1)
|
194
|
+
|
195
|
+
* Update `rubocop-rspec` v1.12.0.
|
196
|
+
* Enable `Style/StringMethods` cop.
|
197
|
+
* Enable `Style/StringLiteralsInInterpolation` cop.
|
198
|
+
* Change `RSpec/DescribedClass` to `explicit` style.
|
199
|
+
* Exclude `*.gemspec` from `Metrics/BlockLength` cop.
|
200
|
+
* Disable `Lint/EmptyWhen` cop.
|
201
|
+
|
202
|
+
|
203
|
+
## v0.47.1.0 (2017-01-20)
|
204
|
+
|
205
|
+
[full changelog](https://github.com/onk/onkcop/compare/v0.46.0.1...v0.47.1.0)
|
206
|
+
|
207
|
+
* Update to `rubocop` v0.47.1 and `rubocop-rspec` v1.10.0.
|
208
|
+
* Remove `Style/SingleLineBlockParams` cop config because disabled by default.
|
209
|
+
* Disable new `Security/YAMLLoad` cop.
|
210
|
+
|
211
|
+
|
212
|
+
## v0.46.0.1 (2017-01-07)
|
213
|
+
|
214
|
+
[full changelog](https://github.com/onk/onkcop/compare/v0.46.0.0...v0.46.0.1)
|
215
|
+
|
216
|
+
* Update to `rubocop-rspec` v1.9.1.
|
217
|
+
* Disable `RSpec/MessageExpectation` cop that is replaced with a new cop: `RSpec/MessageSpies`.
|
218
|
+
* Add CLI for setup `.rubocop.yml`.
|
219
|
+
|
220
|
+
|
221
|
+
## v0.46.0.0 (2016-11-30)
|
222
|
+
|
223
|
+
[full changelog](https://github.com/onk/onkcop/compare/v0.45.0.0...v0.46.0.0)
|
224
|
+
|
225
|
+
* Update to `rubocop` v0.46.0.
|
226
|
+
* Use new `Style/EmptyMethod` cop with `expanded` style.
|
227
|
+
* Use `Style/TernaryParentheses` cop `require_parentheses_when_complex` style.
|
228
|
+
|
229
|
+
|
230
|
+
## v0.45.0.0 (2016-11-02)
|
231
|
+
[full changelog](https://github.com/onk/onkcop/compare/v0.44.1.1...v0.45.0.0)
|
232
|
+
|
233
|
+
* Update to `rubocop` v0.45.0 and `rubocop-rspec` v1.8.0.
|
234
|
+
* Disable new `RSpec/ImplicitExpect` cop.
|
235
|
+
* Explicitly enable `Rspec/MessageExpectation` cop that is now disabled by default.
|
236
|
+
* Exclude Gemfile, Guardfile on `Metrics/BlockLength`.
|
237
|
+
* Disable `Style/TernaryParentheses` cop.
|
238
|
+
* Enable `Rails/HttpPositionalArguments` cop that fixes bug.
|
data/Gemfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in rubocop-codetakt.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem 'rake', '~> 12.0'
|
7
|
+
gem 'rspec', '~> 3.0'
|
8
|
+
gem 'rubocop-performance', '~> 1.6.0'
|
9
|
+
gem 'rubocop-rails', '~> 2.5.0'
|
10
|
+
gem 'rubocop-rspec', '~> 1.39.0'
|
data/{LICENSE → LICENSE.txt}
RENAMED
@@ -1,6 +1,8 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright
|
3
|
+
Copyright for portions of project rubocop-codetakt are held by Takafumi
|
4
|
+
ONAKA, 2019 as part of project onkcop. All other copyright for project
|
5
|
+
rubocop-codetakt are held by codeTakt, 2020.
|
4
6
|
|
5
7
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
8
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,38 +1,55 @@
|
|
1
|
-
#
|
1
|
+
# rubocop-codetakt
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
[](https://badge.fury.io/rb/rubocop-codetakt)
|
4
|
+
|
5
|
+
This includes the RuboCop configuration used by codeTakt. It is for the unification and linfting of coding styles.
|
6
|
+
|
7
|
+
**IMPORTANT** This repository is forked from onk/onkcop v0.53.0.3 (979b8e74eda394434e49caaee31d3f3d781d14f6). And it has been modified for our team. Therefore, it should not be regarded as a successor.
|
5
8
|
|
6
9
|
## Usage
|
7
10
|
|
8
|
-
|
11
|
+
Setup .rubocop.yml
|
9
12
|
|
10
|
-
|
13
|
+
```sh
|
14
|
+
bundle exec rubocop-codetakt init
|
15
|
+
```
|
11
16
|
|
12
|
-
|
13
|
-
|
17
|
+
`init` generate the following directive to your `.rubocop.yml`:
|
18
|
+
|
19
|
+
```yaml
|
20
|
+
inherit_gem:
|
21
|
+
rubocop-codetakt:
|
22
|
+
- "config/rubocop.yml"
|
23
|
+
# uncomment if use performance cops
|
24
|
+
# - "config/performance.yml"
|
25
|
+
# uncomment if use rails cops
|
26
|
+
# - "config/rails.yml"
|
27
|
+
# uncomment if use rspec cops
|
28
|
+
# - "config/rspec.yml"
|
29
|
+
|
30
|
+
AllCops:
|
31
|
+
TargetRubyVersion: 2.5
|
14
32
|
```
|
15
33
|
|
16
|
-
|
34
|
+
```sh
|
35
|
+
bundle exec rubocop <options...>
|
36
|
+
```
|
37
|
+
|
38
|
+
## Installation
|
39
|
+
|
40
|
+
Add this line to your application's Gemfile:
|
17
41
|
|
18
42
|
```ruby
|
19
43
|
group :development do
|
20
|
-
gem
|
44
|
+
gem "rubocop-codetakt", require: false
|
21
45
|
end
|
22
46
|
```
|
23
47
|
|
24
|
-
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/codetakt/rubocop-codetakt.
|
25
51
|
|
26
|
-
```yaml
|
27
|
-
inherit_gem:
|
28
|
-
rubocop-codetakt:
|
29
|
-
- config/rubocop.yml
|
30
|
-
- config/rails.yml # optional.
|
31
|
-
- config/rspec.yml # optional.
|
32
|
-
```
|
33
52
|
|
34
53
|
## License
|
35
54
|
|
36
55
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
37
|
-
|
38
|
-
[1]: https://github.com/onk/onkcop
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'rubocop_codetakt'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/config/rails.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require: "rubocop-rails"
|
2
|
+
|
3
|
+
Rails:
|
4
|
+
Enabled: true
|
4
5
|
|
5
6
|
# Migrations are must not depend to the ApplicationRecord,
|
6
7
|
# because the AR is mutable.
|
@@ -8,3 +9,52 @@ inherit_gem:
|
|
8
9
|
Rails/ApplicationRecord:
|
9
10
|
Exclude:
|
10
11
|
- "db/migrate/*.rb"
|
12
|
+
|
13
|
+
# ActiveRecord で association を安易に delegate すると
|
14
|
+
# N+1 を起こしまくるので、なるべく delegate 的なメソッドを使わずに
|
15
|
+
# コストが掛かっていることを自覚できるようにしておきたい。
|
16
|
+
# メソッドでも危ういが、DSL だと更に意識から抜けるので無効に。
|
17
|
+
Rails/Delegate:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
# 意図せずに exit を書くこと無いでしょ?
|
21
|
+
# 毎回 Exclude / rubocop:disable する方が手間。
|
22
|
+
Rails/Exit:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
# -File.join(Rails.root, "app", "models")
|
26
|
+
# +Rails.root.join("app", "models")
|
27
|
+
# はともかく
|
28
|
+
# -Rails.root.join("app/models")
|
29
|
+
# +Rails.root.join("app", "models")
|
30
|
+
# は Pathname#plus が行っているので意味無いのでは?
|
31
|
+
Rails/FilePath:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
# 桁が揃わなくて気持ち悪い
|
35
|
+
# create(:user, logged_in_at: 1.day.ago)
|
36
|
+
# create(:user, logged_in_at: 2.days.ago)
|
37
|
+
Rails/PluralizationGrammar:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
# unless 文を使ってでも「空」を条件にした方が
|
41
|
+
# 「存在する」よりも「空」の方が状態として特別なので
|
42
|
+
# 脳内モデルと合致しやすい。
|
43
|
+
Rails/Present:
|
44
|
+
Enabled: false
|
45
|
+
|
46
|
+
# method_missing を隠したい場合は respond_to? を使うべき
|
47
|
+
Rails/SafeNavigation:
|
48
|
+
ConvertTry: true
|
49
|
+
|
50
|
+
# valid? チェックし忘れを防ぎたい
|
51
|
+
Rails/SaveBang:
|
52
|
+
Enabled: true
|
53
|
+
|
54
|
+
# staging 環境を使っているので追加
|
55
|
+
Rails/UnknownEnv:
|
56
|
+
Environments:
|
57
|
+
- development # rubocop default.yml
|
58
|
+
- test # rubocop default.yml
|
59
|
+
- production # rubocop default.yml
|
60
|
+
- staging
|
data/config/rspec.yml
CHANGED
@@ -1,20 +1,71 @@
|
|
1
|
-
|
2
|
-
onkcop:
|
3
|
-
- config/rspec.yml
|
1
|
+
require: "rubocop-rspec"
|
4
2
|
|
3
|
+
# 日本語だと「〜の場合」になるので suffix でないと対応できない
|
4
|
+
RSpec/ContextWording:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
# subject はコピペ可搬性よりもそのまま USAGE であって欲しい
|
5
8
|
RSpec/DescribedClass:
|
9
|
+
EnforcedStyle: explicit
|
6
10
|
Exclude:
|
7
11
|
- "spec/requests/*"
|
8
12
|
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
13
|
+
# it が一つしか無いような context では空行を開ける方が読みづらい
|
14
|
+
# context "when foo is bar" do
|
15
|
+
# let(:foo) { bar }
|
16
|
+
# it { is_expected.to do_something }
|
17
|
+
# end
|
18
|
+
RSpec/EmptyLineAfterFinalLet:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
# each で回したり aggregate_failures 使ってたりすると厳しい。
|
22
|
+
# feature spec は exclude でも良いかもしれない。
|
23
|
+
# ヒアドキュメント使うと一瞬で超えるので disable も検討。
|
24
|
+
RSpec/ExampleLength:
|
25
|
+
Max: 8
|
26
|
+
|
27
|
+
# block の方がテスト対象が
|
28
|
+
# * `{}` の前後のスペースと相まって目立つ
|
29
|
+
# * 普段書く形と同じなので自然に脳内に入ってくる
|
30
|
+
RSpec/ExpectChange:
|
31
|
+
EnforcedStyle: block
|
32
|
+
|
33
|
+
# one-liner の should は書きやすいし意味が通りやすいし副作用も無いので撥ねる必要がない。
|
34
|
+
# ただ expect 派に対して強制するほどでもないので統一はしない。
|
35
|
+
RSpec/ImplicitExpect:
|
36
|
+
Enabled: false
|
37
|
+
|
38
|
+
# let を使うのは context 間で条件が違うものが存在する時だけにしたい。
|
39
|
+
# before の方が事前条件を整えていることが分かりやすい。
|
40
|
+
RSpec/InstanceVariable:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
# rubocop-rspec v1.34.0 から RSpec/MultipleExpectations の AggregateFailuresByDefault オプションがなくなった
|
44
|
+
# https://github.com/rubocop-hq/rubocop-rspec/blob/v1.34.0/CHANGELOG.md
|
45
|
+
# feature specなどでは1つのitに複数のexpectをよく書く
|
46
|
+
# 弊社ではaggregate_failuresをデフォルトで有効にしているのでこのCopをoffにする
|
47
|
+
RSpec/MultipleExpectations:
|
48
|
+
Enabled: false
|
49
|
+
|
50
|
+
# 変に名前つけて呼ぶ方が分かりづらい。
|
51
|
+
# テスト対象メソッドを呼ぶだけの subject 以外を書かないようにする方が効く。
|
52
|
+
RSpec/NamedSubject:
|
53
|
+
Enabled: false
|
54
|
+
|
55
|
+
# Model
|
56
|
+
# `- #method
|
57
|
+
# |- 頻出ケースのテスト 1
|
58
|
+
# |- 頻出ケースのテスト 2
|
59
|
+
# `- レアケース
|
60
|
+
# |- レアケースのテスト 1
|
61
|
+
# `- レアケースのテスト 2
|
62
|
+
# のように括り出すと、レアケースのテストを読み飛ばせるようになり
|
63
|
+
# テストを読む人にやさしくなる。
|
64
|
+
# デフォルトの 3 より少し緩めてもヨサソウ。
|
14
65
|
RSpec/NestedGroups:
|
15
66
|
Max: 4
|
16
67
|
|
17
|
-
#
|
18
|
-
#
|
19
|
-
RSpec/
|
68
|
+
# ブロックは初見だと返り値を書いていると気づけないので and_return にしたいが、
|
69
|
+
# ブロックの方が見た目がスッキリして見やすいので、どちらでもお好きにどうぞ。
|
70
|
+
RSpec/ReturnFromStub:
|
20
71
|
Enabled: false
|
data/config/rubocop.yml
CHANGED
@@ -1,40 +1,389 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
AllCops:
|
2
|
+
# We accept the default setting of rookie cops.
|
3
|
+
# https://docs.rubocop.org/rubocop/versioning.html
|
4
|
+
NewCops: enable
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
# Exclude automatically generated files.
|
7
|
+
Exclude:
|
8
|
+
- "node_modules/**/*" # rubocop config/default.yml
|
9
|
+
- "vendor/**/*" # rubocop config/default.yml
|
10
|
+
- "db/schema.rb"
|
7
11
|
|
12
|
+
#################### Layout ################################
|
13
|
+
|
14
|
+
# メソッドをグループ分けして書き順を揃えておくと読みやすくなる。
|
15
|
+
# 多少のツラミはあるかもしれない。
|
16
|
+
# TODO: Categories を調整することで
|
17
|
+
# https://github.com/pocke/rubocop-rails-order_model_declarative_methods
|
18
|
+
# を再現できそう。
|
19
|
+
Layout/ClassStructure:
|
20
|
+
Enabled: true
|
21
|
+
|
22
|
+
# 桁揃えが綺麗にならないことが多いので migration は除外
|
23
|
+
Layout/ExtraSpacing:
|
24
|
+
Exclude:
|
25
|
+
- "db/migrate/*.rb"
|
26
|
+
|
27
|
+
# special_inside_parentheses (default) と比べて
|
28
|
+
# * 横に長くなりづらい
|
29
|
+
# * メソッド名の長さが変わったときに diff が少ない
|
30
|
+
Layout/FirstArrayElementIndentation:
|
31
|
+
EnforcedStyle: consistent
|
32
|
+
|
33
|
+
# ({ と hash を開始した場合に ( の位置にインデントさせる
|
34
|
+
# そもそも {} が必要ない可能性が高いが Style/BracesAroundHashParameters はチェックしないことにしたので
|
35
|
+
Layout/FirstHashElementIndentation:
|
36
|
+
EnforcedStyle: consistent
|
37
|
+
|
38
|
+
# We have decided to accept the default options of this cop (as of
|
39
|
+
# RuboCop v0.83.0.) These are certainly useful in many situations.
|
40
|
+
# However, any product team has the discretion to locally disable this
|
41
|
+
# cop.
|
42
|
+
Layout/HashAlignment:
|
43
|
+
EnforcedHashRocketStyle: key
|
44
|
+
EnforcedColonStyle: key
|
45
|
+
EnforcedLastArgumentHashStyle: always_inspect
|
46
|
+
|
47
|
+
# * 警告 120文字
|
48
|
+
# * 禁止 160文字
|
49
|
+
# のイメージ
|
50
|
+
Layout/LineLength:
|
51
|
+
Max: 160
|
52
|
+
Exclude:
|
53
|
+
- "db/migrate/*.rb"
|
54
|
+
|
55
|
+
# This is a port from our history.
|
56
|
+
# Unfortunately, that process has been lost.
|
8
57
|
Layout/MultilineMethodCallIndentation:
|
9
58
|
EnforcedStyle: indented
|
10
59
|
IndentationWidth: 2
|
11
60
|
|
61
|
+
# {} は 1 行で書くときに主に使われるので、スペースよりも
|
62
|
+
# 横に長くならない方が嬉しさが多い。
|
63
|
+
# そもそも {| のスタイルの方が一般的だったと認識している。
|
64
|
+
Layout/SpaceInsideBlockBraces:
|
65
|
+
SpaceBeforeBlockParameters: false
|
66
|
+
|
67
|
+
#################### Lint ##################################
|
68
|
+
|
69
|
+
# spec 内では
|
70
|
+
# expect { subject }.to change { foo }
|
71
|
+
# という書き方をよく行うので () を省略したい。
|
72
|
+
# { foo } は明らかに change に紐付く。
|
73
|
+
Lint/AmbiguousBlockAssociation:
|
74
|
+
Exclude:
|
75
|
+
- "spec/**/*_spec.rb"
|
76
|
+
|
77
|
+
# Style/EmptyCaseCondition と同じく網羅の表現力が empty when を認めた方が高いし、
|
78
|
+
# 頻出する対象を最初の when で撥ねるのはパフォーマンス向上で頻出する。
|
79
|
+
# また、
|
80
|
+
# case foo
|
81
|
+
# when 42
|
82
|
+
# # nop
|
83
|
+
# when 1..100
|
84
|
+
# ...
|
85
|
+
# end
|
86
|
+
# と、下の when がキャッチしてしまう場合等に対応していない。
|
87
|
+
# See. http://tech.sideci.com/entry/2016/11/01/105900
|
88
|
+
Lint/EmptyWhen:
|
89
|
+
Enabled: false
|
90
|
+
|
91
|
+
# RuntimeError は「特定の Error を定義できない場合」なので、
|
92
|
+
# 定義できるエラーは RuntimeError ではなく StandardError を継承する。
|
93
|
+
Lint/InheritException:
|
94
|
+
EnforcedStyle: standard_error
|
95
|
+
|
96
|
+
# * 同名のメソッドがある場合にローカル変数に `_` を付ける
|
97
|
+
# * 一時変数として `_` を付ける
|
98
|
+
# というテクニックは頻出する
|
99
|
+
Lint/UnderscorePrefixedVariableName:
|
100
|
+
Enabled: false
|
101
|
+
|
102
|
+
# 子クラスで実装させるつもりで中身が
|
103
|
+
# raise NotImplementedError
|
104
|
+
# のみのメソッドが引っかかるので。
|
105
|
+
# (raise せずに中身が空だと IgnoreEmptyMethods でセーフ)
|
106
|
+
Lint/UnusedMethodArgument:
|
107
|
+
Enabled: false
|
108
|
+
|
109
|
+
# select 以外では引っかからないと思うので
|
110
|
+
# mutating_methods のチェックを有効に。
|
111
|
+
# TODO: select は引数が無い (ブロックのみ) の場合にだけチェックする
|
112
|
+
# ようにすると誤検知がほぼ無くなる?
|
113
|
+
Lint/Void:
|
114
|
+
CheckForMethodsWithNoSideEffects: true
|
115
|
+
|
116
|
+
#################### Metrics ###############################
|
117
|
+
|
118
|
+
# 30 まではギリギリ許せる範囲だったけど
|
119
|
+
# リリースごとに 3 ずつぐらい下げていきます。20 まで下げたい。
|
12
120
|
Metrics/AbcSize:
|
13
|
-
Max: 30
|
121
|
+
Max: 30 # Loosen for our firm.
|
122
|
+
|
123
|
+
# Gemfile, Guardfile は DSL 的で基本的に複雑にはならないので除外
|
124
|
+
# rake, rspec, environments, routes は巨大な block 不可避なので除外
|
125
|
+
# TODO: ExcludedMethods の精査
|
126
|
+
Metrics/BlockLength:
|
127
|
+
Exclude:
|
128
|
+
- "Rakefile"
|
129
|
+
- "**/*.rake"
|
130
|
+
- "spec/**/*.rb"
|
131
|
+
- "Gemfile"
|
132
|
+
- "Guardfile"
|
133
|
+
- "config/environments/*.rb"
|
134
|
+
- "config/routes.rb"
|
135
|
+
- "config/routes/**/*.rb"
|
136
|
+
- "*.gemspec"
|
14
137
|
|
138
|
+
# 6 は強すぎるので緩める
|
15
139
|
Metrics/CyclomaticComplexity:
|
16
140
|
Max: 10
|
17
141
|
|
142
|
+
# 20 行超えるのは migration ファイル以外滅多に無い
|
18
143
|
Metrics/MethodLength:
|
19
144
|
Max: 20
|
145
|
+
Exclude:
|
146
|
+
- "db/migrate/*.rb"
|
20
147
|
|
148
|
+
# 分岐の数。ガード句を多用しているとデフォルト 7 だと厳しい
|
21
149
|
Metrics/PerceivedComplexity:
|
22
|
-
Max: 10
|
150
|
+
Max: 10 # Loosen for our firm.
|
151
|
+
|
152
|
+
|
153
|
+
#################### Naming ################################
|
154
|
+
|
155
|
+
# 3 文字未満だと指摘されるが、未使用を示す _ や e(rror), b(lock),
|
156
|
+
# n(umber) といった 1 文字変数は頻出するし、前置詞(by, to, ...)や
|
157
|
+
# よく知られた省略語 (op: operator とか pk: primary key とか) も妥当。
|
158
|
+
# 変数 s にどんな文字列かを形容したい場合と、不要な場合とがある=無効
|
159
|
+
Naming/MethodParameterName:
|
160
|
+
Enabled: false
|
161
|
+
|
162
|
+
# has_ から始まるメソッドは許可する
|
163
|
+
Naming/PredicateName:
|
164
|
+
ForbiddenPrefixes:
|
165
|
+
- "is_"
|
166
|
+
- "have_"
|
167
|
+
NamePrefix:
|
168
|
+
- "is_"
|
169
|
+
- "have_"
|
170
|
+
|
171
|
+
#################### Security ##############################
|
172
|
+
|
173
|
+
# 毎回 YAML.safe_load(yaml_str, [Date, Time]) するのは面倒で。。
|
174
|
+
Security/YAMLLoad:
|
175
|
+
Enabled: false
|
176
|
+
|
177
|
+
|
178
|
+
#################### Style #################################
|
179
|
+
|
180
|
+
# レキシカルスコープの扱いが alias_method の方が自然。
|
181
|
+
# https://ernie.io/2014/10/23/in-defense-of-alias/ のように
|
182
|
+
# 問題になる場合は自分で緩める。
|
183
|
+
Style/Alias:
|
184
|
+
EnforcedStyle: prefer_alias_method
|
185
|
+
|
186
|
+
# redirect_to xxx and return のイディオムを維持したい
|
187
|
+
Style/AndOr:
|
188
|
+
EnforcedStyle: conditionals
|
189
|
+
|
190
|
+
# 日本語のコメントを許可する
|
191
|
+
Style/AsciiComments:
|
192
|
+
Enabled: false
|
193
|
+
|
194
|
+
# do .. end から更にメソッドチェーンすると見づらいので
|
195
|
+
# auto-correct せず、自分で修正する
|
196
|
+
# spec 内は見た目が綺麗になるので許可
|
197
|
+
Style/BlockDelimiters:
|
198
|
+
AutoCorrect: false
|
199
|
+
Exclude:
|
200
|
+
- "spec/**/*_spec.rb"
|
201
|
+
|
202
|
+
# scope が違うとか親 module の存在確認が必要とかデメリットはあるが、
|
203
|
+
# namespace 付きのクラスはかなり頻繁に作るので簡単に書きたい。
|
204
|
+
Style/ClassAndModuleChildren:
|
205
|
+
Enabled: false
|
206
|
+
|
207
|
+
# Style/CollectionMethods 自体は無効になっているのだが、
|
208
|
+
# https://github.com/bbatsov/rubocop/issues/1084
|
209
|
+
# https://github.com/bbatsov/rubocop/issues/1334
|
210
|
+
# Performance/Detect がこの設定値を見るので PreferredMethods だけ変更しておく。
|
211
|
+
#
|
212
|
+
# デフォルト値から変えたのは
|
213
|
+
# find -> detect
|
214
|
+
# ActiveRecord の find と間違えやすいため
|
215
|
+
# reduce -> inject
|
216
|
+
# detect, reject, select と並べたときに韻を踏んでいるため。
|
217
|
+
# collect -> map を維持しているのは文字数が圧倒的に少ないため。
|
218
|
+
Style/CollectionMethods:
|
219
|
+
PreferredMethods:
|
220
|
+
detect: "detect"
|
221
|
+
find: "detect"
|
222
|
+
inject: "inject"
|
223
|
+
reduce: "inject"
|
23
224
|
|
24
|
-
|
25
|
-
|
225
|
+
# ドキュメントの無い public class を許可する
|
226
|
+
Style/Documentation:
|
227
|
+
Enabled: false
|
228
|
+
|
229
|
+
# !! のイディオムは積極的に使う
|
230
|
+
Style/DoubleNegation:
|
231
|
+
Enabled: false
|
232
|
+
|
233
|
+
# case
|
234
|
+
# when ios?
|
235
|
+
# when android?
|
236
|
+
# end
|
237
|
+
# のようなものは case の方が網羅の表現力が高い
|
238
|
+
Style/EmptyCaseCondition:
|
239
|
+
Enabled: false
|
240
|
+
|
241
|
+
# 明示的に else で nil を返すのは分かりやすいので許可する
|
242
|
+
Style/EmptyElse:
|
243
|
+
EnforcedStyle: empty
|
244
|
+
|
245
|
+
# 空メソッドの場合だけ1行で書かなければいけない理由が無い
|
246
|
+
# 「セミコロンは使わない」に寄せた方がルールがシンプル
|
247
|
+
Style/EmptyMethod:
|
248
|
+
EnforcedStyle: expanded
|
249
|
+
|
250
|
+
# いずれかに揃えるのならば `sprintf` や `format` より String#% が好きです
|
251
|
+
Style/FormatString:
|
252
|
+
EnforcedStyle: percent
|
253
|
+
|
254
|
+
# まだ対応するには早い
|
255
|
+
Style/FrozenStringLiteralComment:
|
256
|
+
Enabled: false
|
26
257
|
|
27
|
-
|
258
|
+
# if 文の中に 3 行程度のブロックを書くぐらいは許容した方が現実的
|
259
|
+
# NOTE: https://github.com/bbatsov/rubocop/commit/29945958034db13af9e8ff385ec58cb9eb464596
|
260
|
+
# の影響で、if 文の中身が 1 行の場合に警告されるようになっている。
|
261
|
+
# Style/IfUnlessModifier の設定見てくれないかなぁ? (v0.36.0)
|
262
|
+
Style/GuardClause:
|
263
|
+
MinBodyLength: 5
|
264
|
+
|
265
|
+
# rake タスクの順序の hash は rocket を許可する
|
266
|
+
Style/HashSyntax:
|
267
|
+
Exclude:
|
268
|
+
- "**/*.rake"
|
269
|
+
- "Rakefile"
|
270
|
+
|
271
|
+
# 平たくしてしまうと条件のグルーピングが脳内モデルとズレやすい
|
272
|
+
Style/IfInsideElse:
|
273
|
+
Enabled: false
|
274
|
+
|
275
|
+
# 条件式の方を意識させたい場合には後置の if/unless を使わない方が分かりやすい
|
276
|
+
Style/IfUnlessModifier:
|
277
|
+
Enabled: false
|
278
|
+
|
279
|
+
# scope 等は複数行でも lambda ではなく ->{} で揃えた方が見た目が綺麗
|
280
|
+
Style/Lambda:
|
281
|
+
EnforcedStyle: literal
|
282
|
+
|
283
|
+
# この 2 つは単発で動かすのが分かっているので Object を汚染しても問題ない。
|
284
|
+
# spec/dummy は Rails Engine を開発するときに絶対に引っかかるので入れておく。
|
285
|
+
Style/MixinUsage:
|
286
|
+
Exclude:
|
287
|
+
- "bin/setup"
|
288
|
+
- "bin/update"
|
289
|
+
- "spec/dummy/bin/setup"
|
290
|
+
- "spec/dummy/bin/update"
|
291
|
+
|
292
|
+
# 1_000_000 と区切り文字が 2 個以上必要になる場合のみ _ 区切りを必須にする
|
293
|
+
# 10_000_00 は許可しない。(これは例えば 10000 ドルをセント単位にする時に便利だが
|
294
|
+
# 頻出しないので foolproof に振る
|
295
|
+
Style/NumericLiterals:
|
296
|
+
MinDigits: 7
|
297
|
+
Strict: true
|
298
|
+
|
299
|
+
# foo.positive? は foo > 0 に比べて意味が曖昧になる
|
300
|
+
# foo.zero? は許可したいけどメソッドごとに指定できないので一括で disable に
|
301
|
+
Style/NumericPredicate:
|
28
302
|
Enabled: false
|
29
303
|
|
30
|
-
|
31
|
-
|
304
|
+
# falsy な場合という条件式の方を意識させたい場合がある。
|
305
|
+
# Style/IfUnlessModifier と同じ雰囲気。
|
306
|
+
Style/OrAssignment:
|
307
|
+
Enabled: false
|
32
308
|
|
33
|
-
|
34
|
-
|
309
|
+
# 正規表現にマッチさせた時の特殊変数の置き換えは Regex.last_match ではなく
|
310
|
+
# 名前付きキャプチャを使って参照したいので auto-correct しない
|
311
|
+
Style/PerlBackrefs:
|
312
|
+
AutoCorrect: false
|
35
313
|
|
314
|
+
# Hash#has_key? の方が key? よりも意味が通る
|
315
|
+
Style/PreferredHashMethods:
|
316
|
+
EnforcedStyle: verbose
|
317
|
+
|
318
|
+
# 受け取り側で multiple assignment しろというのを明示
|
319
|
+
Style/RedundantReturn:
|
320
|
+
AllowMultipleReturnValues: true
|
321
|
+
|
322
|
+
# 特に model 内において、ローカル変数とメソッド呼び出しの区別をつけた方が分かりやすい場合が多い
|
323
|
+
Style/RedundantSelf:
|
324
|
+
Enabled: false
|
325
|
+
|
326
|
+
# 無指定だと StandardError を rescue するのは常識の範疇なので。
|
327
|
+
Style/RescueStandardError:
|
328
|
+
EnforcedStyle: implicit
|
329
|
+
|
330
|
+
# user&.admin? が、[nil, true, false] の 3 値を返すことに一瞬で気づけず
|
331
|
+
# boolean を返すっぽく見えてしまうので無効に。
|
332
|
+
# user && user.admin? なら短絡評価で nil が返ってくるのが一目で分かるので。
|
333
|
+
# (boolean を返すメソッド以外なら積極的に使いたいんだけどねぇ
|
334
|
+
#
|
335
|
+
# 他に auto-correct してはいけないパターンとして
|
336
|
+
# if hoge && hoge.count > 1
|
337
|
+
# がある。
|
338
|
+
Style/SafeNavigation:
|
339
|
+
Enabled: false
|
340
|
+
|
341
|
+
# spec 内は見た目が綺麗になるので許可
|
342
|
+
Style/Semicolon:
|
343
|
+
Exclude:
|
344
|
+
- "spec/**/*_spec.rb"
|
345
|
+
|
346
|
+
# String#intern は ruby の内部表現すぎるので String#to_sym を使う
|
347
|
+
Style/StringMethods:
|
348
|
+
Enabled: true
|
349
|
+
|
350
|
+
# %w() と %i() が見分けづらいので Style/WordArray と合わせて無効に。
|
351
|
+
# 書き手に委ねるという意味で、Enabled: false にしています。使っても良い。
|
352
|
+
Style/SymbolArray:
|
353
|
+
Enabled: false
|
354
|
+
|
355
|
+
# 三項演算子は分かりやすく使いたい。
|
356
|
+
# () を外さない方が条件式が何なのか読み取りやすいと感じる。
|
357
|
+
Style/TernaryParentheses:
|
358
|
+
EnforcedStyle: require_parentheses_when_complex
|
359
|
+
|
360
|
+
# Count on developers the handling of the trailing commas
|
361
|
+
# Make consistency with the eslint-config-codetakt.
|
36
362
|
Style/TrailingCommaInArguments:
|
37
363
|
Enabled: false
|
38
364
|
|
39
|
-
Style/
|
365
|
+
Style/TrailingCommaInArrayLiteral:
|
366
|
+
Enabled: false
|
367
|
+
|
368
|
+
Style/TrailingCommaInHashLiteral:
|
369
|
+
Enabled: false
|
370
|
+
|
371
|
+
# %w() と %i() が見分けづらいので Style/SymbolArray と合わせて無効に。
|
372
|
+
# 書き手に委ねるという意味で、Enabled: false にしています。使っても良い。
|
373
|
+
Style/WordArray:
|
374
|
+
Enabled: false
|
375
|
+
|
376
|
+
# 0 <= foo && foo < 5 のように数直線上に並べるのは
|
377
|
+
# コードを読みやすくするテクニックなので equality_operators_only に。
|
378
|
+
# Style/YodaCondition:
|
379
|
+
# # TODO: rubocop 0.63.0以降はforbid_for_equality_operators_onlyなので依存を引き上げれば有効にできる
|
380
|
+
# EnforcedStyle: forbid_for_equality_operators_only
|
381
|
+
|
382
|
+
# 条件式で arr.size > 0 が使われた時に
|
383
|
+
# if !arr.empty?
|
384
|
+
# else
|
385
|
+
# end
|
386
|
+
# に修正されるのが嫌。
|
387
|
+
# 中身を入れ替えて否定外しても良いんだけど、どちらが例外的な処理なのかが分かりづらくなる。
|
388
|
+
Style/ZeroLengthPredicate:
|
40
389
|
Enabled: false
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Codetakt
|
5
|
+
class CLI
|
6
|
+
def self.start(args)
|
7
|
+
action_name = retrieve_command_name(args)
|
8
|
+
unless action_name
|
9
|
+
print_help
|
10
|
+
exit
|
11
|
+
end
|
12
|
+
|
13
|
+
instance = self.new
|
14
|
+
if instance.public_methods(false).include?(action_name.to_sym)
|
15
|
+
instance.__send__(action_name, args)
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
|
19
|
+
puts "Could not find command #{action_name}."
|
20
|
+
print_help
|
21
|
+
exit(1)
|
22
|
+
rescue => e
|
23
|
+
puts e.message
|
24
|
+
exit(1)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.retrieve_command_name(args)
|
28
|
+
meth = args.first.to_s unless args.empty?
|
29
|
+
args.shift if meth && (meth !~ /^\-/)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.print_help
|
33
|
+
puts 'rubocop-codetakt commands:'
|
34
|
+
puts ' init - Setup .rubocop.yml'
|
35
|
+
end
|
36
|
+
|
37
|
+
CONFIG_FILE_NAME = '.rubocop.yml'.freeze
|
38
|
+
def init(args)
|
39
|
+
raise 'usage: rubocop-codetakt init' unless args.empty?
|
40
|
+
|
41
|
+
template_path = File.expand_path('../../../templates', __dir__)
|
42
|
+
puts "#{File.exist?(CONFIG_FILE_NAME) ? 'overwrite' : 'create'} #{CONFIG_FILE_NAME}"
|
43
|
+
FileUtils.copy_file(File.join(template_path, CONFIG_FILE_NAME), CONFIG_FILE_NAME)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'rubocop/codetakt/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'rubocop-codetakt'
|
7
|
+
spec.version = RuboCop::Codetakt::VERSION
|
8
|
+
spec.authors = ['codeTakt Developers']
|
9
|
+
spec.email = ['dev@codetakt.com']
|
10
|
+
|
11
|
+
spec.summary = 'Unify the coding style of Ruby within codeTakt Inc.'
|
12
|
+
spec.description = <<-DESC
|
13
|
+
This includes the RuboCop configuration used by codeTakt. It is
|
14
|
+
for the unification and linting of coding styles.
|
15
|
+
DESC
|
16
|
+
spec.homepage = 'https://github.com/codetakt/rubocop-codetakt'
|
17
|
+
spec.license = 'MIT'
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
spec.bindir = 'exe'
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_dependency 'rubocop', '~> 0.84.0'
|
25
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
inherit_gem:
|
2
|
+
rubocop-codetakt:
|
3
|
+
- "config/rubocop.yml"
|
4
|
+
# uncomment if use performance cops
|
5
|
+
# - "config/performance.yml"
|
6
|
+
# uncomment if use rails cops
|
7
|
+
# - "config/rails.yml"
|
8
|
+
# uncomment if use rspec cops
|
9
|
+
# - "config/rspec.yml"
|
10
|
+
|
11
|
+
AllCops:
|
12
|
+
TargetRubyVersion: 2.5
|
metadata
CHANGED
@@ -1,70 +1,62 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-codetakt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.84.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- codeTakt
|
7
|
+
- codeTakt Developers
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.52.1.1
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - '='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.52.1.1
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.14'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.14'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
14
|
+
name: rubocop
|
43
15
|
requirement: !ruby/object:Gem::Requirement
|
44
16
|
requirements:
|
45
17
|
- - "~>"
|
46
18
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
-
type: :
|
19
|
+
version: 0.84.0
|
20
|
+
type: :runtime
|
49
21
|
prerelease: false
|
50
22
|
version_requirements: !ruby/object:Gem::Requirement
|
51
23
|
requirements:
|
52
24
|
- - "~>"
|
53
25
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
description:
|
56
|
-
|
57
|
-
|
26
|
+
version: 0.84.0
|
27
|
+
description: |2
|
28
|
+
This includes the RuboCop configuration used by codeTakt. It is
|
29
|
+
for the unification and linting of coding styles.
|
30
|
+
email:
|
31
|
+
- dev@codetakt.com
|
32
|
+
executables:
|
33
|
+
- rubocop-codetakt
|
58
34
|
extensions: []
|
59
35
|
extra_rdoc_files: []
|
60
36
|
files:
|
37
|
+
- ".gitignore"
|
38
|
+
- ".rspec"
|
39
|
+
- ".rubocop.yml"
|
40
|
+
- ".travis.yml"
|
61
41
|
- CHANGELOG.md
|
62
|
-
-
|
42
|
+
- Gemfile
|
43
|
+
- LICENSE.txt
|
63
44
|
- README.md
|
45
|
+
- Rakefile
|
46
|
+
- bin/console
|
47
|
+
- bin/setup
|
48
|
+
- config/performance.yml
|
64
49
|
- config/rails.yml
|
65
50
|
- config/rspec.yml
|
66
51
|
- config/rubocop.yml
|
67
|
-
|
52
|
+
- exe/rubocop-codetakt
|
53
|
+
- lib/rubocop/codetakt.rb
|
54
|
+
- lib/rubocop/codetakt/cli.rb
|
55
|
+
- lib/rubocop/codetakt/version.rb
|
56
|
+
- lib/rubocop_codetakt.rb
|
57
|
+
- rubocop-codetakt.gemspec
|
58
|
+
- templates/.rubocop.yml
|
59
|
+
homepage: https://github.com/codetakt/rubocop-codetakt
|
68
60
|
licenses:
|
69
61
|
- MIT
|
70
62
|
metadata: {}
|
@@ -83,9 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
75
|
- !ruby/object:Gem::Version
|
84
76
|
version: '0'
|
85
77
|
requirements: []
|
86
|
-
|
87
|
-
rubygems_version: 2.5.2
|
78
|
+
rubygems_version: 3.1.2
|
88
79
|
signing_key:
|
89
80
|
specification_version: 4
|
90
|
-
summary:
|
81
|
+
summary: Unify the coding style of Ruby within codeTakt Inc.
|
91
82
|
test_files: []
|