arcadia_cops 4.0.2 → 4.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/config/config.yml +1 -0
- data/config/enabled.yml +6 -0
- data/lib/arcadia_cops/simple_modifier_conditional.rb +21 -0
- data/lib/arcadia_cops/simple_unless.rb +17 -0
- data/lib/arcadia_cops.rb +4 -0
- metadata +21 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fa3774ee46a2326ed47a8c64c089fd5fb681e2c0f4e1d56d3d09126d2ea72f0
|
4
|
+
data.tar.gz: d0dd3053c5f3f6edc72c04d2932f9d42a0622e9abec2332662e1649156179b48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3431f7f1a85ce8dbea1e054057a52ba2604887debe3434f6fcdd98f552130924febe617414720089e4e3aedf956d80d2b2797873c959909385da18519303432a
|
7
|
+
data.tar.gz: 7feddebc66a0eea0b7ce21b0994a526b4a6e4daa52972a4531f25e8e67352e5510ca60634c1a14c0d851238c52dbfb9ddcb753315cd32fb6a2d41c2c7f088421
|
data/README.md
CHANGED
@@ -18,6 +18,8 @@ Add a new cop to the `enabled.yml`, bump the version, and put in a PR for review
|
|
18
18
|
|
19
19
|
To see all cops including those that aren't enabled run `bundle exec rubocop --show-cops`.
|
20
20
|
|
21
|
+
WHen developing custom cops, make sure to add specs and run run `bundle exec rspec` before releasing.
|
22
|
+
|
21
23
|
## Release
|
22
24
|
|
23
25
|
Ensure you have bumped the version and run `rake release` to release to rubygems.org.
|
data/config/config.yml
CHANGED
data/config/enabled.yml
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ArcadiaCops
|
4
|
+
# Cop to tackle prevent more complicated modifier if/unless statements
|
5
|
+
# https://github.com/airbnb/ruby/blob/12435e8136d2adf710de999bc0f6bef01215df2c/rubocop-airbnb/lib/rubocop/cop/airbnb/simple_modifier_conditional.rb
|
6
|
+
class SimpleModifierConditional < RuboCop::Cop::Cop
|
7
|
+
MSG = 'Modifier if/unless usage is okay when the body is simple, ' \
|
8
|
+
'the condition is simple, and the whole thing fits on one line. ' \
|
9
|
+
'Otherwise, avoid modifier if/unless.'.freeze
|
10
|
+
|
11
|
+
def_node_matcher :multiple_conditionals?, '(if ({and or :^} ...) ...)'
|
12
|
+
|
13
|
+
def on_if(node)
|
14
|
+
return unless node.modifier_form?
|
15
|
+
|
16
|
+
if multiple_conditionals?(node) || node.multiline?
|
17
|
+
add_offense(node)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ArcadiaCops
|
4
|
+
# Cop to tackle prevent unless statements with multiple conditions
|
5
|
+
# https://github.com/airbnb/ruby/blob/12435e8136d2adf710de999bc0f6bef01215df2c/rubocop-airbnb/lib/rubocop/cop/airbnb/simple_unless.rb
|
6
|
+
class SimpleUnless < RuboCop::Cop::Cop
|
7
|
+
MSG = 'Unless usage is okay when there is only one conditional'.freeze
|
8
|
+
|
9
|
+
def_node_matcher :multiple_conditionals?, '(if ({and or :^} ...) ...)'
|
10
|
+
|
11
|
+
def on_if(node)
|
12
|
+
return unless node.unless?
|
13
|
+
|
14
|
+
add_offense(node) if multiple_conditionals?(node)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/arcadia_cops.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arcadia_cops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 2.0.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +94,7 @@ dependencies:
|
|
80
94
|
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
|
-
description: Contains enabled rubocops for
|
97
|
+
description: Contains enabled rubocops for Arcadia ruby repos.
|
84
98
|
email:
|
85
99
|
- engineering@arcadia.com
|
86
100
|
executables: []
|
@@ -90,6 +104,9 @@ files:
|
|
90
104
|
- README.md
|
91
105
|
- config/config.yml
|
92
106
|
- config/enabled.yml
|
107
|
+
- lib/arcadia_cops.rb
|
108
|
+
- lib/arcadia_cops/simple_modifier_conditional.rb
|
109
|
+
- lib/arcadia_cops/simple_unless.rb
|
93
110
|
homepage: https://github.com/ArcadiaPower/arcadia_cops/
|
94
111
|
licenses:
|
95
112
|
- MIT
|
@@ -112,5 +129,5 @@ requirements: []
|
|
112
129
|
rubygems_version: 3.1.6
|
113
130
|
signing_key:
|
114
131
|
specification_version: 4
|
115
|
-
summary: Arcadia
|
132
|
+
summary: Arcadia Style Cops
|
116
133
|
test_files: []
|