ezcater_rubocop 6.0.1 → 6.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5f12d0a1d9d61fff795e000706b9ef2d02b0d78c65e58a5563c3f11d8870148
4
- data.tar.gz: 33e6a6d1dc61072834735eb38b1e894007c87d478c8f52175158943117c76136
3
+ metadata.gz: 144220e45db4ba03e7754c0f656cafe7650da1669157b65396c818762e7d9185
4
+ data.tar.gz: b1e19818de9418e2a822ef0d1a3c067870ed36d26c7addb6d831776b4590a25d
5
5
  SHA512:
6
- metadata.gz: bf0a35365a2fa3d1b59683b589a6fbe9718920a0c971cf49ada9b2b75b99d1289d8c667424d29cd4153e81e6990e24f7f552de8d6d1351eae77b480a0166bc1a
7
- data.tar.gz: 5cf74d0d428af4489ff699de87603f139c96df12ef07ee4c913554b31218f464d732724667e933bf16eebc6ab71b7ac85052ef36adef5f331ee2d18903daf184
6
+ metadata.gz: 6da4228e123e62619f9ac2e66f53e766cd8a15160f6362fc7e33009b39749028a6e1dd4d835caa8fa101afe71dc743f6947622e43d2d3530b1ee23b3e539fadc
7
+ data.tar.gz: 6cbe86a738c2567d5829b58b18cc23e13f05125b4c19ebd7ad41ddbcc5945cc08774740353708488e9c88235bdf85dc5f317f7654322255c8e9bcc10c4489076
@@ -0,0 +1,71 @@
1
+ name: "CodeQL"
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main" ]
6
+ pull_request:
7
+ # The branches below must be a subset of the branches above
8
+ branches: [ "main" ]
9
+ # https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning#avoiding-unnecessary-scans-of-pull-requests
10
+ paths-ignore:
11
+ - '**/*.md'
12
+ - '**/*.txt'
13
+ schedule:
14
+ - cron: '41 22 * * 5'
15
+
16
+ jobs:
17
+ scan:
18
+ name: Scan
19
+ runs-on: [ ubuntu-latest ]
20
+ permissions:
21
+ actions: read
22
+ contents: read
23
+ security-events: write
24
+
25
+ strategy:
26
+ # Setting fail-fast to false to prevent a failed scan in
27
+ # any of the matrix.language's from stopping the other scans
28
+ # If there are multiple offenses, better to find/report them
29
+ # all at once
30
+ fail-fast: false
31
+ matrix:
32
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
33
+ # https://aka.ms/codeql-docs/language-support
34
+ language: [ 'ruby' ]
35
+
36
+
37
+ steps:
38
+ - name: Checkout repository
39
+ uses: actions/checkout@v3
40
+
41
+ # Initializes the CodeQL tools for scanning.
42
+ - name: Initialize CodeQL
43
+ uses: github/codeql-action/init@v2
44
+ with:
45
+ languages: ${{ matrix.language }}
46
+ # If you wish to specify custom queries, you can do so here or in a config file.
47
+ # By default, queries listed here will override any specified in a config file.
48
+ # Prefix the list here with "+" to use these queries and those in the config file.
49
+
50
+ # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
51
+ # queries: security-extended,security-and-quality
52
+
53
+ # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
54
+ # If this step fails, then you should remove it and run the build manually (see below)
55
+ - name: Autobuild
56
+ uses: github/codeql-action/autobuild@v2
57
+
58
+ # ℹ️ Command-line programs to run using the OS shell.
59
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
60
+
61
+ # If the Autobuild fails above, remove it and uncomment the following three lines.
62
+ # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
63
+
64
+ # - run: |
65
+ # echo "Run, Build Application using script"
66
+ # ./location_of_script_within_repo/buildscript.sh
67
+
68
+ - name: Perform CodeQL Analysis
69
+ uses: github/codeql-action/analyze@v2
70
+ with:
71
+ category: "/language:${{matrix.language}}"
@@ -0,0 +1,15 @@
1
+ name: 'Dependency Review'
2
+ on: [pull_request]
3
+ permissions:
4
+ contents: read
5
+ jobs:
6
+ dependency-review:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - name: 'Checkout Repository'
10
+ uses: actions/checkout@v3
11
+ - name: Dependency Review
12
+ uses: actions/dependency-review-action@v3
13
+ with:
14
+ # Possible values: "critical", "high", "moderate", "low"
15
+ fail-on-severity: high
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
+ ## 6.0.3
10
+ - Fix `FeatureFlagActive` cop so that it allows feature flag names to be constants and dot method calls in addition to strings.
11
+
12
+ ## 6.0.2
13
+ - Upgrade rubocop-rspec to v2.22.0 to use the new FactoryBot namespaces.
14
+ - Fix the following wrong namespaces related to `FactoryBot`: `RSpec/FactoryBot/AttributeDefinedStatically`, `RSpec/FactoryBot/CreateList` and `RSpec/FactoryBot/FactoryClassName`.
15
+
9
16
  ## 6.0.1
10
17
  - Fix a bug in the `FeatureFlagNameValid` cop where the titlecase regex matcher was incorrectly finding offenses.
11
18
 
@@ -13,7 +20,7 @@ Prior to v1.0.0 this gem was versioned based on the `MAJOR`.`MINOR` version of R
13
20
  - Add `FeatureFlagNameValid` cop to validate correct feature flag name format, [adopted from the cop](https://github.com/ezcater/ez-rails/blob/2d9272eb3d2c71dc5ebc2aa01a849cf9cfae3df2/cops/rubocop/cops/feature_flags_flag_name.rb_) in `ez-rails`.
14
21
 
15
22
  ## 5.2.1
16
- - Fix the has the wrong namespace for `RSpec/Capybara/CurrentPathExpectation` and `RSpec/Capybara/VisibilityMatcher` cops, since [they've been extracted](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md#2180-2023-01-16) into a separate repo [rubocop-capybara](https://github.com/rubocop/rubocop-capybara).
23
+ - Fix the wrong namespace for `RSpec/Capybara/CurrentPathExpectation` and `RSpec/Capybara/VisibilityMatcher` cops, since [they've been extracted](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md#2180-2023-01-16) into a separate repo [rubocop-capybara](https://github.com/rubocop/rubocop-capybara).
17
24
 
18
25
  ## 5.2.0
19
26
 
data/conf/rubocop.yml CHANGED
@@ -245,13 +245,13 @@ RSpec/Capybara/FeatureMethods:
245
245
  RSpec/EmptyHook:
246
246
  Enabled: true
247
247
 
248
- RSpec/FactoryBot/AttributeDefinedStatically:
248
+ FactoryBot/AttributeDefinedStatically:
249
249
  Enabled: true
250
250
 
251
- RSpec/FactoryBot/CreateList:
251
+ FactoryBot/CreateList:
252
252
  Enabled: true
253
253
 
254
- RSpec/FactoryBot/FactoryClassName:
254
+ FactoryBot/FactoryClassName:
255
255
  Enabled: true
256
256
 
257
257
  RSpec/MultipleMemoizedHelpers:
@@ -55,5 +55,5 @@ Gem::Specification.new do |spec|
55
55
  spec.add_runtime_dependency "rubocop", ">= 1.16.0", "< 2.0"
56
56
  spec.add_runtime_dependency "rubocop-graphql", ">= 0.14.0", "< 1.0"
57
57
  spec.add_runtime_dependency "rubocop-rails", ">= 2.10.1", "< 3.0"
58
- spec.add_runtime_dependency "rubocop-rspec", ">= 2.3.0", "< 3.0"
58
+ spec.add_runtime_dependency "rubocop-rspec", ">= 2.22.0", "< 3.0"
59
59
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EzcaterRubocop
4
- VERSION = "6.0.1"
4
+ VERSION = "6.0.3"
5
5
  end
@@ -23,6 +23,7 @@ require "rubocop/cop/ezcater/rails_configuration"
23
23
  require "rubocop/cop/ezcater/rails_env"
24
24
  require "rubocop/cop/ezcater/ruby_timeout"
25
25
  require "rubocop/cop/ezcater/rails_top_level_sql_execute"
26
+ require "rubocop/cop/ezcater/require_custom_error"
26
27
  require "rubocop/cop/ezcater/require_gql_error_helpers"
27
28
  require "rubocop/cop/ezcater/rspec_match_ordered_array"
28
29
  require "rubocop/cop/ezcater/rspec_require_browser_mock"
@@ -12,15 +12,20 @@ module RuboCop
12
12
  # EzFF.active?("FlagName", identifiers: ["user:12345", "user:23456"])
13
13
  # EzFF.active?(defined_flag_name_var, tracking_id: "brand:12345")
14
14
  # EzFF.active?(@flag_name_ivar, tracking_id: "brand:12345")
15
+ # EzFF.active?(CONSTANT_NAME, tracking_id: "brand:12345")
16
+ # EzFF.active?(config.flag_name, tracking_id: "brand:12345")
15
17
  #
16
18
  # # bad
17
19
  # EzFF.active?("FlagName")
18
20
  # EzFF.active?(defined_flag_name_var)
19
21
  # EzFF.active?(@flag_name_ivar)
22
+ # EzFF.active?(:symbol_name, tracking_id: "brand:12345")
23
+ # EzFF.active?(123, identifiers: ["user:12345"])
20
24
 
21
25
  class FeatureFlagActive < Cop
22
26
  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"
27
+ FIRST_PARAM_MSG = "The first argument to `EzFF.active?` must be a string literal or a variable " \
28
+ "or constant assigned to a string"
24
29
 
25
30
  def_node_matcher :ezff_active_one_arg, <<-PATTERN
26
31
  (send
@@ -30,7 +35,7 @@ module RuboCop
30
35
  def_node_matcher :args_matcher, <<-PATTERN
31
36
  (send
32
37
  (_ _ {:EzFF :EzcaterFeatureFlag}) :active?
33
- ${str lvar ivar}
38
+ $_
34
39
  (_
35
40
  (pair
36
41
  (sym {:tracking_id :identifiers})
@@ -38,9 +43,9 @@ module RuboCop
38
43
  ...))
39
44
  PATTERN
40
45
 
41
- def_node_matcher :first_param_good, <<-PATTERN
46
+ def_node_matcher :first_param_bad, <<-PATTERN
42
47
  (send
43
- (_ _ {:EzFF :EzcaterFeatureFlag}) :active? ${str lvar ivar} ...)
48
+ (_ _ {:EzFF :EzcaterFeatureFlag}) :active? ${sym int} ...)
44
49
  PATTERN
45
50
 
46
51
  def_node_matcher :method_call_matcher, <<-PATTERN
@@ -51,7 +56,7 @@ module RuboCop
51
56
  def on_send(node)
52
57
  return unless method_call_matcher(node)
53
58
 
54
- if !first_param_good(node)
59
+ if first_param_bad(node)
55
60
  add_offense(node, location: :expression, message: FIRST_PARAM_MSG)
56
61
  end
57
62
 
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Ezcater
6
+ # Checks for `raise` on `StandardError` and `ArgumentError`.
7
+ # We want to be explicit about the error we're raising and use a custom error
8
+ #
9
+ # @example
10
+ # # bad
11
+ # raise StandardError, "You can't do that"
12
+ #
13
+ # # good
14
+ # raise OrderActionNotAllowed
15
+
16
+ class RequireCustomError < Cop
17
+ MSG = "Use a custom error class that inherits from StandardError when raising an exception"
18
+
19
+ def_node_matcher :raising_standard_or_argument_error,
20
+ "(send nil? {:raise :fail} (const nil? {:StandardError :ArgumentError} ...) ...)"
21
+
22
+ def_node_matcher :initializing_standard_or_argument_error,
23
+ "(send nil? {:raise :fail} (send (const nil? {:StandardError :ArgumentError} ...) ...))"
24
+
25
+ def on_send(node)
26
+ raising_standard_or_argument_error(node) do
27
+ add_offense(node, message: format(MSG))
28
+ end
29
+
30
+ initializing_standard_or_argument_error(node) do
31
+ add_offense(node, message: format(MSG))
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ 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: 6.0.1
4
+ version: 6.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ezCater, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-02 00:00:00.000000000 Z
11
+ date: 2023-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -174,7 +174,7 @@ dependencies:
174
174
  requirements:
175
175
  - - ">="
176
176
  - !ruby/object:Gem::Version
177
- version: 2.3.0
177
+ version: 2.22.0
178
178
  - - "<"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '3.0'
@@ -184,7 +184,7 @@ dependencies:
184
184
  requirements:
185
185
  - - ">="
186
186
  - !ruby/object:Gem::Version
187
- version: 2.3.0
187
+ version: 2.22.0
188
188
  - - "<"
189
189
  - !ruby/object:Gem::Version
190
190
  version: '3.0'
@@ -198,6 +198,8 @@ extra_rdoc_files: []
198
198
  files:
199
199
  - ".github/CODEOWNERS"
200
200
  - ".github/PULL_REQUEST_TEMPLATE.md"
201
+ - ".github/workflows/codeql.yml"
202
+ - ".github/workflows/dependency-review.yml"
201
203
  - ".tool-versions"
202
204
  - CHANGELOG.md
203
205
  - Gemfile
@@ -217,6 +219,7 @@ files:
217
219
  - lib/rubocop/cop/ezcater/rails_configuration.rb
218
220
  - lib/rubocop/cop/ezcater/rails_env.rb
219
221
  - lib/rubocop/cop/ezcater/rails_top_level_sql_execute.rb
222
+ - lib/rubocop/cop/ezcater/require_custom_error.rb
220
223
  - lib/rubocop/cop/ezcater/require_gql_error_helpers.rb
221
224
  - lib/rubocop/cop/ezcater/rspec_dot_not_self_dot.rb
222
225
  - lib/rubocop/cop/ezcater/rspec_match_ordered_array.rb