datarockets-style 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/CONTRIBUTING.md +1 -1
- data/Gemfile.lock +4 -4
- data/README.md +3 -1
- data/STYLE_GUIDE.md +90 -13
- data/datarockets-style.gemspec +4 -2
- data/default.yml +6 -0
- data/lib/datarockets/style/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a419ac14c8ca4180f3f2e84d995a722129c04d3
|
4
|
+
data.tar.gz: a86d9ed8fc71274bcbb72a8b2834575191aa7876
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d14ee00d5a5936c01202602e715837df46a2ce514319fc16e59236fbd4332ef8988ac70bf1acfc2953669263d879e25983e1640322ba8ae42fda426c479fde83
|
7
|
+
data.tar.gz: 9c9997bb55e5524e61929feb73933eaf99bfe9d525694cd0a2059f761f697e8922949ae312abb3aac891b26e4b91ec67e4ed638c3bdcbea919d89612e0b89023
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,14 @@ The format is described in [Contributing notes](CONTRIBUTING.md#changelog-entry-
|
|
4
4
|
|
5
5
|
## master (unreleased)
|
6
6
|
|
7
|
+
## 0.2.0 (2019-07-17)
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
* Update rubocop to `0.73.0`. ([@r.dubrovsky][])
|
12
|
+
* Use prefered variable name in rescued exceptions (cop: `Naming/RescuedExceptionsVariableName`) ([@ula][])
|
13
|
+
* Disable `RSpec/ImplicitSubject` cop for rspec files. ([@r.dubrovsky][])
|
14
|
+
|
7
15
|
## 0.1.0 (2019-06-27)
|
8
16
|
|
9
17
|
### Added
|
@@ -29,3 +37,4 @@ The format is described in [Contributing notes](CONTRIBUTING.md#changelog-entry-
|
|
29
37
|
|
30
38
|
[@r.dubrovsky]: https://github.com/roman-dubrovsky
|
31
39
|
[@aleks]: https://github.com/AleksSenkou
|
40
|
+
[@ula]: https://github.com/lazycoder9
|
data/CONTRIBUTING.md
CHANGED
@@ -19,7 +19,7 @@ do so.
|
|
19
19
|
## Pull requests
|
20
20
|
|
21
21
|
* Read [how to properly contribute to open source projects on GitHub][2].
|
22
|
-
* Fork the project.
|
22
|
+
* Fork the project (if it's necessary and you don't have writing access).
|
23
23
|
* Use a topic/feature branch to easily amend a pull request later, if necessary.
|
24
24
|
* Write [good commit messages][3].
|
25
25
|
* Use the same coding conventions as the rest of the project.
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
datarockets-style (0.
|
5
|
-
rubocop (~> 0.
|
6
|
-
rubocop-rspec
|
4
|
+
datarockets-style (0.2.0)
|
5
|
+
rubocop (~> 0.73.0)
|
6
|
+
rubocop-rspec (~> 1.33)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
@@ -15,7 +15,7 @@ GEM
|
|
15
15
|
ast (~> 2.4.0)
|
16
16
|
rainbow (3.0.0)
|
17
17
|
rake (10.5.0)
|
18
|
-
rubocop (0.
|
18
|
+
rubocop (0.73.0)
|
19
19
|
jaro_winkler (~> 1.5.1)
|
20
20
|
parallel (~> 1.10)
|
21
21
|
parser (>= 2.6)
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Datarockets::Style
|
1
|
+
# Datarockets::Style [](https://badge.fury.io/rb/datarockets-style)
|
2
2
|
|
3
3
|
Datarockets shared style configs and notes of code-style convensions. Based on the [Rubocop](https://github.com/rubocop-hq/rubocop) util.
|
4
4
|
|
@@ -22,7 +22,9 @@ spec.add_development_dependency 'datarockets-style'
|
|
22
22
|
|
23
23
|
And then execute:
|
24
24
|
|
25
|
+
```bash
|
25
26
|
$ bundle install
|
27
|
+
```
|
26
28
|
|
27
29
|
## Usage
|
28
30
|
|
data/STYLE_GUIDE.md
CHANGED
@@ -4,19 +4,35 @@ In datarockets we enforce a community [Ruby Style Guide](https://github.com/rubo
|
|
4
4
|
|
5
5
|
This is a small list of differences which we have when compared with community style guide:
|
6
6
|
|
7
|
+
## Table of contents
|
8
|
+
|
9
|
+
* [Bundler](#Bundler)
|
10
|
+
* [Style](#Style)
|
11
|
+
* [Rspec](#Rspec)
|
12
|
+
|
7
13
|
## Bundler
|
8
14
|
|
9
|
-
*
|
15
|
+
* <a name="bundler-add-once"></a>
|
16
|
+
A Gem's requirements should be listed only once in a Gemfile
|
17
|
+
<sup>[[link](#bundler-add-once)]</sup>
|
10
18
|
|
11
|
-
*
|
19
|
+
* <a name="bundler-ordering"></a>
|
20
|
+
Gems should be alphabetically sorted within groups. Also you can use a line comment as a group separator.
|
21
|
+
<sup>[[link](#bundler-ordering)]</sup>
|
12
22
|
|
13
23
|
## Style
|
14
24
|
|
15
|
-
*
|
25
|
+
* <a name="style-line-length"></a>
|
26
|
+
Limit lines to 120 characters.
|
27
|
+
<sup>[[link](#style-line-length)]</sup>
|
16
28
|
|
17
|
-
*
|
29
|
+
* <a name="style-double-quotes"></a>
|
30
|
+
Prefer double-quotes unless your string literal contains " or escape characters you want to suppress.
|
31
|
+
<sup>[[link](#style-double-quotes)]</sup>
|
18
32
|
|
19
|
-
*
|
33
|
+
* <a name="style-hash-aligning"></a>
|
34
|
+
If elements of a hash literal span more than one line we're aligning them by keys.
|
35
|
+
<sup>[[link](#style-hash-aligning)]</sup>
|
20
36
|
|
21
37
|
|
22
38
|
```ruby
|
@@ -37,8 +53,10 @@ This is a small list of differences which we have when compared with community s
|
|
37
53
|
}
|
38
54
|
```
|
39
55
|
|
40
|
-
*
|
41
|
-
|
56
|
+
* <a name="style-keyword-arguments-aligning"></a>
|
57
|
+
There is one exception in the rule above when the hash literal is passed as method argument.
|
58
|
+
In this case we just use an indentation level.
|
59
|
+
<sup>[[link](#style-keyword-arguments-aligning)]</sup>
|
42
60
|
|
43
61
|
```ruby
|
44
62
|
# bad
|
@@ -50,7 +68,9 @@ do_something(foo: 1,
|
|
50
68
|
bar: 2)
|
51
69
|
```
|
52
70
|
|
53
|
-
*
|
71
|
+
* <a name="style-parameters-aligning"></a>
|
72
|
+
The parameters on a multi-line method call or definition are aligning by an indentation level.
|
73
|
+
<sup>[[link](#style-parameters-aligning)]</sup>
|
54
74
|
|
55
75
|
```ruby
|
56
76
|
# good
|
@@ -83,7 +103,9 @@ def foo(
|
|
83
103
|
end
|
84
104
|
```
|
85
105
|
|
86
|
-
*
|
106
|
+
* <a name="style-end-aligning"></a>
|
107
|
+
The `end` shall be aligned with the left-hand-side of the variable assignment. But we prefer not to use code blocks with `end` for variable assignment and prefer move it into the separate methods.
|
108
|
+
<sup>[[link](#style-end-aligning)]</sup>
|
87
109
|
|
88
110
|
```ruby
|
89
111
|
# bad
|
@@ -127,7 +149,9 @@ end
|
|
127
149
|
|
128
150
|
```
|
129
151
|
|
130
|
-
*
|
152
|
+
* <a name="style-method-indentations"></a>
|
153
|
+
We're prefering a ruby style for methods indentations, not rails. You can check it [here](https://github.com/rubocop-hq/ruby-style-guide#indent-public-private-protected).
|
154
|
+
<sup>[[link](#style-method-indentations)]</sup>
|
131
155
|
|
132
156
|
```ruby
|
133
157
|
# bad
|
@@ -183,7 +207,9 @@ class A
|
|
183
207
|
end
|
184
208
|
```
|
185
209
|
|
186
|
-
*
|
210
|
+
* <a name="style-hash-spaces"></a>
|
211
|
+
For hash literals not to add scapes after `{` or before `}`. We want to have the advantage of adding visual difference between block and hash literals.
|
212
|
+
<sup>[[link](#style-hash-spaces)]</sup>
|
187
213
|
|
188
214
|
```ruby
|
189
215
|
# bad
|
@@ -195,8 +221,59 @@ h = {a: 1, b: 2}
|
|
195
221
|
Array.new(3) { |i| i + 1 }
|
196
222
|
```
|
197
223
|
|
224
|
+
* <a name="style-rescued-variable-name"></a>
|
225
|
+
Use `error` as a variable name on processing exceptions.
|
226
|
+
<sup>[[link](#style-rescued-variable-name)]</sup>
|
227
|
+
|
228
|
+
```ruby
|
229
|
+
# bad
|
230
|
+
begin
|
231
|
+
# do something
|
232
|
+
rescue MyException => e
|
233
|
+
# do something
|
234
|
+
end
|
235
|
+
|
236
|
+
# good
|
237
|
+
begin
|
238
|
+
# do something
|
239
|
+
rescue MyException => error
|
240
|
+
# do something
|
241
|
+
end
|
242
|
+
```
|
198
243
|
## Rspec
|
199
244
|
|
200
|
-
*
|
245
|
+
* <a name="rspec-betterrspec"></a>
|
246
|
+
We're happy to use [better spec rules](http://www.betterspecs.org/) for improving our tests.
|
247
|
+
<sup>[[link](#rspec-betterrspec)]</sup>
|
248
|
+
|
249
|
+
* <a name="rspec-file-length"></a>
|
250
|
+
We're not limiting a length of rspec files.
|
251
|
+
<sup>[[link](#rspec-file-length)]</sup>
|
252
|
+
|
253
|
+
* <a name="rspec-subject"></a>
|
254
|
+
Each subject should be named and we should not use `subject` in our test cases.
|
255
|
+
Prefer to use `is_expected` that `expect(subject_name)` for small tests.
|
256
|
+
<sup>[[link](#rspec-subject)]</sup>
|
201
257
|
|
202
|
-
|
258
|
+
```ruby
|
259
|
+
# bad
|
260
|
+
subject { service.call }
|
261
|
+
|
262
|
+
it 'test' do
|
263
|
+
expect(subject).to eq value
|
264
|
+
end
|
265
|
+
|
266
|
+
# ok
|
267
|
+
subject(:service_call) { service.call }
|
268
|
+
|
269
|
+
it 'test' do
|
270
|
+
expect(service_call).to eq value
|
271
|
+
end
|
272
|
+
|
273
|
+
# better
|
274
|
+
subject { service.call }
|
275
|
+
|
276
|
+
it 'test' do
|
277
|
+
is_expected.to eq value
|
278
|
+
end
|
279
|
+
```
|
data/datarockets-style.gemspec
CHANGED
@@ -12,6 +12,8 @@ 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'
|
16
|
+
|
15
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
19
|
if spec.respond_to?(:metadata)
|
@@ -28,8 +30,8 @@ Gem::Specification.new do |spec|
|
|
28
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
31
|
spec.require_paths = ["lib"]
|
30
32
|
|
31
|
-
spec.add_dependency "rubocop", "~> 0.
|
32
|
-
spec.add_dependency "rubocop-rspec"
|
33
|
+
spec.add_dependency "rubocop", "~> 0.73.0"
|
34
|
+
spec.add_dependency "rubocop-rspec", "~> 1.33"
|
33
35
|
|
34
36
|
spec.add_development_dependency "bundler", "~> 1.16"
|
35
37
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/default.yml
CHANGED
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.2.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: 2019-
|
11
|
+
date: 2019-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.73.0
|
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.73.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop-rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.33'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '1.33'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
103
|
requirements:
|
104
104
|
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
106
|
+
version: 2.3.0
|
107
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - ">="
|