arcadia_cops 4.0.2 → 4.0.4
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 +27 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e254a8851f6048dabca6101e69ab0160d19a6155636f8fd46eb46e8970ed17f
|
4
|
+
data.tar.gz: b2d36f4a92357caf5468c31deab4e1af9894220da245ea51e7a4bae4f84d946c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4a552a043a4889583cb7e2be39c74663b9b66906265b069efa674185a6e4ef7c82c55e4040e28305aec637b2290677f4921e962e41efdc420a8f7826cbcff6d
|
7
|
+
data.tar.gz: 6f26d7596c968cc0559b3d47190bf1d09755bd507d02705654b2c8476dcdaa040bdc282af30704ad41cb904c1f4e81435d150b51bff5d775dfeadd66909b0f14
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- engineering
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.29
|
19
|
+
version: '1.29'
|
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: 1.29
|
26
|
+
version: '1.29'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop-rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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,11 +104,14 @@ 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
|
96
113
|
metadata: {}
|
97
|
-
post_install_message:
|
114
|
+
post_install_message:
|
98
115
|
rdoc_options: []
|
99
116
|
require_paths:
|
100
117
|
- lib
|
@@ -109,8 +126,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
126
|
- !ruby/object:Gem::Version
|
110
127
|
version: '0'
|
111
128
|
requirements: []
|
112
|
-
rubygems_version: 3.
|
113
|
-
signing_key:
|
129
|
+
rubygems_version: 3.4.9
|
130
|
+
signing_key:
|
114
131
|
specification_version: 4
|
115
|
-
summary: Arcadia
|
132
|
+
summary: Arcadia Style Cops
|
116
133
|
test_files: []
|