ezcater_rubocop 2.3.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/ezcater_rubocop.gemspec +1 -1
- data/lib/ezcater_rubocop/version.rb +1 -1
- data/lib/rubocop/cop/ezcater/feature_flag_active.rb +16 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e4c9156d1f1e5ccdc48028b627a413ae3ff87a7bf47ec574943d2d755efe5aa
|
4
|
+
data.tar.gz: 490b59709998f04a6c873d210f028ddb6d045dabccce60e4a962f38f2ac1584d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5645db771b9fd242d08b92eb300f29c57a51bb089466e5f3c4f269261972e786a8cf0a3f9b051eb401acfb001d2cacc024e292b6291243c9b086ebafb90fe392
|
7
|
+
data.tar.gz: f9b580d5a79630d70c77d06fb3f5922f39a2a2fafd70ec587f162409553ccc8e4bf28ed55d1f68ae0b6daa279faed0f7f88c69c4c6998bec039cd29a8b27210f
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,13 @@ This gem is moving onto its own [Semantic Versioning](https://semver.org/) schem
|
|
6
6
|
|
7
7
|
Prior to v1.0.0 this gem was versioned based on the `MAJOR`.`MINOR` version of RuboCop. The first release of the ezcater_rubocop gem was `v0.49.0`.
|
8
8
|
|
9
|
+
## v2.5.0
|
10
|
+
- Update rubocop to 0.90.0
|
11
|
+
|
12
|
+
## v2.4.0
|
13
|
+
- Fix `FeatureFlagActive` cop so that it allows feature flag names to be variables in addition to strings.
|
14
|
+
- Add check to `FeatureFlagActive` that the first parameter is a string or a variable, and use the appropriate messaging.
|
15
|
+
|
9
16
|
## v2.3.0
|
10
17
|
- Add `FeatureFlagActive` cop. This provides confidence that upgrading to `ezcater_feature_flag-client` v2.0.0, which
|
11
18
|
contains breaking API changes, can be done safely.
|
data/ezcater_rubocop.gemspec
CHANGED
@@ -52,7 +52,7 @@ Gem::Specification.new do |spec|
|
|
52
52
|
spec.add_development_dependency "simplecov", "< 0.18.0"
|
53
53
|
|
54
54
|
spec.add_runtime_dependency "parser", "!= 2.5.1.1"
|
55
|
-
spec.add_runtime_dependency "rubocop", "~> 0.
|
55
|
+
spec.add_runtime_dependency "rubocop", "~> 0.90.0"
|
56
56
|
spec.add_runtime_dependency "rubocop-rails", "~> 2.5.2"
|
57
57
|
spec.add_runtime_dependency "rubocop-rspec", "~> 1.38.1"
|
58
58
|
end
|
@@ -10,22 +10,27 @@ module RuboCop
|
|
10
10
|
# # good
|
11
11
|
# EzFF.active?("FlagName", tracking_id: "user:12345")
|
12
12
|
# EzFF.active?("FlagName", identifiers: ["user:12345", "user:23456"])
|
13
|
+
# EzFF.active?(defined_flag_name_var, tracking_id: "brand:12345")
|
14
|
+
# EzFF.active?(@flag_name_ivar, tracking_id: "brand:12345")
|
13
15
|
#
|
14
16
|
# # bad
|
15
17
|
# EzFF.active?("FlagName")
|
18
|
+
# EzFF.active?(defined_flag_name_var)
|
19
|
+
# EzFF.active?(@flag_name_ivar)
|
16
20
|
|
17
21
|
class FeatureFlagActive < Cop
|
18
22
|
MSG = "`EzFF.active?` must be called with at least one of `tracking_id` or `identifiers`"
|
23
|
+
FIRST_PARAM_MSG = "The first argument to `EzFF.active?` must be a string or predefined variable"
|
19
24
|
|
20
25
|
def_node_matcher :ezff_active_one_arg, <<-PATTERN
|
21
26
|
(send
|
22
|
-
(_ _ {:EzFF :EzcaterFeatureFlag}) :active?
|
27
|
+
(_ _ {:EzFF :EzcaterFeatureFlag}) :active? ${str lvar ivar})
|
23
28
|
PATTERN
|
24
29
|
|
25
30
|
def_node_matcher :args_matcher, <<-PATTERN
|
26
31
|
(send
|
27
32
|
(_ _ {:EzFF :EzcaterFeatureFlag}) :active?
|
28
|
-
|
33
|
+
${str lvar ivar}
|
29
34
|
(_
|
30
35
|
(pair
|
31
36
|
(sym {:tracking_id :identifiers})
|
@@ -33,6 +38,11 @@ module RuboCop
|
|
33
38
|
...))
|
34
39
|
PATTERN
|
35
40
|
|
41
|
+
def_node_matcher :first_param_good, <<-PATTERN
|
42
|
+
(send
|
43
|
+
(_ _ {:EzFF :EzcaterFeatureFlag}) :active? ${str lvar ivar} ...)
|
44
|
+
PATTERN
|
45
|
+
|
36
46
|
def_node_matcher :method_call_matcher, <<-PATTERN
|
37
47
|
(send
|
38
48
|
(_ _ {:EzFF :EzcaterFeatureFlag}) :active? ...)
|
@@ -41,6 +51,10 @@ module RuboCop
|
|
41
51
|
def on_send(node)
|
42
52
|
return unless method_call_matcher(node)
|
43
53
|
|
54
|
+
if !first_param_good(node)
|
55
|
+
add_offense(node, location: :expression, message: FIRST_PARAM_MSG)
|
56
|
+
end
|
57
|
+
|
44
58
|
if ezff_active_one_arg(node) || !args_matcher(node)
|
45
59
|
add_offense(node, location: :expression, message: MSG)
|
46
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ezcater_rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ezCater, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
117
|
+
version: 0.90.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
124
|
+
version: 0.90.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rubocop-rails
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -207,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
209
|
requirements: []
|
210
|
-
rubygems_version: 3.
|
210
|
+
rubygems_version: 3.1.6
|
211
211
|
signing_key:
|
212
212
|
specification_version: 4
|
213
213
|
summary: ezCater custom cops and shared configuration
|