datarockets-style 1.1.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +46 -4
- data/Gemfile +2 -4
- data/README.md +25 -16
- data/RELEASING.md +1 -1
- data/config/base.yml +21 -2
- data/config/rails-locales.yml +2 -0
- data/config/rails.yml +3 -0
- data/config/rspec.yml +3 -0
- data/datarockets-style.gemspec +11 -4
- data/doc/STYLE_GUIDE.md +80 -0
- data/doc/STYLE_GUIDE_RSPEC.md +16 -0
- data/lib/datarockets_style/cop/layout/array_alignment_extended.rb +5 -4
- data/lib/datarockets_style/cop/rspec/prefer_before_over_setup.rb +43 -0
- data/lib/datarockets_style/cop/style/nested_interpolation.rb +3 -1
- data/lib/datarockets_style/formatter/todo_list_formatter/report_summary.rb +2 -0
- data/lib/datarockets_style/formatter/todo_list_formatter.rb +2 -0
- data/lib/datarockets_style/version.rb +3 -1
- data/lib/datarockets_style.rb +3 -0
- data/manual/cops_layout.md +24 -0
- metadata +58 -26
- data/Gemfile.lock +0 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6270a40b4ee5b048f1e8df9b7771556a66cc0ff086b9e5198e1b2b2220d99113
|
4
|
+
data.tar.gz: e1d537d012304fdcf3d0439d8fa36625823da85930e31304ffa8f1ff4b839f91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67361be1894556117a361d9d2a7f5f82be094d61c5b16df15f2248fd5f41c7f669b6a864415d153d94cf3c94002f0bf936a3accb55c3fb765054a36c2a364c55
|
7
|
+
data.tar.gz: 5da0e3a48096c6189decf5692f0d3a258cd572310ccd2553edbc713c97a727e25bd785e4dec621f712a6fa048065fa79cf334815b3642e84acbb9961980cbd89
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,19 +4,61 @@ The format is described in [Contributing notes](CONTRIBUTING.md#changelog-entry-
|
|
4
4
|
|
5
5
|
## master
|
6
6
|
|
7
|
+
## 1.3.0 (2022-12-02)
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
* [#261](https://github.com/datarockets/ruby-style/issues/261) Add new config `rails-locales`. ([@r.dubrovsky][])
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
|
15
|
+
* **(Breaking)** Drop support for Ruby 2.4 and Ruby 2.5. ([@r.dubrovsky][])
|
16
|
+
|
17
|
+
* [#260](https://github.com/datarockets/ruby-style/issues/260) Update rubocop to `1.39`. ([@r.dubrovsky][])
|
18
|
+
* Setup `Layout/CaseIndentation` rule. ([@r.dubrovsky][])
|
19
|
+
* [#261](https://github.com/datarockets/ruby-style/issues/261) Update rubocop-rails to `2.17.3`. ([@r.dubrovsky][])
|
20
|
+
* [#262](https://github.com/datarockets/ruby-style/issues/262) Update rubocop-rspec to `2.15`. ([@r.dubrovsky][])
|
21
|
+
* [#32](https://github.com/datarockets/ruby-style/issues/32) Enable back `Style/FrozenStringLiteralComment` cop. ([@r.dubrovsky][])
|
22
|
+
* [#176](https://github.com/datarockets/ruby-style/issues/176) Fix hash alignment via changing `Layout/HashAlignment` cop. ([@r.dubrovsky][])
|
23
|
+
* [#263](https://github.com/datarockets/ruby-style/issues/263) Setup `EnforcedStyle` for `Layout/LineEndStringConcatenationIndentation` cop. ([@r.dubrovsky][])
|
24
|
+
* [#258](https://github.com/datarockets/ruby-style/issues/258) Setup `EnforcedStyle` for `Layout/FirstArrayElementIndentation` cop. ([@r.dubrovsky][])
|
25
|
+
* [#179](https://github.com/datarockets/ruby-style/issues/179) Setup `EnforcedStyleAlignWith` rule for `Layout/BlockAlignment` cop. ([@r.dubrovsky][])
|
26
|
+
|
27
|
+
### Fixed
|
28
|
+
|
29
|
+
* [#196](https://github.com/datarockets/ruby-style/issues/196) Fix `Layout/ArrayAlignmentExtended` cop. ([@r.dubrovsky][])
|
30
|
+
* [#258](https://github.com/datarockets/ruby-style/issues/258) Fix conflict between `Layout/ArrayAlignmentExtended` and `Layout/FirstArrayElementIndentation` cops. ([@r.dubrovsky][])
|
31
|
+
|
32
|
+
## 1.2.0 (2021-02-24)
|
33
|
+
|
34
|
+
### Added
|
35
|
+
|
36
|
+
* [#219](https://github.com/datarockets/datarockets-style/issues/219) Add `RSpec/PreferBeforeOverSetup` cop. ([@paydaylight][])
|
37
|
+
|
38
|
+
### Changed
|
39
|
+
|
40
|
+
* [#233](https://github.com/datarockets/datarockets-style/issues/233) Setup `EnforcedStyleForMultiline` for `Style/TrailingCommaInArguments` and `Style/TrailingCommaInArrayLiteral` rules. ([@paydaylight][])
|
41
|
+
* [#124](https://github.com/datarockets/datarockets-style/issues/124) Move gem dependencies to `./datarockets-style.gemspec` and drop `Gemfile.lock` tracking. ([@paydaylight][])
|
42
|
+
* [#253](https://github.com/datarockets/datarockets-style/issues/253) Update rubocop to `1.10`. ([@paydaylight][])
|
43
|
+
* [#124](https://github.com/datarockets/datarockets-style/issues/124) Update rubocop-rails to `2.9`. ([@paydaylight][])
|
44
|
+
|
45
|
+
### Fixed
|
46
|
+
|
47
|
+
* [#251](https://github.com/datarockets/datarockets-style/issues/251) Update documentation to match `1.1.0` release changes. ([@paydaylight][])
|
48
|
+
|
7
49
|
## 1.1.0 (2021-02-09)
|
8
50
|
|
9
51
|
### Changed
|
10
52
|
|
11
53
|
* Setup `EnforcedStyleForMultiline` for `Style/TrailingCommaInHashLiteral` rule. ([@r.dubrovsky][])
|
12
|
-
* Update rubocop to
|
13
|
-
* Update rubocop-rails requirement to
|
54
|
+
* Update rubocop to `1.9.1`. ([@paydaylight][])
|
55
|
+
* Update rubocop-rails requirement to `>= 2.8.0, < 2.10.0`. ([@paydaylight][])
|
14
56
|
* Update rubocop-rspec to `2.2.0`. ([@paydaylight][])
|
15
|
-
* Change
|
57
|
+
* Change `Datarockets::Style` module to `DatarocketsStyle`. ([@paydaylight][])
|
16
58
|
|
17
59
|
### Fixed
|
18
60
|
|
19
|
-
* [#177](https://github.com/datarockets/datarockets-style/issues/177) set
|
61
|
+
* [#177](https://github.com/datarockets/datarockets-style/issues/177) set `Layout/MultilineOperationIndentation` to indented ([@paydaylight][])
|
20
62
|
|
21
63
|
## 1.0.0 (2020-11-10)
|
22
64
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -10,14 +10,14 @@ Add this line to your application's Gemfile:
|
|
10
10
|
|
11
11
|
```ruby
|
12
12
|
group :test, :development do
|
13
|
-
gem 'datarockets-style', '~> 1.
|
13
|
+
gem 'datarockets-style', '~> 1.3.0'
|
14
14
|
end
|
15
15
|
```
|
16
16
|
|
17
17
|
Or, for a Ruby library, add this to your gemspec:
|
18
18
|
|
19
19
|
```ruby
|
20
|
-
spec.add_development_dependency 'datarockets-style', '~> 1.
|
20
|
+
spec.add_development_dependency 'datarockets-style', '~> 1.3.0'
|
21
21
|
```
|
22
22
|
|
23
23
|
And then execute:
|
@@ -51,6 +51,15 @@ inherit_gem:
|
|
51
51
|
- config/rails.yml
|
52
52
|
```
|
53
53
|
|
54
|
+
By default, it doesn't include rules for I18n. For enabling them, add the next styles
|
55
|
+
|
56
|
+
```yaml
|
57
|
+
inherit_gem:
|
58
|
+
datarockets-style:
|
59
|
+
- config/rails.yml
|
60
|
+
- config/rails-locales.yml
|
61
|
+
```
|
62
|
+
|
54
63
|
### Rspec config
|
55
64
|
|
56
65
|
For Rspec tests, you can add a special rubocop config
|
@@ -108,28 +117,28 @@ Result of the formatter is compatible with rubocop config or rubocop todo file.
|
|
108
117
|
For running that cop, just print in your command like
|
109
118
|
|
110
119
|
```bash
|
111
|
-
$ bundle exec rubocop -f TodoListFormatter -r
|
120
|
+
$ bundle exec rubocop -f TodoListFormatter -r datarockets_style
|
112
121
|
Inspecting 10 files
|
113
122
|
...CC.CC..
|
114
123
|
10 files inspected, 7 offenses detected
|
115
124
|
|
116
125
|
Layout/IndentationConsistency:
|
117
126
|
Exclude:
|
118
|
-
- 'spec/
|
127
|
+
- 'spec/datarockets_style/formatter/todo_list_formatter_spec.rb' # 1
|
119
128
|
|
120
129
|
Naming/MemoizedInstanceVariableName:
|
121
130
|
Exclude:
|
122
|
-
- 'lib/
|
131
|
+
- 'lib/datarockets_style/formatter/todo_list_formatter/report_summary.rb' # 1
|
123
132
|
|
124
133
|
RSpec/ExampleLength:
|
125
134
|
Exclude:
|
126
|
-
- 'spec/
|
127
|
-
- 'spec/
|
135
|
+
- 'spec/datarockets_style/formatter/todo_list_formatter/report_summary_spec.rb' # 1
|
136
|
+
- 'spec/datarockets_style/formatter/todo_list_formatter_spec.rb' # 2
|
128
137
|
|
129
138
|
Style/Documentation:
|
130
139
|
Exclude:
|
131
|
-
- 'lib/
|
132
|
-
- 'lib/
|
140
|
+
- 'lib/datarockets_style/formatter/todo_list_formatter/report_summary.rb' # 1
|
141
|
+
- 'lib/datarockets_style/formatter/todo_list_formatter.rb' # 1
|
133
142
|
```
|
134
143
|
|
135
144
|
#### Autocorrection
|
@@ -137,24 +146,24 @@ Style/Documentation:
|
|
137
146
|
If you run the formatter with autocorrection options, the formatter skip corrected cop and does not include it to the result.
|
138
147
|
|
139
148
|
```bash
|
140
|
-
$ bundle exec rubocop -f TodoListFormatter -r
|
149
|
+
$ bundle exec rubocop -f TodoListFormatter -r datarockets_style -a
|
141
150
|
Inspecting 10 files
|
142
151
|
...CC.CC..
|
143
152
|
10 files inspected, 7 offenses detected, 1 offenses corrected
|
144
153
|
|
145
154
|
Naming/MemoizedInstanceVariableName:
|
146
155
|
Exclude:
|
147
|
-
- 'lib/
|
156
|
+
- 'lib/datarockets_style/formatter/todo_list_formatter/report_summary.rb' # 1
|
148
157
|
|
149
158
|
RSpec/ExampleLength:
|
150
159
|
Exclude:
|
151
|
-
- 'spec/
|
152
|
-
- 'spec/
|
160
|
+
- 'spec/datarockets_style/formatter/todo_list_formatter/report_summary_spec.rb' # 1
|
161
|
+
- 'spec/datarockets_style/formatter/todo_list_formatter_spec.rb' # 2
|
153
162
|
|
154
163
|
Style/Documentation:
|
155
164
|
Exclude:
|
156
|
-
- 'lib/
|
157
|
-
- 'lib/
|
165
|
+
- 'lib/datarockets_style/formatter/todo_list_formatter/report_summary.rb' # 1
|
166
|
+
- 'lib/datarockets_style/formatter/todo_list_formatter.rb' # 1
|
158
167
|
```
|
159
168
|
|
160
169
|
## Non-goals of RuboCop
|
@@ -178,4 +187,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
178
187
|
|
179
188
|
## Code of Conduct
|
180
189
|
|
181
|
-
Everyone interacting in the
|
190
|
+
Everyone interacting in the DatarocketsStyle project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
|
data/RELEASING.md
CHANGED
data/config/base.yml
CHANGED
@@ -25,8 +25,18 @@ Layout/ArrayAlignmentExtended:
|
|
25
25
|
- with_fixed_indentation
|
26
26
|
IndentationWidth: ~
|
27
27
|
|
28
|
+
Layout/BlockAlignment:
|
29
|
+
EnforcedStyleAlignWith: start_of_block
|
30
|
+
|
31
|
+
Layout/CaseIndentation:
|
32
|
+
EnforcedStyle: end
|
33
|
+
|
34
|
+
Layout/FirstArrayElementIndentation:
|
35
|
+
EnforcedStyle: consistent
|
36
|
+
|
28
37
|
Layout/HashAlignment:
|
29
|
-
|
38
|
+
EnforcedColonStyle: key
|
39
|
+
EnforcedHashRocketStyle: key
|
30
40
|
|
31
41
|
Layout/ParameterAlignment:
|
32
42
|
EnforcedStyle: with_fixed_indentation
|
@@ -41,6 +51,9 @@ Layout/EndAlignment:
|
|
41
51
|
Layout/IndentationConsistency:
|
42
52
|
EnforcedStyle: normal
|
43
53
|
|
54
|
+
Layout/LineEndStringConcatenationIndentation:
|
55
|
+
EnforcedStyle: indented
|
56
|
+
|
44
57
|
Layout/LineLength:
|
45
58
|
Max: 120
|
46
59
|
|
@@ -152,7 +165,7 @@ Style/HashTransformValues:
|
|
152
165
|
Enabled: true
|
153
166
|
|
154
167
|
Style/FrozenStringLiteralComment:
|
155
|
-
Enabled:
|
168
|
+
Enabled: true
|
156
169
|
|
157
170
|
Style/NestedInterpolation:
|
158
171
|
Enabled: true
|
@@ -190,5 +203,11 @@ Style/StringConcatenation:
|
|
190
203
|
Style/StringLiterals:
|
191
204
|
EnforcedStyle: double_quotes
|
192
205
|
|
206
|
+
Style/TrailingCommaInArguments:
|
207
|
+
EnforcedStyleForMultiline: comma
|
208
|
+
|
209
|
+
Style/TrailingCommaInArrayLiteral:
|
210
|
+
EnforcedStyleForMultiline: comma
|
211
|
+
|
193
212
|
Style/TrailingCommaInHashLiteral:
|
194
213
|
EnforcedStyleForMultiline: comma
|
data/config/rails.yml
CHANGED
data/config/rspec.yml
CHANGED
data/datarockets-style.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path("lib", __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require "datarockets_style/version"
|
@@ -12,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
12
14
|
spec.homepage = "https://github.com/datarockets/datarockets-style"
|
13
15
|
spec.license = "MIT"
|
14
16
|
|
15
|
-
spec.required_ruby_version = ">= 2.
|
17
|
+
spec.required_ruby_version = ">= 2.6.0"
|
16
18
|
|
17
19
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
20
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
@@ -30,7 +32,12 @@ Gem::Specification.new do |spec|
|
|
30
32
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
33
|
spec.require_paths = ["lib"]
|
32
34
|
|
33
|
-
spec.add_dependency "rubocop", "
|
34
|
-
spec.add_dependency "rubocop-rails", "
|
35
|
-
spec.add_dependency "rubocop-rspec", "~> 2.
|
35
|
+
spec.add_dependency "rubocop", "~> 1.39"
|
36
|
+
spec.add_dependency "rubocop-rails", "~> 2.17.3"
|
37
|
+
spec.add_dependency "rubocop-rspec", "~> 2.15"
|
38
|
+
|
39
|
+
spec.add_development_dependency "pry-byebug"
|
40
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
41
|
+
spec.add_development_dependency "rspec", "~> 3.10"
|
42
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
36
43
|
end
|
data/doc/STYLE_GUIDE.md
CHANGED
@@ -392,6 +392,86 @@ def foo
|
|
392
392
|
end
|
393
393
|
```
|
394
394
|
|
395
|
+
* <a name="style-trailing-comma-in-arguments"></a>
|
396
|
+
Requires a comma after the last argument, but only for parenthesized method calls where each argument is on its own line.
|
397
|
+
<sup>[[link](#style-trailing-comma-in-arguments)]</sup>
|
398
|
+
|
399
|
+
```ruby
|
400
|
+
# bad
|
401
|
+
method(1, 2,)
|
402
|
+
|
403
|
+
# good
|
404
|
+
method(1, 2)
|
405
|
+
|
406
|
+
# bad
|
407
|
+
method(
|
408
|
+
1, 2,
|
409
|
+
3,
|
410
|
+
)
|
411
|
+
|
412
|
+
# good
|
413
|
+
method(
|
414
|
+
1, 2,
|
415
|
+
3
|
416
|
+
)
|
417
|
+
|
418
|
+
# bad
|
419
|
+
method(
|
420
|
+
1, 2, 3,
|
421
|
+
)
|
422
|
+
|
423
|
+
# good
|
424
|
+
method(
|
425
|
+
1, 2, 3
|
426
|
+
)
|
427
|
+
|
428
|
+
# good
|
429
|
+
method(
|
430
|
+
1,
|
431
|
+
2,
|
432
|
+
)
|
433
|
+
```
|
434
|
+
|
435
|
+
* <a name="style-trailing-comma-in-array-literals"></a>
|
436
|
+
Requires a comma after last item in an array, but only when each item is on its own line.
|
437
|
+
<sup>[[link](#style-trailing-comma-in-array-literals)]</sup>
|
438
|
+
|
439
|
+
```ruby
|
440
|
+
# bad
|
441
|
+
a = [1, 2,]
|
442
|
+
|
443
|
+
# good
|
444
|
+
a = [1, 2]
|
445
|
+
|
446
|
+
# bad
|
447
|
+
a = [
|
448
|
+
1, 2,
|
449
|
+
3,
|
450
|
+
]
|
451
|
+
|
452
|
+
# good
|
453
|
+
a = [
|
454
|
+
1, 2,
|
455
|
+
3
|
456
|
+
]
|
457
|
+
|
458
|
+
# bad
|
459
|
+
a = [
|
460
|
+
1, 2, 3,
|
461
|
+
]
|
462
|
+
|
463
|
+
# good
|
464
|
+
a = [
|
465
|
+
1, 2, 3
|
466
|
+
]
|
467
|
+
|
468
|
+
# good
|
469
|
+
a = [
|
470
|
+
1,
|
471
|
+
2,
|
472
|
+
]
|
473
|
+
```
|
474
|
+
|
395
475
|
* <a name="style-trailing-comma-in-hash-literal"></a>
|
396
476
|
Requires a comma after the last item in a hash.
|
397
477
|
<sup>[[link](#style-trailing-comma-in-hash-literal)]</sup>
|
data/doc/STYLE_GUIDE_RSPEC.md
CHANGED
@@ -186,3 +186,19 @@ it "returns the last widget" do
|
|
186
186
|
expect(Widget.last).to eq my_widget
|
187
187
|
end
|
188
188
|
```
|
189
|
+
|
190
|
+
* <a name="rspec-prefer-before"></a>
|
191
|
+
Prefer using `before` instead of `setup`.
|
192
|
+
<sup>[[link](#rspec-prefer-before)]</sup>
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
# bad
|
196
|
+
setup do
|
197
|
+
allow(post).to receive(:publish!)
|
198
|
+
end
|
199
|
+
|
200
|
+
# good
|
201
|
+
before do
|
202
|
+
allow(post).to receive(:publish!)
|
203
|
+
end
|
204
|
+
```
|
@@ -33,13 +33,14 @@ module DatarocketsStyle
|
|
33
33
|
#
|
34
34
|
# array = [1, 2, 3,
|
35
35
|
# 4, 5, 6]
|
36
|
-
class ArrayAlignmentExtended < RuboCop::Cop::
|
36
|
+
class ArrayAlignmentExtended < RuboCop::Cop::Base
|
37
37
|
include RuboCop::Cop::Alignment
|
38
|
+
extend RuboCop::Cop::AutoCorrector
|
38
39
|
|
39
40
|
ALIGN_PARAMS_MSG = "Align the elements of an array literal if they span more than one line."
|
40
41
|
|
41
42
|
FIXED_INDENT_MSG = "Use one level of indentation for elements " \
|
42
|
-
|
43
|
+
"following the first line of a multi-line array."
|
43
44
|
|
44
45
|
def on_array(node)
|
45
46
|
return if node.children.size < 2
|
@@ -47,8 +48,8 @@ module DatarocketsStyle
|
|
47
48
|
check_alignment(node.children, base_column(node, node.children))
|
48
49
|
end
|
49
50
|
|
50
|
-
def autocorrect(node)
|
51
|
-
RuboCop::Cop::AlignmentCorrector.correct(processed_source, node, column_delta)
|
51
|
+
def autocorrect(corrector, node)
|
52
|
+
RuboCop::Cop::AlignmentCorrector.correct(corrector, processed_source, node, column_delta)
|
52
53
|
end
|
53
54
|
|
54
55
|
private
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DatarocketsStyle
|
4
|
+
module Cop
|
5
|
+
module RSpec
|
6
|
+
# Checks that tests use `before` instead of RoR unit-test `setup` method (part of `rspec-rails` gem)
|
7
|
+
#
|
8
|
+
# bad
|
9
|
+
#
|
10
|
+
# setup do
|
11
|
+
# allow(post).to receive(:publish!)
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# good
|
15
|
+
#
|
16
|
+
# before do
|
17
|
+
# allow(post).to receive(:publish!)
|
18
|
+
# end
|
19
|
+
class PreferBeforeOverSetup < RuboCop::Cop::Cop
|
20
|
+
MSG = "Use `before` instead of `setup`."
|
21
|
+
|
22
|
+
def_node_matcher :setup_call?, <<-PATTERN
|
23
|
+
(block
|
24
|
+
(send _ :setup)
|
25
|
+
(args) _)
|
26
|
+
PATTERN
|
27
|
+
|
28
|
+
def on_block(node)
|
29
|
+
return unless setup_call?(node)
|
30
|
+
|
31
|
+
add_offense(node)
|
32
|
+
end
|
33
|
+
|
34
|
+
def autocorrect(node)
|
35
|
+
lambda do |corrector|
|
36
|
+
block_internals = node.source.split(/ /)
|
37
|
+
corrector.replace node.loc.expression, ["before", *block_internals[1..]].join(" ")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module DatarocketsStyle
|
2
4
|
module Cop
|
3
5
|
module Style
|
@@ -14,7 +16,7 @@ module DatarocketsStyle
|
|
14
16
|
class NestedInterpolation < RuboCop::Cop::Cop
|
15
17
|
include RuboCop::Cop::Interpolation
|
16
18
|
|
17
|
-
MSG = "Redundant nested interpolation."
|
19
|
+
MSG = "Redundant nested interpolation."
|
18
20
|
|
19
21
|
def on_interpolation(node)
|
20
22
|
node.each_descendant(:dstr) do |descendant_node|
|
data/lib/datarockets_style.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rubocop"
|
2
4
|
require "datarockets_style/formatter/todo_list_formatter"
|
3
5
|
|
@@ -5,6 +7,7 @@ require "datarockets_style/version"
|
|
5
7
|
|
6
8
|
require "datarockets_style/cop/layout/array_alignment_extended"
|
7
9
|
require "datarockets_style/cop/style/nested_interpolation"
|
10
|
+
require "datarockets_style/cop/rspec/prefer_before_over_setup"
|
8
11
|
|
9
12
|
# Top level module for datarockets-style
|
10
13
|
module DatarocketsStyle
|
data/manual/cops_layout.md
CHANGED
@@ -52,6 +52,30 @@ Name | Default value | Configurable values
|
|
52
52
|
EnforcedStyle | `with_first_parameter` | `with_first_parameter`, `with_fixed_indentation`
|
53
53
|
IndentationWidth | `<none>` | Integer
|
54
54
|
|
55
|
+
# RSpec
|
56
|
+
|
57
|
+
## RSpec/PreferBeforeOverSetup
|
58
|
+
|
59
|
+
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
60
|
+
--- | --- | --- | --- | ---
|
61
|
+
Enabled | Yes | Yes | 1.2.0 | -
|
62
|
+
|
63
|
+
Checks that tests use `before` instead of RoR unit-test `setup` method (part of `rspec-rails` gem)
|
64
|
+
|
65
|
+
### Example
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
# bad
|
69
|
+
setup do
|
70
|
+
allow(post).to receive(:publish!)
|
71
|
+
end
|
72
|
+
|
73
|
+
# good
|
74
|
+
before do
|
75
|
+
allow(post).to receive(:publish!)
|
76
|
+
end
|
77
|
+
```
|
78
|
+
|
55
79
|
# Style
|
56
80
|
|
57
81
|
## Style/NestedInterpolation
|
metadata
CHANGED
@@ -1,69 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datarockets-style
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Dubrovsky
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.2'
|
20
|
-
- - "<"
|
17
|
+
- - "~>"
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
19
|
+
version: '1.39'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '1.2'
|
30
|
-
- - "<"
|
24
|
+
- - "~>"
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
26
|
+
version: '1.39'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: rubocop-rails
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
|
-
- - "
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.17.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
38
39
|
- !ruby/object:Gem::Version
|
39
|
-
version: 2.
|
40
|
-
|
40
|
+
version: 2.17.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop-rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
41
46
|
- !ruby/object:Gem::Version
|
42
|
-
version: 2.
|
47
|
+
version: '2.15'
|
43
48
|
type: :runtime
|
44
49
|
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.15'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
45
64
|
version_requirements: !ruby/object:Gem::Requirement
|
46
65
|
requirements:
|
47
66
|
- - ">="
|
48
67
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
50
|
-
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '13.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
51
81
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
82
|
+
version: '13.0'
|
53
83
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
84
|
+
name: rspec
|
55
85
|
requirement: !ruby/object:Gem::Requirement
|
56
86
|
requirements:
|
57
87
|
- - "~>"
|
58
88
|
- !ruby/object:Gem::Version
|
59
|
-
version: '
|
60
|
-
type: :
|
89
|
+
version: '3.10'
|
90
|
+
type: :development
|
61
91
|
prerelease: false
|
62
92
|
version_requirements: !ruby/object:Gem::Requirement
|
63
93
|
requirements:
|
64
94
|
- - "~>"
|
65
95
|
- !ruby/object:Gem::Version
|
66
|
-
version: '
|
96
|
+
version: '3.10'
|
67
97
|
description:
|
68
98
|
email:
|
69
99
|
- r.dubrovsky@datarockets.com
|
@@ -82,7 +112,6 @@ files:
|
|
82
112
|
- CODE_OF_CONDUCT.md
|
83
113
|
- CONTRIBUTING.md
|
84
114
|
- Gemfile
|
85
|
-
- Gemfile.lock
|
86
115
|
- LICENSE.txt
|
87
116
|
- Makefile
|
88
117
|
- README.md
|
@@ -91,6 +120,7 @@ files:
|
|
91
120
|
- bin/console
|
92
121
|
- bin/setup
|
93
122
|
- config/base.yml
|
123
|
+
- config/rails-locales.yml
|
94
124
|
- config/rails.yml
|
95
125
|
- config/rspec.yml
|
96
126
|
- config/ruby.yml
|
@@ -100,6 +130,7 @@ files:
|
|
100
130
|
- doc/STYLE_GUIDE_RSPEC.md
|
101
131
|
- lib/datarockets_style.rb
|
102
132
|
- lib/datarockets_style/cop/layout/array_alignment_extended.rb
|
133
|
+
- lib/datarockets_style/cop/rspec/prefer_before_over_setup.rb
|
103
134
|
- lib/datarockets_style/cop/style/nested_interpolation.rb
|
104
135
|
- lib/datarockets_style/formatter/todo_list_formatter.rb
|
105
136
|
- lib/datarockets_style/formatter/todo_list_formatter/report_summary.rb
|
@@ -110,6 +141,7 @@ licenses:
|
|
110
141
|
- MIT
|
111
142
|
metadata:
|
112
143
|
allowed_push_host: https://rubygems.org
|
144
|
+
rubygems_mfa_required: 'true'
|
113
145
|
post_install_message:
|
114
146
|
rdoc_options: []
|
115
147
|
require_paths:
|
@@ -118,14 +150,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
150
|
requirements:
|
119
151
|
- - ">="
|
120
152
|
- !ruby/object:Gem::Version
|
121
|
-
version: 2.
|
153
|
+
version: 2.6.0
|
122
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
155
|
requirements:
|
124
156
|
- - ">="
|
125
157
|
- !ruby/object:Gem::Version
|
126
158
|
version: '0'
|
127
159
|
requirements: []
|
128
|
-
rubygems_version: 3.
|
160
|
+
rubygems_version: 3.1.4
|
129
161
|
signing_key:
|
130
162
|
specification_version: 4
|
131
163
|
summary: Datarockets style guides and shared style configs
|
data/Gemfile.lock
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
datarockets-style (1.1.0)
|
5
|
-
rubocop (>= 1.2, < 2.0)
|
6
|
-
rubocop-rails (>= 2.8.0, < 2.10.0)
|
7
|
-
rubocop-rspec (~> 2.0)
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
activesupport (6.1.1)
|
13
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
-
i18n (>= 1.6, < 2)
|
15
|
-
minitest (>= 5.1)
|
16
|
-
tzinfo (~> 2.0)
|
17
|
-
zeitwerk (~> 2.3)
|
18
|
-
ast (2.4.2)
|
19
|
-
byebug (11.1.3)
|
20
|
-
coderay (1.1.2)
|
21
|
-
concurrent-ruby (1.1.7)
|
22
|
-
diff-lcs (1.4.4)
|
23
|
-
i18n (1.8.7)
|
24
|
-
concurrent-ruby (~> 1.0)
|
25
|
-
method_source (1.0.0)
|
26
|
-
minitest (5.14.3)
|
27
|
-
parallel (1.20.1)
|
28
|
-
parser (3.0.0.0)
|
29
|
-
ast (~> 2.4.1)
|
30
|
-
pry (0.13.1)
|
31
|
-
coderay (~> 1.1)
|
32
|
-
method_source (~> 1.0)
|
33
|
-
pry-byebug (3.9.0)
|
34
|
-
byebug (~> 11.0)
|
35
|
-
pry (~> 0.13.0)
|
36
|
-
rack (2.2.3)
|
37
|
-
rainbow (3.0.0)
|
38
|
-
rake (13.0.3)
|
39
|
-
regexp_parser (2.0.3)
|
40
|
-
rexml (3.2.4)
|
41
|
-
rspec (3.10.0)
|
42
|
-
rspec-core (~> 3.10.0)
|
43
|
-
rspec-expectations (~> 3.10.0)
|
44
|
-
rspec-mocks (~> 3.10.0)
|
45
|
-
rspec-core (3.10.0)
|
46
|
-
rspec-support (~> 3.10.0)
|
47
|
-
rspec-expectations (3.10.0)
|
48
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
-
rspec-support (~> 3.10.0)
|
50
|
-
rspec-mocks (3.10.0)
|
51
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
-
rspec-support (~> 3.10.0)
|
53
|
-
rspec-support (3.10.0)
|
54
|
-
rubocop (1.9.1)
|
55
|
-
parallel (~> 1.10)
|
56
|
-
parser (>= 3.0.0.0)
|
57
|
-
rainbow (>= 2.2.2, < 4.0)
|
58
|
-
regexp_parser (>= 1.8, < 3.0)
|
59
|
-
rexml
|
60
|
-
rubocop-ast (>= 1.2.0, < 2.0)
|
61
|
-
ruby-progressbar (~> 1.7)
|
62
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
63
|
-
rubocop-ast (1.4.1)
|
64
|
-
parser (>= 2.7.1.5)
|
65
|
-
rubocop-rails (2.9.1)
|
66
|
-
activesupport (>= 4.2.0)
|
67
|
-
rack (>= 1.1)
|
68
|
-
rubocop (>= 0.90.0, < 2.0)
|
69
|
-
rubocop-rspec (2.1.0)
|
70
|
-
rubocop (~> 1.0)
|
71
|
-
rubocop-ast (>= 1.1.0)
|
72
|
-
ruby-progressbar (1.11.0)
|
73
|
-
tzinfo (2.0.4)
|
74
|
-
concurrent-ruby (~> 1.0)
|
75
|
-
unicode-display_width (2.0.0)
|
76
|
-
zeitwerk (2.4.2)
|
77
|
-
|
78
|
-
PLATFORMS
|
79
|
-
ruby
|
80
|
-
|
81
|
-
DEPENDENCIES
|
82
|
-
datarockets-style!
|
83
|
-
pry-byebug
|
84
|
-
rake (~> 13.0)
|
85
|
-
rspec (~> 3.10)
|
86
|
-
|
87
|
-
BUNDLED WITH
|
88
|
-
2.1.4
|