ezcater_rubocop 2.2.0 → 2.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be105a0d50d96f787a2dcface6a8850d0754c975a224489755a78107bd387a01
4
- data.tar.gz: 263a7bde454086d6171fefede0684aa035b2564fe5ab7e56dd901cbc7379e925
3
+ metadata.gz: 7bac13ea668d2b0aece9d826156baceaf021911bad36ad355086e7f6a53efe6b
4
+ data.tar.gz: 71339942639c5d6e12282656e7e8e4bc8469eda4b8fd081f2bd38ac5e169fc4f
5
5
  SHA512:
6
- metadata.gz: ae30e082ef82f070eeb11994a10f852e846590799ade95b3e85d87668386c41fe107dd81aa2bb688453dc8369b72ce044be59c231667ce8cf1a6bfe83fd4df27
7
- data.tar.gz: 58fa9015aecefd84a3986203a98ff9c10edb1ec72658c2392ac88ba5a771997a4aa08477eb56a062063c24afddfd826285914e104b03bdda7455e9c55621004b
6
+ metadata.gz: 297e28c0e816b378fcd08ad2ee9e44286d25a00230cf81022ba06e67597472c5b6392ac3b77a16d647808402827c7cd3288080ed5d790868b2eaa268aa911ed7
7
+ data.tar.gz: c4f7a84f1699a263ac4d1bf51b7bbe520a5e83a0db43db12d1d79cb7079b743cf6cb3f245b309782f385bb7eddb67938f5913f372a5ceae4cd5be6e570190b8f
data/.github/CODEOWNERS CHANGED
@@ -1 +1 @@
1
- * @agrobbin @aprescott @tjwp
1
+ * @ezcater/ruby-style-group
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.3.0
10
+ - Add `FeatureFlagActive` cop. This provides confidence that upgrading to `ezcater_feature_flag-client` v2.0.0, which
11
+ contains breaking API changes, can be done safely.
12
+
9
13
  ## v2.2.0
10
14
  - Require Ruby 2.6 or later.
11
15
  - Set `TargetRubyVersion` to 2.6 in `rubocop_gem` configuration.
data/config/default.yml CHANGED
@@ -19,6 +19,10 @@ Ezcater/DirectEnvCheck:
19
19
  Description: 'Enforce the use of `Rails.configuration.x.<foo>` instead of checking `ENV`.'
20
20
  Enabled: false
21
21
 
22
+ Ezcater/FeatureFlagActive:
23
+ Description: 'Enforce the proper arguments are given to EzcaterFeatureFlag.active?'
24
+ Enabled: true
25
+
22
26
  Ezcater/RspecDotNotSelfDot:
23
27
  Description: 'Enforce ".<class method>" instead of "self.<class method>" for example group description.'
24
28
  Enabled: true
@@ -16,6 +16,7 @@ config = RuboCop::ConfigLoader.merge_with_default(config, path)
16
16
  RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
17
17
 
18
18
  require "rubocop/cop/ezcater/direct_env_check"
19
+ require "rubocop/cop/ezcater/feature_flag_active"
19
20
  require "rubocop/cop/ezcater/graphql_fields_naming"
20
21
  require "rubocop/cop/ezcater/rails_configuration"
21
22
  require "rubocop/cop/ezcater/rails_env"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EzcaterRubocop
4
- VERSION = "2.2.0"
4
+ VERSION = "2.3.0"
5
5
  end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Ezcater
6
+ # Use `EzcaterFeatureFlag.active?` with a tracking_id or array of identifiers
7
+ #
8
+ # @example
9
+ #
10
+ # # good
11
+ # EzFF.active?("FlagName", tracking_id: "user:12345")
12
+ # EzFF.active?("FlagName", identifiers: ["user:12345", "user:23456"])
13
+ #
14
+ # # bad
15
+ # EzFF.active?("FlagName")
16
+
17
+ class FeatureFlagActive < Cop
18
+ MSG = "`EzFF.active?` must be called with at least one of `tracking_id` or `identifiers`"
19
+
20
+ def_node_matcher :ezff_active_one_arg, <<-PATTERN
21
+ (send
22
+ (_ _ {:EzFF :EzcaterFeatureFlag}) :active? (str _))
23
+ PATTERN
24
+
25
+ def_node_matcher :args_matcher, <<-PATTERN
26
+ (send
27
+ (_ _ {:EzFF :EzcaterFeatureFlag}) :active?
28
+ (str _)
29
+ (_
30
+ (pair
31
+ (sym {:tracking_id :identifiers})
32
+ _)
33
+ ...))
34
+ PATTERN
35
+
36
+ def_node_matcher :method_call_matcher, <<-PATTERN
37
+ (send
38
+ (_ _ {:EzFF :EzcaterFeatureFlag}) :active? ...)
39
+ PATTERN
40
+
41
+ def on_send(node)
42
+ return unless method_call_matcher(node)
43
+
44
+ if ezff_active_one_arg(node) || !args_matcher(node)
45
+ add_offense(node, location: :expression, message: MSG)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ 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.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ezCater, Inc
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-09 00:00:00.000000000 Z
11
+ date: 2021-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -173,6 +173,7 @@ files:
173
173
  - lib/ezcater_rubocop.rb
174
174
  - lib/ezcater_rubocop/version.rb
175
175
  - lib/rubocop/cop/ezcater/direct_env_check.rb
176
+ - lib/rubocop/cop/ezcater/feature_flag_active.rb
176
177
  - lib/rubocop/cop/ezcater/graphql_fields_naming.rb
177
178
  - lib/rubocop/cop/ezcater/rails_configuration.rb
178
179
  - lib/rubocop/cop/ezcater/rails_env.rb
@@ -191,7 +192,7 @@ licenses:
191
192
  - MIT
192
193
  metadata:
193
194
  allowed_push_host: https://rubygems.org
194
- post_install_message:
195
+ post_install_message:
195
196
  rdoc_options: []
196
197
  require_paths:
197
198
  - lib
@@ -206,8 +207,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
207
  - !ruby/object:Gem::Version
207
208
  version: '0'
208
209
  requirements: []
209
- rubygems_version: 3.1.6
210
- signing_key:
210
+ rubygems_version: 3.0.3
211
+ signing_key:
211
212
  specification_version: 4
212
213
  summary: ezCater custom cops and shared configuration
213
214
  test_files: []