ezcater_rubocop 2.0.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -1
- data/CHANGELOG.md +15 -0
- data/conf/rubocop_gem.yml +1 -0
- data/conf/rubocop_rails.yml +5 -0
- data/config/default.yml +4 -0
- data/ezcater_rubocop.gemspec +2 -0
- data/lib/ezcater_rubocop.rb +1 -0
- data/lib/ezcater_rubocop/version.rb +1 -1
- data/lib/rubocop/cop/ezcater/feature_flag_active.rb +65 -0
- metadata +5 -4
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/.github/CODEOWNERS
CHANGED
@@ -1 +1 @@
|
|
1
|
-
* @
|
1
|
+
* @ezcater/ruby-style-group
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,21 @@ 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
|
+
|
13
|
+
## v2.3.0
|
14
|
+
- Add `FeatureFlagActive` cop. This provides confidence that upgrading to `ezcater_feature_flag-client` v2.0.0, which
|
15
|
+
contains breaking API changes, can be done safely.
|
16
|
+
|
17
|
+
## v2.2.0
|
18
|
+
- Require Ruby 2.6 or later.
|
19
|
+
- Set `TargetRubyVersion` to 2.6 in `rubocop_gem` configuration.
|
20
|
+
|
21
|
+
## v2.1.0
|
22
|
+
- Enable `Rails/SaveBang` with `AllowImplicitReturn: false`, and with autocorrection disabled.
|
23
|
+
|
9
24
|
## v2.0.0
|
10
25
|
- Update to `rubocop` v0.81.0, `rubocop-rspec` v1.38.1 and `rubocop-rails` v2.5.2.
|
11
26
|
- This is being released as a major update because cops have been renamed so this is unlikely to be
|
data/conf/rubocop_gem.yml
CHANGED
data/conf/rubocop_rails.yml
CHANGED
@@ -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
|
data/ezcater_rubocop.gemspec
CHANGED
@@ -42,6 +42,8 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.executables << "circle_rubocop.rb"
|
43
43
|
spec.require_paths = ["lib"]
|
44
44
|
|
45
|
+
spec.required_ruby_version = ">= 2.6"
|
46
|
+
|
45
47
|
spec.add_development_dependency "bundler", "~> 2.1"
|
46
48
|
spec.add_development_dependency "pry-byebug"
|
47
49
|
spec.add_development_dependency "rake", "~> 12.3"
|
data/lib/ezcater_rubocop.rb
CHANGED
@@ -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"
|
@@ -0,0 +1,65 @@
|
|
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
|
+
# EzFF.active?(defined_flag_name_var, tracking_id: "brand:12345")
|
14
|
+
# EzFF.active?(@flag_name_ivar, tracking_id: "brand:12345")
|
15
|
+
#
|
16
|
+
# # bad
|
17
|
+
# EzFF.active?("FlagName")
|
18
|
+
# EzFF.active?(defined_flag_name_var)
|
19
|
+
# EzFF.active?(@flag_name_ivar)
|
20
|
+
|
21
|
+
class FeatureFlagActive < Cop
|
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"
|
24
|
+
|
25
|
+
def_node_matcher :ezff_active_one_arg, <<-PATTERN
|
26
|
+
(send
|
27
|
+
(_ _ {:EzFF :EzcaterFeatureFlag}) :active? ${str lvar ivar})
|
28
|
+
PATTERN
|
29
|
+
|
30
|
+
def_node_matcher :args_matcher, <<-PATTERN
|
31
|
+
(send
|
32
|
+
(_ _ {:EzFF :EzcaterFeatureFlag}) :active?
|
33
|
+
${str lvar ivar}
|
34
|
+
(_
|
35
|
+
(pair
|
36
|
+
(sym {:tracking_id :identifiers})
|
37
|
+
_)
|
38
|
+
...))
|
39
|
+
PATTERN
|
40
|
+
|
41
|
+
def_node_matcher :first_param_good, <<-PATTERN
|
42
|
+
(send
|
43
|
+
(_ _ {:EzFF :EzcaterFeatureFlag}) :active? ${str lvar ivar} ...)
|
44
|
+
PATTERN
|
45
|
+
|
46
|
+
def_node_matcher :method_call_matcher, <<-PATTERN
|
47
|
+
(send
|
48
|
+
(_ _ {:EzFF :EzcaterFeatureFlag}) :active? ...)
|
49
|
+
PATTERN
|
50
|
+
|
51
|
+
def on_send(node)
|
52
|
+
return unless method_call_matcher(node)
|
53
|
+
|
54
|
+
if !first_param_good(node)
|
55
|
+
add_offense(node, location: :expression, message: FIRST_PARAM_MSG)
|
56
|
+
end
|
57
|
+
|
58
|
+
if ezff_active_one_arg(node) || !args_matcher(node)
|
59
|
+
add_offense(node, location: :expression, message: MSG)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
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:
|
11
|
+
date: 2021-05-28 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
|
@@ -199,14 +200,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
199
200
|
requirements:
|
200
201
|
- - ">="
|
201
202
|
- !ruby/object:Gem::Version
|
202
|
-
version: '
|
203
|
+
version: '2.6'
|
203
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
205
|
requirements:
|
205
206
|
- - ">="
|
206
207
|
- !ruby/object:Gem::Version
|
207
208
|
version: '0'
|
208
209
|
requirements: []
|
209
|
-
rubygems_version: 3.0.
|
210
|
+
rubygems_version: 3.0.3
|
210
211
|
signing_key:
|
211
212
|
specification_version: 4
|
212
213
|
summary: ezCater custom cops and shared configuration
|