ezcater_rubocop 2.3.0 → 2.4.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 +4 -0
- data/lib/ezcater_rubocop/version.rb +1 -1
- data/lib/rubocop/cop/ezcater/feature_flag_active.rb +16 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2096c91ae045203c587668c5973b89b1b873645d0f0d1d95641eb556dd536dff
|
|
4
|
+
data.tar.gz: a989856aa682768b8a3e9c47270dc441cd6743420cf8884451b53579a61c6c1f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 772cc5d23fa87784f870effdc91bccf4bdb12665c017b7f3a845f38c572c46a3232ad2acddd89e48be6f6566144e63b6693c4a78638e18e1231eb0086c8bfea9
|
|
7
|
+
data.tar.gz: 7396c095538e84ca0984ecec837d18164a0bc3fdd3b2a11b5dcf8ae586f926100518ab78bb757a10f998c0b3c819d0e62a59025561653877e6f8829aa4a013ce
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,10 @@ 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.4.0
|
|
10
|
+
- Fix `FeatureFlagActive` cop so that it allows feature flag names to be variables in addition to strings.
|
|
11
|
+
- Add check to `FeatureFlagActive` that the first parameter is a string or a variable, and use the appropriate messaging.
|
|
12
|
+
|
|
9
13
|
## v2.3.0
|
|
10
14
|
- Add `FeatureFlagActive` cop. This provides confidence that upgrading to `ezcater_feature_flag-client` v2.0.0, which
|
|
11
15
|
contains breaking API changes, can be done safely.
|
|
@@ -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.4.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: 2021-05-
|
|
11
|
+
date: 2021-05-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|