ezcater_rubocop 6.0.2 → 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: 74dad3c36b4474ebb1ed730e204ed1256715708736a388dc809ae106256b3b08
4
- data.tar.gz: 34751bbd4b890ba18a534bc5f47860cc6e00121d43ce3b398ddcb921c56afbb0
3
+ metadata.gz: 144220e45db4ba03e7754c0f656cafe7650da1669157b65396c818762e7d9185
4
+ data.tar.gz: b1e19818de9418e2a822ef0d1a3c067870ed36d26c7addb6d831776b4590a25d
5
5
  SHA512:
6
- metadata.gz: c9762748a349377a1f673572a21e5fd71ad80f4a5213f4fb1b95670c65b6cb7093e77b7d01168d0cd8e2bc6947321ebcf8d888f6f9fe945e9d70daee1ad019b1
7
- data.tar.gz: e8da642c516edf9dd7a916ae664261aab3db90873fd68247012a017b22d5affac97f806bc4dbd3a5a2721ab3ebf64d97ade3bf75bc6a872e59b34d01bcfa9d5e
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,9 @@ 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
+
9
12
  ## 6.0.2
10
13
  - Upgrade rubocop-rspec to v2.22.0 to use the new FactoryBot namespaces.
11
14
  - Fix the following wrong namespaces related to `FactoryBot`: `RSpec/FactoryBot/AttributeDefinedStatically`, `RSpec/FactoryBot/CreateList` and `RSpec/FactoryBot/FactoryClassName`.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EzcaterRubocop
4
- VERSION = "6.0.2"
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.2
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-09 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
@@ -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