datarockets-style 0.8.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4f7d9668fbc210ee4a62d6e430941cb41f0c76f1
4
- data.tar.gz: f940fdde78d921b6fed3ebe586c136525a986397
2
+ SHA256:
3
+ metadata.gz: 7ef40260e95ced035f4c8f86b18c807997a4e79228c72e75a880477fecb8030e
4
+ data.tar.gz: b35d77e092533855df4092585e8af229653859c6cce685bed399f50880d5bc49
5
5
  SHA512:
6
- metadata.gz: c78d9af47a6f03ea18358b9a41547fd6e5afd61aa51abffb3ee5319cb5c3762359e5bb2b611387abfe4f9c7bbf5beafbaa3573c5b418ee9c00f1b865dea5f840
7
- data.tar.gz: 72897ad0da40c29848d78a0663004fcb968c51e67f84a6480e0c6953b2a35cc83949bfae4aba2bbe84575bfb842959da9cc0e806e2f5b5ffb010cdaa83b33b25
6
+ metadata.gz: a8b0a2bcb81d48837a708f337e3f37baba4e26d86f1be42fa02c12f441e18286b1164996a0a0026f870886a887c7664300683de2b80dee0e7fc6c4721934fce2
7
+ data.tar.gz: 0dd7f1c7bd2a72a7cbebe4fb5eaf4b399f53d014b0ecfe701be979917e09e7bc7467367d0dced76d25f9a76ad369b88da746285774e092b0078eea180209c913
@@ -14,3 +14,4 @@ To-Do list:
14
14
  - [ ] update dependencies to the latest version
15
15
  - [ ] investigate how it changes and affect our current styles and cops
16
16
  - [ ] check the required ruby version
17
+ - [ ] enable pending cops
data/.gitignore CHANGED
@@ -4,3 +4,6 @@
4
4
  /_yardoc/
5
5
  /pkg/
6
6
  /tmp/
7
+
8
+ .byebug_history
9
+ .idea
data/.rubocop.yml CHANGED
@@ -7,7 +7,7 @@ inherit_mode:
7
7
  - Exclude
8
8
 
9
9
  AllCops:
10
- TargetRubyVersion: 2.3
10
+ TargetRubyVersion: 2.4
11
11
 
12
12
  # for checking cops with interpolation
13
13
  Lint/InterpolationCheck:
data/CHANGELOG.md CHANGED
@@ -2,7 +2,73 @@
2
2
 
3
3
  The format is described in [Contributing notes](CONTRIBUTING.md#changelog-entry-format).
4
4
 
5
- ## master (unreleased)
5
+ ## master
6
+
7
+ ## 1.1.0 (2021-02-09)
8
+
9
+ ### Changed
10
+
11
+ * Setup `EnforcedStyleForMultiline` for `Style/TrailingCommaInHashLiteral` rule. ([@r.dubrovsky][])
12
+ * Update rubocop to ```1.9.1```.([@paydaylight][])
13
+ * Update rubocop-rails requirement to ```>= 2.8.0, < 2.10.0```. ([@paydaylight][])
14
+ * Update rubocop-rspec to `2.2.0`. ([@paydaylight][])
15
+ * Change ```Datarockets::Style``` module to ```DatarocketsStyle```. ([@paydaylight][])
16
+
17
+ ### Fixed
18
+
19
+ * [#177](https://github.com/datarockets/datarockets-style/issues/177) set ```Layout/MultilineOperationIndentation``` to indented ([@paydaylight][])
20
+
21
+ ## 1.0.0 (2020-11-10)
22
+
23
+ ### Changed
24
+
25
+ * Update rubocop to `1.2.0`.
26
+ * Update rubocop-rails to `2.8.1`.
27
+ * Update rubocop-rspec tp `2.0.0`.
28
+
29
+ ## 0.11.0 (2020-11-07)
30
+
31
+ ### Changed
32
+
33
+ * Update rubocop to '0.93.1'. ([@r.dubrovsky][])
34
+ * Enable new cops `Lint/BinaryOperatorWithIdenticalOperands`, `Lint/DuplicateRescueException`, `Lint/EmptyConditionalBody`, `Lint/FloatComparison`, `Lint/MissingSuper
35
+ `, `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`.
36
+ * Allow to add all new lints automatically.
37
+ * Add auto-correctable count notification.
38
+ * Fix tests
39
+ * Update rubocop-rails to `2.7.1`.
40
+ * Update rubocop-rspec tp `1.43.2`.
41
+ * Disable `RSpec/MultipleMemoizedHelpers` cop.
42
+
43
+ ## 0.10.0 (2020-07-17)
44
+
45
+ ### Changed
46
+
47
+ * Update rubocop to `0.88.0`. ([@r.dubrovsky][])
48
+ * Enable new cops `Lint/MixedRegexpCaptureTypes`, `Style/RedundantRegexpCharacterClass` and `Style/RedundantRegexpEscape`. Cops were added in version `0.85`.
49
+ * Enable new cop `Style/RedundantFetchBlock`. Cop was added in version `0.86`.
50
+ * Enable new cops `Style/AccessorGrouping`, `Style/BisectedAttrAccessor` and `Style/RedundantAssignment`. Cops were added in version `0.87`.
51
+ * Enable new cops `Lint/DuplicateElsifCondition`, `Style/ArrayCoercion`, `Style/CaseLikeIf`, `Style/HashAsLastArrayItem`, `Style/HashLikeCase` and `Style/RedundantFileExtensionInRequire`. Cops were added in version `0.88`.
52
+ * Update rubocop-rails to `2.6.0`.
53
+ * Update rubocop-rspec to `1.42.0`.
54
+
55
+ * Setup `no_braces` rule for `Style/HashAsLastArrayItem` cop which added in the rubocop version `0.88`.
56
+
57
+ ## 0.9.0 (2020-05-27)
58
+
59
+ ### Changed
60
+
61
+ * **(Breaking)** Drop support for Ruby 2.3. ([@r.dubrovsky][])
62
+
63
+ * Update rubocop to `0.84.0`. ([@r.dubrovsky][])
64
+ * Enable new cops `Lint/RaiseException` and `Lint/StructNewOverride`. Cops were added in version `0.81`.
65
+ * Enable new cops `Layout/SpaceAroundMethodCallOperator` and `Style/ExponentialNotation`. Cops were added in version `0.82`.
66
+ * Enable new cops `Layout/EmptyLinesAroundAttributeAccessor` and `Style/SlicingWithRange`. Cops were added in version `0.83`.
67
+ * Enable new cop `Lint/DeprecatedOpenSSLConstant`. Cop was added in version `0.84`.
68
+
69
+ * Update rubocop-rails to `2.5.2`.
70
+ * Update rubocop-rspec to `1.39`.
71
+ * Update `activesupport` for fixing security issues.
6
72
 
7
73
  ## 0.8.1 (2020-03-02)
8
74
 
@@ -155,4 +221,4 @@ The format is described in [Contributing notes](CONTRIBUTING.md#changelog-entry-
155
221
  [@v.kuzmik]: https://github.com/TheBlackArroVV/
156
222
  [@a.branzeanu]: https://github.com/texpert
157
223
  [@nikitasakov]: https://github.com/nikitasakov
158
-
224
+ [@paydaylight]: https://github.com/paydaylight
data/Gemfile CHANGED
@@ -6,4 +6,4 @@ gemspec
6
6
 
7
7
  gem "pry-byebug"
8
8
  gem "rake", "~> 13.0"
9
- gem "rspec", "~> 3.7"
9
+ gem "rspec", "~> 3.10"
data/Gemfile.lock CHANGED
@@ -1,61 +1,79 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- datarockets-style (0.8.1)
5
- rubocop (~> 0.80)
6
- rubocop-rails (~> 2.4)
7
- rubocop-rspec (~> 1.38)
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
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- ast (2.4.0)
13
- byebug (11.0.1)
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)
14
20
  coderay (1.1.2)
15
- diff-lcs (1.3)
16
- jaro_winkler (1.5.4)
17
- method_source (0.9.2)
18
- parallel (1.19.1)
19
- parser (2.7.0.4)
20
- ast (~> 2.4.0)
21
- pry (0.12.2)
22
- coderay (~> 1.1.0)
23
- method_source (~> 0.9.0)
24
- pry-byebug (3.7.0)
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)
25
34
  byebug (~> 11.0)
26
- pry (~> 0.10)
27
- rack (2.2.2)
35
+ pry (~> 0.13.0)
36
+ rack (2.2.3)
28
37
  rainbow (3.0.0)
29
- rake (13.0.1)
38
+ rake (13.0.3)
39
+ regexp_parser (2.0.3)
30
40
  rexml (3.2.4)
31
- rspec (3.9.0)
32
- rspec-core (~> 3.9.0)
33
- rspec-expectations (~> 3.9.0)
34
- rspec-mocks (~> 3.9.0)
35
- rspec-core (3.9.0)
36
- rspec-support (~> 3.9.0)
37
- rspec-expectations (3.9.0)
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)
38
48
  diff-lcs (>= 1.2.0, < 2.0)
39
- rspec-support (~> 3.9.0)
40
- rspec-mocks (3.9.0)
49
+ rspec-support (~> 3.10.0)
50
+ rspec-mocks (3.10.0)
41
51
  diff-lcs (>= 1.2.0, < 2.0)
42
- rspec-support (~> 3.9.0)
43
- rspec-support (3.9.0)
44
- rubocop (0.80.1)
45
- jaro_winkler (~> 1.5.1)
52
+ rspec-support (~> 3.10.0)
53
+ rspec-support (3.10.0)
54
+ rubocop (1.9.1)
46
55
  parallel (~> 1.10)
47
- parser (>= 2.7.0.1)
56
+ parser (>= 3.0.0.0)
48
57
  rainbow (>= 2.2.2, < 4.0)
58
+ regexp_parser (>= 1.8, < 3.0)
49
59
  rexml
60
+ rubocop-ast (>= 1.2.0, < 2.0)
50
61
  ruby-progressbar (~> 1.7)
51
- unicode-display_width (>= 1.4.0, < 1.7)
52
- rubocop-rails (2.4.2)
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)
53
67
  rack (>= 1.1)
54
- rubocop (>= 0.72.0)
55
- rubocop-rspec (1.38.1)
56
- rubocop (>= 0.68.1)
57
- ruby-progressbar (1.10.1)
58
- unicode-display_width (1.6.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)
59
77
 
60
78
  PLATFORMS
61
79
  ruby
@@ -64,7 +82,7 @@ DEPENDENCIES
64
82
  datarockets-style!
65
83
  pry-byebug
66
84
  rake (~> 13.0)
67
- rspec (~> 3.7)
85
+ rspec (~> 3.10)
68
86
 
69
87
  BUNDLED WITH
70
- 1.16.3
88
+ 2.1.4
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'
13
+ gem 'datarockets-style', '~> 1.0.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'
20
+ spec.add_development_dependency 'datarockets-style', '~> 1.0.0'
21
21
  ```
22
22
 
23
23
  And then execute:
data/RELEASING.md CHANGED
@@ -15,3 +15,19 @@ gem push *built_file*
15
15
  * Announce the new release,
16
16
  making sure to say "thank you" to the contributors
17
17
  who helped shape this version!
18
+
19
+ ## Versioning stragety
20
+
21
+ As versioning strategy, we're using SemVer: `MAJOR.MINOR.PATCH`
22
+
23
+ A `MAJOR` version must be incremented if there are any backward-incompatible breaking changes included in a release. This has the benefit of making it easy for anyone to quickly identify if a new version will work differently than a previous one.
24
+
25
+ Usually, we'll increment it on updating major versions of rubocop dependencies. Ideally, it should be synchronized with the major verion of `rubocop`.
26
+
27
+ The `MINOR` version must be incremented if backward-compatible functionality is introduced. In the strictest sense, this means you should be able to upgrade to a new minor version without experiencing any breaking changes.
28
+
29
+ Usually, we'll increment it on changing the list of cops, updating minor versions of dependencies.
30
+
31
+ The `PATCH` version is meant for backward-compatible bug fixes. You should expect no new functionality with a new patch version, only improvements.
32
+
33
+ Usually, we'll use it for updating patch versions of dependencies or fixing bugs of the last version. Changed rules of cops in most cases should be added to minor version.
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "datarockets/style"
4
+ require "datarockets_style"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
data/config/base.yml CHANGED
@@ -1,4 +1,7 @@
1
- require: datarockets/style
1
+ require: datarockets_style
2
+
3
+ AllCops:
4
+ NewCops: enable
2
5
 
3
6
  Bundler/DuplicatedGem:
4
7
  Enabled: true
@@ -29,6 +32,9 @@ Layout/ParameterAlignment:
29
32
  EnforcedStyle: with_fixed_indentation
30
33
  IndentationWidth: 2
31
34
 
35
+ Layout/EmptyLinesAroundAttributeAccessor:
36
+ Enabled: true
37
+
32
38
  Layout/EndAlignment:
33
39
  EnforcedStyleAlignWith: variable
34
40
 
@@ -44,25 +50,101 @@ Layout/FirstHashElementIndentation:
44
50
  Layout/MultilineMethodCallIndentation:
45
51
  EnforcedStyle: indented
46
52
 
53
+ Layout/MultilineOperationIndentation:
54
+ EnforcedStyle: indented
55
+
56
+ Layout/SpaceAroundMethodCallOperator:
57
+ Enabled: true
58
+
47
59
  Layout/SpaceInsideHashLiteralBraces:
48
60
  EnforcedStyle: no_space
49
61
  EnforcedStyleForEmptyBraces: no_space
50
62
 
63
+ Lint/BinaryOperatorWithIdenticalOperands:
64
+ Enabled: true
65
+
66
+ Lint/DeprecatedOpenSSLConstant:
67
+ Enabled: true
68
+
69
+ Lint/DuplicateElsifCondition:
70
+ Enabled: true
71
+
72
+ Lint/DuplicateRescueException:
73
+ Enabled: true
74
+
75
+ Lint/EmptyConditionalBody:
76
+ Enabled: true
77
+
78
+ Lint/FloatComparison:
79
+ Enabled: true
80
+
81
+ Lint/MissingSuper:
82
+ Enabled: true
83
+
84
+ Lint/MixedRegexpCaptureTypes:
85
+ Enabled: true
86
+
87
+ Lint/OutOfRangeRegexpRef:
88
+ Enabled: true
89
+
90
+ Lint/RaiseException:
91
+ Enabled: true
92
+
93
+ Lint/SelfAssignment:
94
+ Enabled: true
95
+
96
+ Lint/StructNewOverride:
97
+ Enabled: true
98
+
99
+ Lint/TopLevelReturnWithArgument:
100
+ Enabled: true
101
+
102
+ Lint/UnreachableLoop:
103
+ Enabled: true
104
+
51
105
  Naming/MemoizedInstanceVariableName:
52
106
  EnforcedStyleForLeadingUnderscores: required
53
107
 
54
108
  Naming/RescuedExceptionsVariableName:
55
109
  PreferredName: error
56
110
 
111
+ Style/AccessorGrouping:
112
+ Enabled: true
113
+
114
+ Style/ArrayCoercion:
115
+ Enabled: true
116
+
117
+ Style/BisectedAttrAccessor:
118
+ Enabled: true
119
+
120
+ Style/CaseLikeIf:
121
+ Enabled: true
122
+
57
123
  Style/ClassAndModuleChildren:
58
124
  EnforcedStyle: nested
59
125
 
60
126
  Style/EmptyMethod:
61
127
  EnforcedStyle: expanded
62
128
 
129
+ Style/ExplicitBlockArgument:
130
+ Enabled: true
131
+
132
+ Style/ExponentialNotation:
133
+ Enabled: true
134
+
135
+ Style/GlobalStdStream:
136
+ Enabled: true
137
+
138
+ Style/HashAsLastArrayItem:
139
+ Enabled: true
140
+ EnforcedStyle: no_braces
141
+
63
142
  Style/HashEachMethods:
64
143
  Enabled: true
65
144
 
145
+ Style/HashLikeCase:
146
+ Enabled: true
147
+
66
148
  Style/HashTransformKeys:
67
149
  Enabled: true
68
150
 
@@ -75,5 +157,38 @@ Style/FrozenStringLiteralComment:
75
157
  Style/NestedInterpolation:
76
158
  Enabled: true
77
159
 
160
+ Style/OptionalBooleanParameter:
161
+ Enabled: true
162
+
163
+ Style/RedundantAssignment:
164
+ Enabled: true
165
+
166
+ Style/RedundantFetchBlock:
167
+ Enabled: true
168
+
169
+ Style/RedundantFileExtensionInRequire:
170
+ Enabled: true
171
+
172
+ Style/RedundantRegexpCharacterClass:
173
+ Enabled: true
174
+
175
+ Style/RedundantRegexpEscape:
176
+ Enabled: true
177
+
178
+ Style/SingleArgumentDig:
179
+ Enabled: true
180
+
181
+ Style/SlicingWithRange:
182
+ Enabled: true
183
+
184
+ Style/SoleNestedConditional:
185
+ Enabled: true
186
+
187
+ Style/StringConcatenation:
188
+ Enabled: true
189
+
78
190
  Style/StringLiterals:
79
191
  EnforcedStyle: double_quotes
192
+
193
+ Style/TrailingCommaInHashLiteral:
194
+ EnforcedStyleForMultiline: comma
data/config/rails.yml CHANGED
@@ -1,5 +1,7 @@
1
1
  require: rubocop-rails
2
2
 
3
+ inherit_from: base.yml
4
+
3
5
  AllCops:
4
6
  Exclude:
5
7
  - "db/**/*"
@@ -12,8 +14,6 @@ AllCops:
12
14
  - "config.ru"
13
15
  - "Rakefile"
14
16
 
15
- inherit_from: base.yml
16
-
17
17
  Style/Documentation:
18
18
  Enabled: true
19
19
  Exclude:
data/config/rspec.yml CHANGED
@@ -31,5 +31,8 @@ RSpec/LetSetup:
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
@@ -1,10 +1,10 @@
1
1
  lib = File.expand_path("lib", __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "datarockets/style/version"
3
+ require "datarockets_style/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "datarockets-style"
7
- spec.version = Datarockets::Style::VERSION
7
+ spec.version = DatarocketsStyle::VERSION
8
8
  spec.authors = ["Roman Dubrovsky"]
9
9
  spec.email = ["r.dubrovsky@datarockets.com"]
10
10
 
@@ -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.3.0"
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,7 +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.80"
34
- spec.add_dependency "rubocop-rails", "~> 2.4"
35
- spec.add_dependency "rubocop-rspec", "~> 1.38"
33
+ spec.add_dependency "rubocop", ">= 1.2 ", "< 2.0"
34
+ spec.add_dependency "rubocop-rails", ">= 2.8.0", "< 2.10.0"
35
+ spec.add_dependency "rubocop-rspec", "~> 2.0"
36
36
  end
data/doc/STYLE_GUIDE.md CHANGED
@@ -392,6 +392,46 @@ def foo
392
392
  end
393
393
  ```
394
394
 
395
+ * <a name="style-trailing-comma-in-hash-literal"></a>
396
+ Requires a comma after the last item in a hash.
397
+ <sup>[[link](#style-trailing-comma-in-hash-literal)]</sup>
398
+
399
+ ```ruby
400
+ # bad
401
+ a = { foo: 1, bar: 2, }
402
+
403
+ # good
404
+ a = { foo: 1, bar: 2 }
405
+
406
+ # bad
407
+ a = {
408
+ foo: 1, bar: 2,
409
+ qux: 3,
410
+ }
411
+
412
+ # good
413
+ a = {
414
+ foo: 1, bar: 2,
415
+ qux: 3
416
+ }
417
+
418
+ # bad
419
+ a = {
420
+ foo: 1, bar: 2, qux: 3,
421
+ }
422
+
423
+ # good
424
+ a = {
425
+ foo: 1, bar: 2, qux: 3
426
+ }
427
+
428
+ # good
429
+ a = {
430
+ foo: 1,
431
+ bar: 2,
432
+ }
433
+ ```
434
+
395
435
  * <a name="style-magic-link"></a>
396
436
  There are not any required rules for `frozen_string_literal` magic url.
397
437
  Set up [this cop](https://rubocop.readthedocs.io/en/latest/cops_style/#stylefrozenstringliteralcomment) depends on the project.
@@ -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.
@@ -0,0 +1,12 @@
1
+ require "rubocop"
2
+ require "datarockets_style/formatter/todo_list_formatter"
3
+
4
+ require "datarockets_style/version"
5
+
6
+ require "datarockets_style/cop/layout/array_alignment_extended"
7
+ require "datarockets_style/cop/style/nested_interpolation"
8
+
9
+ # Top level module for datarockets-style
10
+ module DatarocketsStyle
11
+ # Datarickors sharable config
12
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DatarocketsStyle
4
+ module Cop
5
+ module Layout
6
+ # Here we check if the elements of a multi-line array literal are
7
+ # aligned.
8
+ #
9
+ # @example EnforcedStyle: with_first_argument (default)
10
+ # # good
11
+ #
12
+ # array = [1, 2, 3,
13
+ # 4, 5, 6]
14
+ # array = ['run',
15
+ # 'forrest',
16
+ # 'run']
17
+ #
18
+ # # bad
19
+ #
20
+ # array = [1, 2, 3,
21
+ # 4, 5, 6]
22
+ # array = ['run',
23
+ # 'forrest',
24
+ # 'run']
25
+ #
26
+ # @example EnforcedStyle: with_fixed_indentation
27
+ # # good
28
+ #
29
+ # array = [1, 2, 3,
30
+ # 4, 5, 6]
31
+ #
32
+ # # bad
33
+ #
34
+ # array = [1, 2, 3,
35
+ # 4, 5, 6]
36
+ class ArrayAlignmentExtended < RuboCop::Cop::Cop
37
+ include RuboCop::Cop::Alignment
38
+
39
+ ALIGN_PARAMS_MSG = "Align the elements of an array literal if they span more than one line."
40
+
41
+ FIXED_INDENT_MSG = "Use one level of indentation for elements " \
42
+ "following the first line of a multi-line array."
43
+
44
+ def on_array(node)
45
+ return if node.children.size < 2
46
+
47
+ check_alignment(node.children, base_column(node, node.children))
48
+ end
49
+
50
+ def autocorrect(node)
51
+ RuboCop::Cop::AlignmentCorrector.correct(processed_source, node, column_delta)
52
+ end
53
+
54
+ private
55
+
56
+ def message(_node)
57
+ fixed_indentation? ? FIXED_INDENT_MSG : ALIGN_PARAMS_MSG
58
+ end
59
+
60
+ def fixed_indentation?
61
+ cop_config["EnforcedStyle"] == "with_fixed_indentation"
62
+ end
63
+
64
+ def base_column(node, args)
65
+ fixed_indentation? ? line_indentation(node) : display_column(args.first.source_range)
66
+ end
67
+
68
+ def line_indentation(node)
69
+ lineno = target_method_lineno(node)
70
+ line = node.source_range.source_buffer.source_line(lineno)
71
+ line_indentation = /\S.*/.match(line).begin(0)
72
+ line_indentation + configured_indentation_width
73
+ end
74
+
75
+ def target_method_lineno(node)
76
+ node.loc.line
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,35 @@
1
+ module DatarocketsStyle
2
+ module Cop
3
+ module Style
4
+ # This cop checks nested interpolations
5
+ #
6
+ # @example
7
+ #
8
+ # # bad
9
+ # "Hello, #{user.blank? ? 'guest' : "dear #{user.name}"}"
10
+ #
11
+ # # good
12
+ # user_name = user.blank? ? 'guest' : "dear #{user.name}"
13
+ # "Hello, #{user_name}"
14
+ class NestedInterpolation < RuboCop::Cop::Cop
15
+ include RuboCop::Cop::Interpolation
16
+
17
+ MSG = "Redundant nested interpolation.".freeze
18
+
19
+ def on_interpolation(node)
20
+ node.each_descendant(:dstr) do |descendant_node|
21
+ detect_double_interpolation(descendant_node)
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def detect_double_interpolation(node)
28
+ node.each_child_node(:begin) do |begin_node|
29
+ add_offense(begin_node)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -42,9 +42,10 @@ 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
- Datarockets::Style::Formatter::TodoListFormatter::ReportSummary.new(offense_list).call(output)
49
+ DatarocketsStyle::Formatter::TodoListFormatter::ReportSummary.new(offense_list).call(output)
49
50
  end
50
51
  end
@@ -0,0 +1,55 @@
1
+ module DatarocketsStyle
2
+ module Formatter
3
+ module TodoListFormatter
4
+ # Get file of pairs: file path and cop name - and prepare report for ToDo list formatter.
5
+ #
6
+ # Example of result:
7
+ #
8
+ # LineLength
9
+ # Exclude:
10
+ # - "really/bad/file.rb" # 100500
11
+ # - "almost/ok.rb" # 1
12
+ class ReportSummary
13
+ attr_reader :offense_list
14
+
15
+ FileGroup = Struct.new(:file, :offenses_count) do
16
+ def print(output)
17
+ output.puts " - '#{file}' # #{offenses_count}"
18
+ end
19
+ end
20
+
21
+ OffenseGroup = Struct.new(:cop_name, :offenses) do
22
+ def file_groups
23
+ @_file_groups ||= offenses.group_by(&:file_path).map do |file, offenses|
24
+ FileGroup.new(file, offenses.length)
25
+ end
26
+ end
27
+
28
+ def print(output)
29
+ output.puts("#{cop_name}:")
30
+ output.puts(" Exclude:")
31
+ file_groups.sort_by(&:file).each do |file_group|
32
+ file_group.print(output)
33
+ end
34
+ output.puts
35
+ end
36
+ end
37
+
38
+ def initialize(offense_list)
39
+ @offense_list = offense_list
40
+ end
41
+
42
+ def call(output)
43
+ offense_groups.sort_by(&:cop_name).each { |group| group.print(output) }
44
+ end
45
+
46
+ private
47
+
48
+ def offense_groups
49
+ @_offense_groups ||= offense_list.group_by(&:cop_name)
50
+ .map { |cop_name, offenses| OffenseGroup.new(cop_name, offenses) }
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,3 @@
1
+ module DatarocketsStyle
2
+ VERSION = "1.1.0".freeze
3
+ end
metadata CHANGED
@@ -1,57 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datarockets-style
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 1.1.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-03-02 00:00:00.000000000 Z
11
+ date: 2021-02-09 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
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: '0.80'
22
+ version: '2.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '1.2'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '0.80'
32
+ version: '2.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rubocop-rails
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - "~>"
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 2.8.0
40
+ - - "<"
32
41
  - !ruby/object:Gem::Version
33
- version: '2.4'
42
+ version: 2.10.0
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
- - - "~>"
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 2.8.0
50
+ - - "<"
39
51
  - !ruby/object:Gem::Version
40
- version: '2.4'
52
+ version: 2.10.0
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: rubocop-rspec
43
55
  requirement: !ruby/object:Gem::Requirement
44
56
  requirements:
45
57
  - - "~>"
46
58
  - !ruby/object:Gem::Version
47
- version: '1.38'
59
+ version: '2.0'
48
60
  type: :runtime
49
61
  prerelease: false
50
62
  version_requirements: !ruby/object:Gem::Requirement
51
63
  requirements:
52
64
  - - "~>"
53
65
  - !ruby/object:Gem::Version
54
- version: '1.38'
66
+ version: '2.0'
55
67
  description:
56
68
  email:
57
69
  - r.dubrovsky@datarockets.com
@@ -86,12 +98,12 @@ files:
86
98
  - doc/STYLE_GUIDE.md
87
99
  - doc/STYLE_GUIDE_RAILS.md
88
100
  - doc/STYLE_GUIDE_RSPEC.md
89
- - lib/datarockets/style.rb
90
- - lib/datarockets/style/cop/layout/array_alignment_extended.rb
91
- - lib/datarockets/style/cop/style/nested_interpolation.rb
92
- - lib/datarockets/style/formatter/todo_list_formatter.rb
93
- - lib/datarockets/style/formatter/todo_list_formatter/report_summary.rb
94
- - lib/datarockets/style/version.rb
101
+ - lib/datarockets_style.rb
102
+ - lib/datarockets_style/cop/layout/array_alignment_extended.rb
103
+ - lib/datarockets_style/cop/style/nested_interpolation.rb
104
+ - lib/datarockets_style/formatter/todo_list_formatter.rb
105
+ - lib/datarockets_style/formatter/todo_list_formatter/report_summary.rb
106
+ - lib/datarockets_style/version.rb
95
107
  - manual/cops_layout.md
96
108
  homepage: https://github.com/datarockets/datarockets-style
97
109
  licenses:
@@ -106,15 +118,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
118
  requirements:
107
119
  - - ">="
108
120
  - !ruby/object:Gem::Version
109
- version: 2.3.0
121
+ version: 2.4.0
110
122
  required_rubygems_version: !ruby/object:Gem::Requirement
111
123
  requirements:
112
124
  - - ">="
113
125
  - !ruby/object:Gem::Version
114
126
  version: '0'
115
127
  requirements: []
116
- rubyforge_project:
117
- rubygems_version: 2.6.14
128
+ rubygems_version: 3.2.5
118
129
  signing_key:
119
130
  specification_version: 4
120
131
  summary: Datarockets style guides and shared style configs
@@ -1,14 +0,0 @@
1
- require "rubocop"
2
- require "datarockets/style/formatter/todo_list_formatter"
3
-
4
- require "datarockets/style/version"
5
-
6
- require "datarockets/style/cop/layout/array_alignment_extended"
7
- require "datarockets/style/cop/style/nested_interpolation"
8
-
9
- module Datarockets
10
- # Datarickors sharable config
11
- module Style
12
- # Your code goes here...
13
- end
14
- end
@@ -1,83 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Datarockets
4
- module Style
5
- module Cop
6
- module Layout
7
- # Here we check if the elements of a multi-line array literal are
8
- # aligned.
9
- #
10
- # @example EnforcedStyle: with_first_argument (default)
11
- # # good
12
- #
13
- # array = [1, 2, 3,
14
- # 4, 5, 6]
15
- # array = ['run',
16
- # 'forrest',
17
- # 'run']
18
- #
19
- # # bad
20
- #
21
- # array = [1, 2, 3,
22
- # 4, 5, 6]
23
- # array = ['run',
24
- # 'forrest',
25
- # 'run']
26
- #
27
- # @example EnforcedStyle: with_fixed_indentation
28
- # # good
29
- #
30
- # array = [1, 2, 3,
31
- # 4, 5, 6]
32
- #
33
- # # bad
34
- #
35
- # array = [1, 2, 3,
36
- # 4, 5, 6]
37
- class ArrayAlignmentExtended < RuboCop::Cop::Cop
38
- include RuboCop::Cop::Alignment
39
-
40
- ALIGN_PARAMS_MSG = "Align the elements of an array literal if they span more than one line."
41
-
42
- FIXED_INDENT_MSG = "Use one level of indentation for elements " \
43
- "following the first line of a multi-line array."
44
-
45
- def on_array(node)
46
- return if node.children.size < 2
47
-
48
- check_alignment(node.children, base_column(node, node.children))
49
- end
50
-
51
- def autocorrect(node)
52
- RuboCop::Cop::AlignmentCorrector.correct(processed_source, node, column_delta)
53
- end
54
-
55
- private
56
-
57
- def message(_node)
58
- fixed_indentation? ? FIXED_INDENT_MSG : ALIGN_PARAMS_MSG
59
- end
60
-
61
- def fixed_indentation?
62
- cop_config["EnforcedStyle"] == "with_fixed_indentation"
63
- end
64
-
65
- def base_column(node, args)
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
74
- end
75
-
76
- def target_method_lineno(node)
77
- node.loc.line
78
- end
79
- end
80
- end
81
- end
82
- end
83
- end
@@ -1,37 +0,0 @@
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
@@ -1,57 +0,0 @@
1
- module Datarockets
2
- module Style
3
- module Formatter
4
- module TodoListFormatter
5
- # Get file of pairs: file path and cop name - and prepare report for ToDo list formatter.
6
- #
7
- # Example of result:
8
- #
9
- # LineLength
10
- # Exclude:
11
- # - "really/bad/file.rb" # 100500
12
- # - "almost/ok.rb" # 1
13
- class ReportSummary
14
- attr_reader :offense_list
15
-
16
- FileGroup = Struct.new(:file, :count) do
17
- def print(output)
18
- output.puts " - '#{file}' # #{count}"
19
- end
20
- end
21
-
22
- OffenseGroup = Struct.new(:cop_name, :offenses) do
23
- def file_groups
24
- @_file_groups ||= offenses.group_by(&:file_path).map do |file, offenses|
25
- FileGroup.new(file, offenses.length)
26
- end
27
- end
28
-
29
- def print(output)
30
- output.puts(cop_name + ":")
31
- output.puts(" Exclude:")
32
- file_groups.sort_by(&:file).each do |file_group|
33
- file_group.print(output)
34
- end
35
- output.puts
36
- end
37
- end
38
-
39
- def initialize(offense_list)
40
- @offense_list = offense_list
41
- end
42
-
43
- def call(output)
44
- offense_groups.sort_by(&:cop_name).each { |group| group.print(output) }
45
- end
46
-
47
- private
48
-
49
- def offense_groups
50
- @_offense_groups ||= offense_list.group_by(&:cop_name)
51
- .map { |cop_name, offenses| OffenseGroup.new(cop_name, offenses) }
52
- end
53
- end
54
- end
55
- end
56
- end
57
- end
@@ -1,5 +0,0 @@
1
- module Datarockets
2
- module Style
3
- VERSION = "0.8.1".freeze
4
- end
5
- end