datarockets-style 0.7.0 → 0.11.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/.github/ISSUE_TEMPLATE/update-dependencies.md +1 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +6 -1
- data/CHANGELOG.md +70 -1
- data/Gemfile.lock +49 -23
- data/README.md +9 -0
- data/config/base.yml +123 -18
- data/config/rails.yml +8 -1
- data/config/rspec.yml +4 -1
- data/datarockets-style.gemspec +4 -3
- data/doc/STYLE_GUIDE.md +13 -15
- data/doc/STYLE_GUIDE_RAILS.md +27 -1
- data/doc/STYLE_GUIDE_RSPEC.md +4 -0
- data/lib/datarockets/style.rb +1 -0
- data/lib/datarockets/style/cop/layout/array_alignment_extended.rb +9 -10
- data/lib/datarockets/style/cop/style/nested_interpolation.rb +37 -0
- data/lib/datarockets/style/formatter/todo_list_formatter.rb +2 -1
- data/lib/datarockets/style/formatter/todo_list_formatter/report_summary.rb +3 -3
- data/lib/datarockets/style/version.rb +1 -1
- data/manual/cops_layout.md +74 -0
- metadata +30 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 7fafb7c948730c343855a68d07997ccd3810e8167c2a015e8d36bc62f4d131ed
|
|
4
|
+
data.tar.gz: 9949285276625c8fc9c699b0cf81b95d571d33d48cc01d28079bfa389a550398
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 257dfbd765bb44afca6141ad304c8be3140d7b3755b8a39755a5a5d335cc01422cad573ddbd5aab99067a65703b7933a073f53bd7b0a276f8340f42a31a426a5
|
|
7
|
+
data.tar.gz: 54a27bdd31588eda01c775ec316886fc835f29d714b5a848f858ba828a73e8c845ea2e524231bf8dd31779bc1fb788e90e28b44de0ba94eb1574d957b97a2a31
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,76 @@
|
|
|
2
2
|
|
|
3
3
|
The format is described in [Contributing notes](CONTRIBUTING.md#changelog-entry-format).
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 0.11.0 (2020-11-07)
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
* Update rubocop to '0.93.1'. ([@r.dubrovsky][])
|
|
10
|
+
* Enable new cops `Lint/BinaryOperatorWithIdenticalOperands`, `Lint/DuplicateRescueException`, `Lint/EmptyConditionalBody`, `Lint/FloatComparison`, `Lint/MissingSuper
|
|
11
|
+
`, `Lint/OutOfRangeRegexpRef`, `Lint/SelfAssignment`, `Lint/TopLevelReturnWithArgument`, `Lint/UnreachableLoop`, `Style/ExplicitBlockArgument`, `Style/GlobalStdStream`, `Style/OptionalBooleanParameter`, `Style/SingleArgumentDig`, `Style/SoleNestedConditional` and `Style/StringConcatenation` in version `0.89`.
|
|
12
|
+
* Allow to add all new lints automatically.
|
|
13
|
+
* Add auto-correctable count notification.
|
|
14
|
+
* Fix tests
|
|
15
|
+
* Update rubocop-rails to `2.7.1`.
|
|
16
|
+
* Update rubocop-rspec tp `1.43.2`.
|
|
17
|
+
* Disable `RSpec/MultipleMemoizedHelpers` cop.
|
|
18
|
+
|
|
19
|
+
## 0.10.0 (2020-07-17)
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
* Update rubocop to `0.88.0`. ([@r.dubrovsky][])
|
|
24
|
+
* Enable new cops `Lint/MixedRegexpCaptureTypes`, `Style/RedundantRegexpCharacterClass` and `Style/RedundantRegexpEscape`. Cops were added in version `0.85`.
|
|
25
|
+
* Enable new cop `Style/RedundantFetchBlock`. Cop was added in version `0.86`.
|
|
26
|
+
* Enable new cops `Style/AccessorGrouping`, `Style/BisectedAttrAccessor` and `Style/RedundantAssignment`. Cops were added in version `0.87`.
|
|
27
|
+
* Enable new cops `Lint/DuplicateElsifCondition`, `Style/ArrayCoercion`, `Style/CaseLikeIf`, `Style/HashAsLastArrayItem`, `Style/HashLikeCase` and `Style/RedundantFileExtensionInRequire`. Cops were added in version `0.88`.
|
|
28
|
+
* Update rubocop-rails to `2.6.0`.
|
|
29
|
+
* Update rubocop-rspec to `1.42.0`.
|
|
30
|
+
|
|
31
|
+
* Setup `no_braces` rule for `Style/HashAsLastArrayItem` cop which added in the rubocop version `0.88`.
|
|
32
|
+
|
|
33
|
+
## 0.9.0 (2020-05-27)
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
* **(Breaking)** Drop support for Ruby 2.3. ([@r.dubrovsky][])
|
|
38
|
+
|
|
39
|
+
* Update rubocop to `0.84.0`. ([@r.dubrovsky][])
|
|
40
|
+
* Enable new cops `Lint/RaiseException` and `Lint/StructNewOverride`. Cops were added in version `0.81`.
|
|
41
|
+
* Enable new cops `Layout/SpaceAroundMethodCallOperator` and `Style/ExponentialNotation`. Cops were added in version `0.82`.
|
|
42
|
+
* Enable new cops `Layout/EmptyLinesAroundAttributeAccessor` and `Style/SlicingWithRange`. Cops were added in version `0.83`.
|
|
43
|
+
* Enable new cop `Lint/DeprecatedOpenSSLConstant`. Cop was added in version `0.84`.
|
|
44
|
+
|
|
45
|
+
* Update rubocop-rails to `2.5.2`.
|
|
46
|
+
* Update rubocop-rspec to `1.39`.
|
|
47
|
+
* Update `activesupport` for fixing security issues.
|
|
48
|
+
|
|
49
|
+
## 0.8.1 (2020-03-02)
|
|
50
|
+
|
|
51
|
+
### Changed
|
|
52
|
+
|
|
53
|
+
* Update rubocop to `0.80.1`.
|
|
54
|
+
|
|
55
|
+
## 0.8.0 (2020-02-20)
|
|
56
|
+
|
|
57
|
+
### Added
|
|
58
|
+
|
|
59
|
+
* Add `Style/NestedInterpolation` cop. ([@r.dubrovsky][])
|
|
60
|
+
|
|
61
|
+
### Changed
|
|
62
|
+
|
|
63
|
+
* Update rubocop to `0.80.0`. ([@r.dubrovsky][])
|
|
64
|
+
* Add `Style/HashEachMethods`, `Style/HashTransformKey`, `Style/HashTransformValues` cops.
|
|
65
|
+
* [#7641](https://github.com/rubocop-hq/rubocop/issues/7641): Remove `Style/BracesAroundHashParameters` cop.
|
|
66
|
+
|
|
67
|
+
* Update rubocop-rspec to `1.38.1`.
|
|
68
|
+
* Add RSpec/RepeatedExampleGroupBody cop. ([@ula][])
|
|
69
|
+
* Add RSpec/RepeatedExampleGroupDescription cop. ([@ula][])
|
|
70
|
+
|
|
71
|
+
* Enable `rubocop-rails` cops for rails config. ([@ula][])
|
|
72
|
+
* Setup `Style/Documentation` for rails config. ([@r.dubrovsky][])
|
|
73
|
+
* Setup `Style/ClassAndModuleChildren` cop. ([@r.dubrovsky][])
|
|
74
|
+
* Enable `RSpec/LetSetup` cop. ([@r.dubrovsky][])
|
|
6
75
|
|
|
7
76
|
## 0.7.0 (2020-01-27)
|
|
8
77
|
|
data/Gemfile.lock
CHANGED
|
@@ -1,30 +1,43 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
datarockets-style (0.
|
|
5
|
-
rubocop (~> 0.
|
|
6
|
-
rubocop-
|
|
4
|
+
datarockets-style (0.11.0)
|
|
5
|
+
rubocop (~> 0.93)
|
|
6
|
+
rubocop-rails (>= 2.6.0, < 2.8.0)
|
|
7
|
+
rubocop-rspec (~> 1.42)
|
|
7
8
|
|
|
8
9
|
GEM
|
|
9
10
|
remote: https://rubygems.org/
|
|
10
11
|
specs:
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
activesupport (6.0.3.4)
|
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
14
|
+
i18n (>= 0.7, < 2)
|
|
15
|
+
minitest (~> 5.1)
|
|
16
|
+
tzinfo (~> 1.1)
|
|
17
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
|
18
|
+
ast (2.4.1)
|
|
19
|
+
byebug (11.1.3)
|
|
13
20
|
coderay (1.1.2)
|
|
21
|
+
concurrent-ruby (1.1.7)
|
|
14
22
|
diff-lcs (1.3)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
i18n (1.8.5)
|
|
24
|
+
concurrent-ruby (~> 1.0)
|
|
25
|
+
method_source (1.0.0)
|
|
26
|
+
minitest (5.14.2)
|
|
27
|
+
parallel (1.19.2)
|
|
28
|
+
parser (2.7.2.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)
|
|
24
34
|
byebug (~> 11.0)
|
|
25
|
-
pry (~> 0.
|
|
35
|
+
pry (~> 0.13.0)
|
|
36
|
+
rack (2.2.3)
|
|
26
37
|
rainbow (3.0.0)
|
|
27
38
|
rake (13.0.1)
|
|
39
|
+
regexp_parser (1.8.2)
|
|
40
|
+
rexml (3.2.4)
|
|
28
41
|
rspec (3.9.0)
|
|
29
42
|
rspec-core (~> 3.9.0)
|
|
30
43
|
rspec-expectations (~> 3.9.0)
|
|
@@ -38,17 +51,30 @@ GEM
|
|
|
38
51
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
39
52
|
rspec-support (~> 3.9.0)
|
|
40
53
|
rspec-support (3.9.0)
|
|
41
|
-
rubocop (0.
|
|
42
|
-
jaro_winkler (~> 1.5.1)
|
|
54
|
+
rubocop (0.93.1)
|
|
43
55
|
parallel (~> 1.10)
|
|
44
|
-
parser (>= 2.7.
|
|
56
|
+
parser (>= 2.7.1.5)
|
|
45
57
|
rainbow (>= 2.2.2, < 4.0)
|
|
58
|
+
regexp_parser (>= 1.8)
|
|
59
|
+
rexml
|
|
60
|
+
rubocop-ast (>= 0.6.0)
|
|
46
61
|
ruby-progressbar (~> 1.7)
|
|
47
|
-
unicode-display_width (>= 1.4.0, <
|
|
48
|
-
rubocop-
|
|
49
|
-
|
|
62
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
63
|
+
rubocop-ast (1.1.1)
|
|
64
|
+
parser (>= 2.7.1.5)
|
|
65
|
+
rubocop-rails (2.7.1)
|
|
66
|
+
activesupport (>= 4.2.0)
|
|
67
|
+
rack (>= 1.1)
|
|
68
|
+
rubocop (>= 0.87.0)
|
|
69
|
+
rubocop-rspec (1.44.1)
|
|
70
|
+
rubocop (~> 0.87)
|
|
71
|
+
rubocop-ast (>= 0.7.1)
|
|
50
72
|
ruby-progressbar (1.10.1)
|
|
51
|
-
|
|
73
|
+
thread_safe (0.3.6)
|
|
74
|
+
tzinfo (1.2.7)
|
|
75
|
+
thread_safe (~> 0.1)
|
|
76
|
+
unicode-display_width (1.7.0)
|
|
77
|
+
zeitwerk (2.4.1)
|
|
52
78
|
|
|
53
79
|
PLATFORMS
|
|
54
80
|
ruby
|
|
@@ -60,4 +86,4 @@ DEPENDENCIES
|
|
|
60
86
|
rspec (~> 3.7)
|
|
61
87
|
|
|
62
88
|
BUNDLED WITH
|
|
63
|
-
1.
|
|
89
|
+
2.1.4
|
data/README.md
CHANGED
|
@@ -76,6 +76,11 @@ There are some areas in which there is no clear consensus in datarockets team re
|
|
|
76
76
|
In such scenarios, all popular styles are acknowledged and it’s up to you to pick one and apply it consistently.
|
|
77
77
|
For that just set up these cops before starting of usage.
|
|
78
78
|
|
|
79
|
+
#### RSpec/LetSetup
|
|
80
|
+
|
|
81
|
+
[This cop](https://rubocop-rspec.readthedocs.io/en/latest/cops_rspec/#rspecletsetup) is enabled by default and we suggest not to use unreferenced `let` variables in your test cases.
|
|
82
|
+
However, if it feels like the cop should be enabled and tests can't be written w/o them, please create an issue with your cases so that we can re-thinking our solution about enabling this cop.
|
|
83
|
+
|
|
79
84
|
#### Style/StringLiterals
|
|
80
85
|
|
|
81
86
|
There are two popular styles in the Ruby community, both of which are considered good - single quotes by default and double quotes by default.
|
|
@@ -88,6 +93,10 @@ P.S. The string literals in this gem are using double quotes by default.
|
|
|
88
93
|
|
|
89
94
|
For an existing project, we suggest running rubocop with both styles and choose which has fewer offenses (which is more popular in the current project).
|
|
90
95
|
|
|
96
|
+
### Custom cops
|
|
97
|
+
|
|
98
|
+
We have custom cops. You can find specification for them [here](manual).
|
|
99
|
+
|
|
91
100
|
## Formatters
|
|
92
101
|
|
|
93
102
|
### ToDo list formatter
|
data/config/base.yml
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
require: datarockets/style
|
|
2
2
|
|
|
3
|
+
AllCops:
|
|
4
|
+
NewCops: enable
|
|
5
|
+
|
|
3
6
|
Bundler/DuplicatedGem:
|
|
4
7
|
Enabled: true
|
|
5
8
|
|
|
@@ -16,28 +19,12 @@ Layout/ArrayAlignmentExtended:
|
|
|
16
19
|
Description: >-
|
|
17
20
|
Align the elements of an array literal if they span more than
|
|
18
21
|
one line.
|
|
19
|
-
# Alignment of elements of a multi-line array.
|
|
20
|
-
#
|
|
21
|
-
# The `with_first_parameter` style aligns the following lines along the same
|
|
22
|
-
# column as the first element.
|
|
23
|
-
#
|
|
24
|
-
# array = [1, 2, 3,
|
|
25
|
-
# 4, 5, 6]
|
|
26
|
-
#
|
|
27
|
-
# The `with_fixed_indentation` style aligns the following lines with one
|
|
28
|
-
# level of indentation relative to the start of the line with start of array.
|
|
29
|
-
#
|
|
30
|
-
# array = [1, 2, 3,
|
|
31
|
-
# 4, 5, 6]
|
|
32
22
|
EnforcedStyle: with_fixed_indentation
|
|
33
23
|
SupportedStyles:
|
|
34
24
|
- with_first_parameter
|
|
35
25
|
- with_fixed_indentation
|
|
36
|
-
# By default, the indentation width from Layout/IndentationWidth is used
|
|
37
|
-
# But it can be overridden by setting this parameter
|
|
38
26
|
IndentationWidth: ~
|
|
39
27
|
|
|
40
|
-
|
|
41
28
|
Layout/HashAlignment:
|
|
42
29
|
EnforcedLastArgumentHashStyle: always_ignore
|
|
43
30
|
|
|
@@ -45,6 +32,9 @@ Layout/ParameterAlignment:
|
|
|
45
32
|
EnforcedStyle: with_fixed_indentation
|
|
46
33
|
IndentationWidth: 2
|
|
47
34
|
|
|
35
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
|
36
|
+
Enabled: true
|
|
37
|
+
|
|
48
38
|
Layout/EndAlignment:
|
|
49
39
|
EnforcedStyleAlignWith: variable
|
|
50
40
|
|
|
@@ -60,24 +50,139 @@ Layout/FirstHashElementIndentation:
|
|
|
60
50
|
Layout/MultilineMethodCallIndentation:
|
|
61
51
|
EnforcedStyle: indented
|
|
62
52
|
|
|
53
|
+
Layout/SpaceAroundMethodCallOperator:
|
|
54
|
+
Enabled: true
|
|
55
|
+
|
|
63
56
|
Layout/SpaceInsideHashLiteralBraces:
|
|
64
57
|
EnforcedStyle: no_space
|
|
65
58
|
EnforcedStyleForEmptyBraces: no_space
|
|
66
59
|
|
|
60
|
+
Lint/BinaryOperatorWithIdenticalOperands:
|
|
61
|
+
Enabled: true
|
|
62
|
+
|
|
63
|
+
Lint/DeprecatedOpenSSLConstant:
|
|
64
|
+
Enabled: true
|
|
65
|
+
|
|
66
|
+
Lint/DuplicateElsifCondition:
|
|
67
|
+
Enabled: true
|
|
68
|
+
|
|
69
|
+
Lint/DuplicateRescueException:
|
|
70
|
+
Enabled: true
|
|
71
|
+
|
|
72
|
+
Lint/EmptyConditionalBody:
|
|
73
|
+
Enabled: true
|
|
74
|
+
|
|
75
|
+
Lint/FloatComparison:
|
|
76
|
+
Enabled: true
|
|
77
|
+
|
|
78
|
+
Lint/MissingSuper:
|
|
79
|
+
Enabled: true
|
|
80
|
+
|
|
81
|
+
Lint/MixedRegexpCaptureTypes:
|
|
82
|
+
Enabled: true
|
|
83
|
+
|
|
84
|
+
Lint/OutOfRangeRegexpRef:
|
|
85
|
+
Enabled: true
|
|
86
|
+
|
|
87
|
+
Lint/RaiseException:
|
|
88
|
+
Enabled: true
|
|
89
|
+
|
|
90
|
+
Lint/SelfAssignment:
|
|
91
|
+
Enabled: true
|
|
92
|
+
|
|
93
|
+
Lint/StructNewOverride:
|
|
94
|
+
Enabled: true
|
|
95
|
+
|
|
96
|
+
Lint/TopLevelReturnWithArgument:
|
|
97
|
+
Enabled: true
|
|
98
|
+
|
|
99
|
+
Lint/UnreachableLoop:
|
|
100
|
+
Enabled: true
|
|
101
|
+
|
|
67
102
|
Naming/MemoizedInstanceVariableName:
|
|
68
103
|
EnforcedStyleForLeadingUnderscores: required
|
|
69
104
|
|
|
70
105
|
Naming/RescuedExceptionsVariableName:
|
|
71
106
|
PreferredName: error
|
|
72
107
|
|
|
73
|
-
Style/
|
|
74
|
-
|
|
108
|
+
Style/AccessorGrouping:
|
|
109
|
+
Enabled: true
|
|
110
|
+
|
|
111
|
+
Style/ArrayCoercion:
|
|
112
|
+
Enabled: true
|
|
113
|
+
|
|
114
|
+
Style/BisectedAttrAccessor:
|
|
115
|
+
Enabled: true
|
|
116
|
+
|
|
117
|
+
Style/CaseLikeIf:
|
|
118
|
+
Enabled: true
|
|
119
|
+
|
|
120
|
+
Style/ClassAndModuleChildren:
|
|
121
|
+
EnforcedStyle: nested
|
|
75
122
|
|
|
76
123
|
Style/EmptyMethod:
|
|
77
124
|
EnforcedStyle: expanded
|
|
78
125
|
|
|
126
|
+
Style/ExplicitBlockArgument:
|
|
127
|
+
Enabled: true
|
|
128
|
+
|
|
129
|
+
Style/ExponentialNotation:
|
|
130
|
+
Enabled: true
|
|
131
|
+
|
|
132
|
+
Style/GlobalStdStream:
|
|
133
|
+
Enabled: true
|
|
134
|
+
|
|
135
|
+
Style/HashAsLastArrayItem:
|
|
136
|
+
Enabled: true
|
|
137
|
+
EnforcedStyle: no_braces
|
|
138
|
+
|
|
139
|
+
Style/HashEachMethods:
|
|
140
|
+
Enabled: true
|
|
141
|
+
|
|
142
|
+
Style/HashLikeCase:
|
|
143
|
+
Enabled: true
|
|
144
|
+
|
|
145
|
+
Style/HashTransformKeys:
|
|
146
|
+
Enabled: true
|
|
147
|
+
|
|
148
|
+
Style/HashTransformValues:
|
|
149
|
+
Enabled: true
|
|
150
|
+
|
|
79
151
|
Style/FrozenStringLiteralComment:
|
|
80
152
|
Enabled: false
|
|
81
153
|
|
|
154
|
+
Style/NestedInterpolation:
|
|
155
|
+
Enabled: true
|
|
156
|
+
|
|
157
|
+
Style/OptionalBooleanParameter:
|
|
158
|
+
Enabled: true
|
|
159
|
+
|
|
160
|
+
Style/RedundantAssignment:
|
|
161
|
+
Enabled: true
|
|
162
|
+
|
|
163
|
+
Style/RedundantFetchBlock:
|
|
164
|
+
Enabled: true
|
|
165
|
+
|
|
166
|
+
Style/RedundantFileExtensionInRequire:
|
|
167
|
+
Enabled: true
|
|
168
|
+
|
|
169
|
+
Style/RedundantRegexpCharacterClass:
|
|
170
|
+
Enabled: true
|
|
171
|
+
|
|
172
|
+
Style/RedundantRegexpEscape:
|
|
173
|
+
Enabled: true
|
|
174
|
+
|
|
175
|
+
Style/SingleArgumentDig:
|
|
176
|
+
Enabled: true
|
|
177
|
+
|
|
178
|
+
Style/SlicingWithRange:
|
|
179
|
+
Enabled: true
|
|
180
|
+
|
|
181
|
+
Style/SoleNestedConditional:
|
|
182
|
+
Enabled: true
|
|
183
|
+
|
|
184
|
+
Style/StringConcatenation:
|
|
185
|
+
Enabled: true
|
|
186
|
+
|
|
82
187
|
Style/StringLiterals:
|
|
83
188
|
EnforcedStyle: double_quotes
|
data/config/rails.yml
CHANGED
data/config/rspec.yml
CHANGED
|
@@ -26,10 +26,13 @@ RSpec/ImplicitSubject:
|
|
|
26
26
|
Enabled: false
|
|
27
27
|
|
|
28
28
|
RSpec/LetSetup:
|
|
29
|
-
Enabled:
|
|
29
|
+
Enabled: true
|
|
30
30
|
|
|
31
31
|
RSpec/MessageSpies:
|
|
32
32
|
EnforcedStyle: have_received
|
|
33
33
|
|
|
34
|
+
RSpec/MultipleMemoizedHelpers:
|
|
35
|
+
Enabled: false
|
|
36
|
+
|
|
34
37
|
RSpec/NestedGroups:
|
|
35
38
|
Enabled: false
|
data/datarockets-style.gemspec
CHANGED
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
|
12
12
|
spec.homepage = "https://github.com/datarockets/datarockets-style"
|
|
13
13
|
spec.license = "MIT"
|
|
14
14
|
|
|
15
|
-
spec.required_ruby_version = ">= 2.
|
|
15
|
+
spec.required_ruby_version = ">= 2.4.0"
|
|
16
16
|
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
18
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
|
30
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
31
31
|
spec.require_paths = ["lib"]
|
|
32
32
|
|
|
33
|
-
spec.add_dependency "rubocop", "~> 0.
|
|
34
|
-
spec.add_dependency "rubocop-
|
|
33
|
+
spec.add_dependency "rubocop", "~> 0.93"
|
|
34
|
+
spec.add_dependency "rubocop-rails", ">= 2.6.0", "< 2.8.0"
|
|
35
|
+
spec.add_dependency "rubocop-rspec", "~> 1.42"
|
|
35
36
|
end
|
data/doc/STYLE_GUIDE.md
CHANGED
|
@@ -35,6 +35,19 @@ This is a small list of differences which we have when compared with community s
|
|
|
35
35
|
Adopt a consistent string literal quoting style.
|
|
36
36
|
<sup>[[link](#style-string-quotes)]</sup>
|
|
37
37
|
|
|
38
|
+
* <a name="style-nested-interpolation"></a>
|
|
39
|
+
Avoid using nested interpolation.
|
|
40
|
+
<sup>[[link](#style-nested-interpolation)]</sup>
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
# bad
|
|
44
|
+
"Hello, #{user.blank? ? 'guest' : "dear #{user.name}"}"
|
|
45
|
+
|
|
46
|
+
# good
|
|
47
|
+
user_name = user.blank? ? 'guest' : "dear #{user.name}"
|
|
48
|
+
"Hello, #{user_name}"
|
|
49
|
+
```
|
|
50
|
+
|
|
38
51
|
* <a name="style-hash-aligning"></a>
|
|
39
52
|
If elements of a hash literal span more than one line, we're aligning them by keys.
|
|
40
53
|
Also, the first hash key is aligned by an indentation level.
|
|
@@ -384,18 +397,3 @@ end
|
|
|
384
397
|
Set up [this cop](https://rubocop.readthedocs.io/en/latest/cops_style/#stylefrozenstringliteralcomment) depends on the project.
|
|
385
398
|
So set up it on the local rubocop config manually.
|
|
386
399
|
<sup>[[link](#style-magic-link)]</sup>
|
|
387
|
-
|
|
388
|
-
* <a name="style-braces-around-hash-params"></a>
|
|
389
|
-
Not to use braces around the last hash literal parameter.
|
|
390
|
-
But requires braces if the second to last parameter is also a hash literal.
|
|
391
|
-
<sup>[[link](#style-braces-around-hash-params)]</sup>
|
|
392
|
-
|
|
393
|
-
```ruby
|
|
394
|
-
# bad
|
|
395
|
-
some_method(x, y, {a: 1, b: 2})
|
|
396
|
-
some_method(x, y, {a: 1, b: 2}, a: 1, b: 2)
|
|
397
|
-
|
|
398
|
-
# good
|
|
399
|
-
some_method(x, y, a: 1, b: 2)
|
|
400
|
-
some_method(x, y, {a: 1, b: 2}, {a: 1, b: 2})
|
|
401
|
-
```
|
data/doc/STYLE_GUIDE_RAILS.md
CHANGED
|
@@ -4,6 +4,32 @@ This style is based on rules from [Ruby Style Guide](docs/STYLE_GUIDE.md). Also,
|
|
|
4
4
|
|
|
5
5
|
This is a small list of differences which we have when compared with community and our Ruby style guides:
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Table of contents
|
|
8
|
+
|
|
9
|
+
* [Style](#Style)
|
|
10
|
+
|
|
11
|
+
## Style
|
|
12
|
+
|
|
13
|
+
* <a name="documentation"></a>
|
|
14
|
+
Documentation is requeried for all files except `app` directory.
|
|
15
|
+
<sup>[[link](#documentation)]</sup>
|
|
16
|
+
|
|
17
|
+
* <a name="nested-style-and-modules"></a>
|
|
18
|
+
Prefer to use nested style of children definitions at classes and modules.
|
|
19
|
+
<sup>[[link](#nested-style-and-modules)]</sup>
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
# bad
|
|
23
|
+
class Api::V1::UsersController
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# good
|
|
27
|
+
module Api
|
|
28
|
+
module V1
|
|
29
|
+
class UsersController
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
```
|
|
8
34
|
|
|
9
35
|
[1]: https://github.com/rubocop-hq/rails-style-guide
|
data/doc/STYLE_GUIDE_RSPEC.md
CHANGED
|
@@ -15,6 +15,10 @@ This style guide recommends best practices for writing a clear Rspec tests and e
|
|
|
15
15
|
So there are not any limits for deep or nested groups.
|
|
16
16
|
<sup>[[link](#rspec-nested-groups)]</sup>
|
|
17
17
|
|
|
18
|
+
* <a name="rspec-let-count"></a>
|
|
19
|
+
We're not limiting a number of `let` blocks in describe and context blocks.
|
|
20
|
+
<sup>[[link](#rspec-let-count)]</sup>
|
|
21
|
+
|
|
18
22
|
* <a name="rspec-subject"></a>
|
|
19
23
|
Each subject should be named, and we should not use `subject` in our test cases.
|
|
20
24
|
Prefer to use `is_expected` that `expect(subject_name)` for small tests.
|
data/lib/datarockets/style.rb
CHANGED
|
@@ -4,6 +4,7 @@ require "datarockets/style/formatter/todo_list_formatter"
|
|
|
4
4
|
require "datarockets/style/version"
|
|
5
5
|
|
|
6
6
|
require "datarockets/style/cop/layout/array_alignment_extended"
|
|
7
|
+
require "datarockets/style/cop/style/nested_interpolation"
|
|
7
8
|
|
|
8
9
|
module Datarockets
|
|
9
10
|
# Datarickors sharable config
|
|
@@ -37,8 +37,7 @@ module Datarockets
|
|
|
37
37
|
class ArrayAlignmentExtended < RuboCop::Cop::Cop
|
|
38
38
|
include RuboCop::Cop::Alignment
|
|
39
39
|
|
|
40
|
-
ALIGN_PARAMS_MSG = "Align the elements of an array literal if they span more "
|
|
41
|
-
"than one line."
|
|
40
|
+
ALIGN_PARAMS_MSG = "Align the elements of an array literal if they span more than one line."
|
|
42
41
|
|
|
43
42
|
FIXED_INDENT_MSG = "Use one level of indentation for elements " \
|
|
44
43
|
"following the first line of a multi-line array."
|
|
@@ -64,14 +63,14 @@ module Datarockets
|
|
|
64
63
|
end
|
|
65
64
|
|
|
66
65
|
def base_column(node, args)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
fixed_indentation? ? line_indentation(node) : display_column(args.first.source_range)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def line_indentation(node)
|
|
70
|
+
lineno = target_method_lineno(node)
|
|
71
|
+
line = node.source_range.source_buffer.source_line(lineno)
|
|
72
|
+
line_indentation = /\S.*/.match(line).begin(0)
|
|
73
|
+
line_indentation + configured_indentation_width
|
|
75
74
|
end
|
|
76
75
|
|
|
77
76
|
def target_method_lineno(node)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module Datarockets
|
|
2
|
+
module Style
|
|
3
|
+
module Cop
|
|
4
|
+
module Style
|
|
5
|
+
# This cop checks nested interpolations
|
|
6
|
+
#
|
|
7
|
+
# @example
|
|
8
|
+
#
|
|
9
|
+
# # bad
|
|
10
|
+
# "Hello, #{user.blank? ? 'guest' : "dear #{user.name}"}"
|
|
11
|
+
#
|
|
12
|
+
# # good
|
|
13
|
+
# user_name = user.blank? ? 'guest' : "dear #{user.name}"
|
|
14
|
+
# "Hello, #{user_name}"
|
|
15
|
+
class NestedInterpolation < RuboCop::Cop::Cop
|
|
16
|
+
include RuboCop::Cop::Interpolation
|
|
17
|
+
|
|
18
|
+
MSG = "Redundant nested interpolation.".freeze
|
|
19
|
+
|
|
20
|
+
def on_interpolation(node)
|
|
21
|
+
node.each_descendant(:dstr) do |descendant_node|
|
|
22
|
+
detect_double_interpolation(descendant_node)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def detect_double_interpolation(node)
|
|
29
|
+
node.each_child_node(:begin) do |begin_node|
|
|
30
|
+
add_offense(begin_node)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -42,7 +42,8 @@ class TodoListFormatter < RuboCop::Formatter::ProgressFormatter
|
|
|
42
42
|
def finished(inspected_files)
|
|
43
43
|
report_summary(inspected_files.length,
|
|
44
44
|
@total_offense_count,
|
|
45
|
-
@total_correction_count
|
|
45
|
+
@total_correction_count,
|
|
46
|
+
@total_correctable_count)
|
|
46
47
|
output.puts
|
|
47
48
|
|
|
48
49
|
Datarockets::Style::Formatter::TodoListFormatter::ReportSummary.new(offense_list).call(output)
|
|
@@ -13,9 +13,9 @@ module Datarockets
|
|
|
13
13
|
class ReportSummary
|
|
14
14
|
attr_reader :offense_list
|
|
15
15
|
|
|
16
|
-
FileGroup = Struct.new(:file, :
|
|
16
|
+
FileGroup = Struct.new(:file, :offenses_count) do
|
|
17
17
|
def print(output)
|
|
18
|
-
output.puts " - '#{file}' # #{
|
|
18
|
+
output.puts " - '#{file}' # #{offenses_count}"
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -27,7 +27,7 @@ module Datarockets
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def print(output)
|
|
30
|
-
output.puts(cop_name
|
|
30
|
+
output.puts("#{cop_name}:")
|
|
31
31
|
output.puts(" Exclude:")
|
|
32
32
|
file_groups.sort_by(&:file).each do |file_group|
|
|
33
33
|
file_group.print(output)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Layout
|
|
2
|
+
|
|
3
|
+
## Layout/ArrayAlignmentExtended
|
|
4
|
+
|
|
5
|
+
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
|
6
|
+
--- | --- | --- | --- | ---
|
|
7
|
+
Enabled | Yes | Yes | 0.7.0 | -
|
|
8
|
+
|
|
9
|
+
Here we check if the elements of a multi-line array literal are
|
|
10
|
+
aligned.
|
|
11
|
+
|
|
12
|
+
### Examples
|
|
13
|
+
|
|
14
|
+
#### EnforcedStyle: with_fixed_indentation (default)
|
|
15
|
+
|
|
16
|
+
```ruby
|
|
17
|
+
# good
|
|
18
|
+
|
|
19
|
+
array = [1, 2, 3,
|
|
20
|
+
4, 5, 6]
|
|
21
|
+
|
|
22
|
+
# bad
|
|
23
|
+
|
|
24
|
+
array = [1, 2, 3,
|
|
25
|
+
4, 5, 6]
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
#### EnforcedStyle: with_first_argument
|
|
29
|
+
|
|
30
|
+
```ruby
|
|
31
|
+
# good
|
|
32
|
+
|
|
33
|
+
array = [1, 2, 3,
|
|
34
|
+
4, 5, 6]
|
|
35
|
+
array = ['run',
|
|
36
|
+
'forrest',
|
|
37
|
+
'run']
|
|
38
|
+
|
|
39
|
+
# bad
|
|
40
|
+
|
|
41
|
+
array = [1, 2, 3,
|
|
42
|
+
4, 5, 6]
|
|
43
|
+
array = ['run',
|
|
44
|
+
'forrest',
|
|
45
|
+
'run']
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Configurable attributes
|
|
49
|
+
|
|
50
|
+
Name | Default value | Configurable values
|
|
51
|
+
--- | --- | ---
|
|
52
|
+
EnforcedStyle | `with_first_parameter` | `with_first_parameter`, `with_fixed_indentation`
|
|
53
|
+
IndentationWidth | `<none>` | Integer
|
|
54
|
+
|
|
55
|
+
# Style
|
|
56
|
+
|
|
57
|
+
## Style/NestedInterpolation
|
|
58
|
+
|
|
59
|
+
Enabled by default | Safe | Supports autocorrection | VersionAdded | VersionChanged
|
|
60
|
+
--- | --- | --- | --- | ---
|
|
61
|
+
Enabled | Yes | No | 0.8.0 | -
|
|
62
|
+
|
|
63
|
+
This cop checks nested interpolations
|
|
64
|
+
|
|
65
|
+
### Example
|
|
66
|
+
|
|
67
|
+
```ruby
|
|
68
|
+
# bad
|
|
69
|
+
"Hello, #{user.blank? ? 'guest' : "dear #{user.name}"}"
|
|
70
|
+
|
|
71
|
+
# good
|
|
72
|
+
user_name = user.blank? ? 'guest' : "dear #{user.name}"
|
|
73
|
+
"Hello, #{user_name}"
|
|
74
|
+
```
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: datarockets-style
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.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: 2020-
|
|
11
|
+
date: 2020-11-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rubocop
|
|
@@ -16,28 +16,48 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0.
|
|
19
|
+
version: '0.93'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0.
|
|
26
|
+
version: '0.93'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rubocop-rails
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 2.6.0
|
|
34
|
+
- - "<"
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: 2.8.0
|
|
37
|
+
type: :runtime
|
|
38
|
+
prerelease: false
|
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: 2.6.0
|
|
44
|
+
- - "<"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: 2.8.0
|
|
27
47
|
- !ruby/object:Gem::Dependency
|
|
28
48
|
name: rubocop-rspec
|
|
29
49
|
requirement: !ruby/object:Gem::Requirement
|
|
30
50
|
requirements:
|
|
31
51
|
- - "~>"
|
|
32
52
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '1.
|
|
53
|
+
version: '1.42'
|
|
34
54
|
type: :runtime
|
|
35
55
|
prerelease: false
|
|
36
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
57
|
requirements:
|
|
38
58
|
- - "~>"
|
|
39
59
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '1.
|
|
60
|
+
version: '1.42'
|
|
41
61
|
description:
|
|
42
62
|
email:
|
|
43
63
|
- r.dubrovsky@datarockets.com
|
|
@@ -74,9 +94,11 @@ files:
|
|
|
74
94
|
- doc/STYLE_GUIDE_RSPEC.md
|
|
75
95
|
- lib/datarockets/style.rb
|
|
76
96
|
- lib/datarockets/style/cop/layout/array_alignment_extended.rb
|
|
97
|
+
- lib/datarockets/style/cop/style/nested_interpolation.rb
|
|
77
98
|
- lib/datarockets/style/formatter/todo_list_formatter.rb
|
|
78
99
|
- lib/datarockets/style/formatter/todo_list_formatter/report_summary.rb
|
|
79
100
|
- lib/datarockets/style/version.rb
|
|
101
|
+
- manual/cops_layout.md
|
|
80
102
|
homepage: https://github.com/datarockets/datarockets-style
|
|
81
103
|
licenses:
|
|
82
104
|
- MIT
|
|
@@ -90,15 +112,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
90
112
|
requirements:
|
|
91
113
|
- - ">="
|
|
92
114
|
- !ruby/object:Gem::Version
|
|
93
|
-
version: 2.
|
|
115
|
+
version: 2.4.0
|
|
94
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
117
|
requirements:
|
|
96
118
|
- - ">="
|
|
97
119
|
- !ruby/object:Gem::Version
|
|
98
120
|
version: '0'
|
|
99
121
|
requirements: []
|
|
100
|
-
|
|
101
|
-
rubygems_version: 2.6.14
|
|
122
|
+
rubygems_version: 3.1.2
|
|
102
123
|
signing_key:
|
|
103
124
|
specification_version: 4
|
|
104
125
|
summary: Datarockets style guides and shared style configs
|