ezcater_rubocop 2.0.0.pre1 → 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: 44fc1c8b8dc328d61ecf1acaf0bdf156c595c28c01cde1e49a48ee2c7a88ca53
4
- data.tar.gz: 9b281bdad5735b54f31282800286b1f6c15bd6b860e08ae7aff94edfe15c4be1
3
+ metadata.gz: 7bac13ea668d2b0aece9d826156baceaf021911bad36ad355086e7f6a53efe6b
4
+ data.tar.gz: 71339942639c5d6e12282656e7e8e4bc8469eda4b8fd081f2bd38ac5e169fc4f
5
5
  SHA512:
6
- metadata.gz: 020605c98b8aeb9f2527dc08edb811eaeb446153ddf8e3d404e6febdd7d31831edeefc13c88c7612f462f983606fca9fe1a31dfcbe91d5f615d316ee673ff343
7
- data.tar.gz: a7dde3fda9fe500707b215a431df6a4d31087978aa15fa1c930e5af8de3704ad5037862fe193d76fba132cd63e065a31a1e8de74355f4397155f473fd32aa4bf
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,10 +6,22 @@ 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.0.0 (unreleased)
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
+
13
+ ## v2.2.0
14
+ - Require Ruby 2.6 or later.
15
+ - Set `TargetRubyVersion` to 2.6 in `rubocop_gem` configuration.
16
+
17
+ ## v2.1.0
18
+ - Enable `Rails/SaveBang` with `AllowImplicitReturn: false`, and with autocorrection disabled.
19
+
20
+ ## v2.0.0
10
21
  - Update to `rubocop` v0.81.0, `rubocop-rspec` v1.38.1 and `rubocop-rails` v2.5.2.
11
22
  - This is being released as a major update because cops have been renamed so this is unlikely to be
12
23
  a drop-in replacement.
24
+ - This is the first release to support Ruby 2.7.
13
25
 
14
26
  ## v1.4.1
15
27
  - Correct a matching syntax issue with `Ezcater/RubyTimeout` so that it applies in the expected cases.
data/conf/rubocop.yml CHANGED
@@ -142,12 +142,20 @@ Style/TrailingCommaInHashLiteral:
142
142
 
143
143
  ### New Cops
144
144
 
145
+ # Cops are now introduced in a "pending" state and must be explicitly
146
+ # enabled or disabled. New cops are not enabled by default until the
147
+ # next major release.
148
+
149
+ #### New cops in v0.81
150
+
145
151
  Lint/RaiseException:
146
152
  Enabled: true
147
153
 
148
154
  Lint/StructNewOverride:
149
155
  Enabled: true
150
156
 
157
+ #### New cops in v0.80
158
+
151
159
  Style/HashEachMethods:
152
160
  Enabled: true
153
161
 
data/conf/rubocop_gem.yml CHANGED
@@ -2,6 +2,7 @@ inherit_from:
2
2
  - ../conf/rubocop.yml
3
3
 
4
4
  AllCops:
5
+ TargetRubyVersion: 2.6
5
6
  Exclude:
6
7
  - 'vendor/bundle/**/*'
7
8
  - 'gemfiles/vendor/**/*'
@@ -47,6 +47,11 @@ Rails/UnknownEnv:
47
47
  - staging
48
48
  - production
49
49
 
50
+ Rails/SaveBang:
51
+ Enabled: true
52
+ AllowImplicitReturn: false
53
+ AutoCorrect: False
54
+
50
55
  Ezcater/RailsTopLevelSqlExecute:
51
56
  Description: 'Use `execute` instead of `ActiveRecord::Base.connection.execute` in migrations.'
52
57
  Enabled: true
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
@@ -42,8 +42,9 @@ Gem::Specification.new do |spec|
42
42
  spec.executables << "circle_rubocop.rb"
43
43
  spec.require_paths = ["lib"]
44
44
 
45
- spec.add_development_dependency "bundler", "~> 1.15"
46
- spec.add_development_dependency "mry"
45
+ spec.required_ruby_version = ">= 2.6"
46
+
47
+ spec.add_development_dependency "bundler", "~> 2.1"
47
48
  spec.add_development_dependency "pry-byebug"
48
49
  spec.add_development_dependency "rake", "~> 12.3"
49
50
  spec.add_development_dependency "rspec", "~> 3.0"
@@ -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.0.0.pre1"
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.0.0.pre1
4
+ version: 2.3.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: 2020-04-23 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
@@ -16,28 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.15'
19
+ version: '2.1'
20
20
  type: :development
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.15'
27
- - !ruby/object:Gem::Dependency
28
- name: mry
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
26
+ version: '2.1'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: pry-byebug
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -187,6 +173,7 @@ files:
187
173
  - lib/ezcater_rubocop.rb
188
174
  - lib/ezcater_rubocop/version.rb
189
175
  - lib/rubocop/cop/ezcater/direct_env_check.rb
176
+ - lib/rubocop/cop/ezcater/feature_flag_active.rb
190
177
  - lib/rubocop/cop/ezcater/graphql_fields_naming.rb
191
178
  - lib/rubocop/cop/ezcater/rails_configuration.rb
192
179
  - lib/rubocop/cop/ezcater/rails_env.rb
@@ -213,14 +200,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
200
  requirements:
214
201
  - - ">="
215
202
  - !ruby/object:Gem::Version
216
- version: '0'
203
+ version: '2.6'
217
204
  required_rubygems_version: !ruby/object:Gem::Requirement
218
205
  requirements:
219
- - - ">"
206
+ - - ">="
220
207
  - !ruby/object:Gem::Version
221
- version: 1.3.1
208
+ version: '0'
222
209
  requirements: []
223
- rubygems_version: 3.1.2
210
+ rubygems_version: 3.0.3
224
211
  signing_key:
225
212
  specification_version: 4
226
213
  summary: ezCater custom cops and shared configuration