ezcater_rubocop 0.51.4 → 0.51.5

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
  SHA1:
3
- metadata.gz: 533086d512870d79f36bab5edde478a041a32c13
4
- data.tar.gz: 317c614d1530561d6d21b9f682acf5171a8f389a
3
+ metadata.gz: 2e1e4b74af46fc4543ab92ab20a575118a881c72
4
+ data.tar.gz: 864de83177e58cdcb3af668d6e10feb53dd1f2ae
5
5
  SHA512:
6
- metadata.gz: ae0fb1e7daa7b2ac3a2f251fe961b0af2d5c41355de2505e6857b53e38244ea80dc76248c74aa127cabd9e9deebb398fd4db541da257218df8c560d5d0338a04
7
- data.tar.gz: 4e0247ac0a40198c7dcff2fe98159220526e61fe11a759023e87c33e86d32c1ebca188fccc5cb5b04a822101af6e1ff0d399fe0d75fb54aea6ab4f804bc53406
6
+ metadata.gz: 3efb0a9492f109fa603cab846955dcf90265b3c0f93213ecba47dbc63cf0ec4ca95691aa69f30ea423130be54d3b8010e3951343de43b17567125045a4d72cf3
7
+ data.tar.gz: d3bb33303ea534109ff12c212ac32cfc70282a364f2bfb49328a6358f06cb5474a226655dea568d1e93e2e8edb4e0e122568ca98f1e0b4e5b5284e8d95fa161f
@@ -1,5 +1,8 @@
1
1
  # ezcater_rubocop
2
2
 
3
+ ## v0.51.5
4
+ - Add `Ezcater/RspecRequireGqlErrorHelpers` cop.
5
+
3
6
  ## v0.51.4
4
7
  - Exclude `Gemfile` for the `Metrics/LineLength` cop.
5
8
  - Add `system` to the excluded spec directories for `RSpec/DescribeClass`.
data/README.md CHANGED
@@ -86,6 +86,7 @@ is updated.
86
86
  1. [RspecDotNotSelfDot](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/rspec_dot_not_self_dot.rb) - Enforce ".<class method>" instead of "self.<class method>" for example group description.
87
87
  1. [RspecRequireBrowserMock](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/rspec_require_browser_mock.rb) - Enforce use of `mock_ezcater_app`, `mock_chrome_browser` & `mock_custom_browser` helpers instead of mocking `Browser` or `EzBrowser` directly.
88
88
  1. [RspecRequireFeatureFlagMock](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb) - Enforce use of `mock_feature_flag` helper instead of mocking `FeatureFlag.is_active?` directly.
89
+ 1. [RspecRequireGqlErrorHelpers](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/rspec_require_gql_error_helpers.rb) - Use the helpers provided by `GQLErrors` instead of raising `GraphQL::ExecutionError` directly.
89
90
  1. [StyleDig](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/style_dig.rb) - Recommend `dig` for deeply nested access.
90
91
 
91
92
  ## Development
@@ -20,6 +20,10 @@ Ezcater/RspecRequireFeatureFlagMock:
20
20
  Include:
21
21
  - '**/*_spec.rb'
22
22
 
23
+ Ezcater/RspecRequireGqlErrorHelpers:
24
+ Description: 'Use the helpers provided by `GQLErrors` instead of raising `GraphQL::ExecutionError` directly.'
25
+ Enabled: true
26
+
23
27
  Ezcater/StyleDig:
24
28
  Description: 'Recommend `dig` for deeply nested access.'
25
29
  Enabled: true
@@ -15,5 +15,6 @@ RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
15
15
  require "rubocop/cop/ezcater/private_attr"
16
16
  require "rubocop/cop/ezcater/rspec_require_browser_mock"
17
17
  require "rubocop/cop/ezcater/rspec_require_feature_flag_mock"
18
+ require "rubocop/cop/ezcater/rspec_require_gql_error_helpers"
18
19
  require "rubocop/cop/ezcater/rspec_dot_not_self_dot"
19
20
  require "rubocop/cop/ezcater/style_dig"
@@ -1,3 +1,3 @@
1
1
  module EzcaterRubocop
2
- VERSION = "0.51.4".freeze
2
+ VERSION = "0.51.5".freeze
3
3
  end
@@ -0,0 +1,35 @@
1
+ module RuboCop
2
+ module Cop
3
+ module Ezcater
4
+ # Enforce use of GQLErrors helpers instead of throwing
5
+ # GraphQL::ExecutionErrors directly
6
+ #
7
+ # @example
8
+ #
9
+ # # good
10
+ # GQLErrors.summary_error("An error occurred")
11
+ # GQLErrors.request_error("You can't access this", 401)
12
+ # GQLErrors.field_error("is invalid", :first_name, "First Name")
13
+ # GQLErrors.field_errors_for(my_model, context)
14
+ # GQLErrors.field_errors_for(my_model, context, summary_error: "An error occurred")
15
+ # GQLErrors.field_errors_for(my_model, context, field_mapping: { first: :first_name })
16
+ #
17
+ # # bad
18
+ # GraphQL::ExecutionError.new("An error occurred")
19
+ # GraphQL::ExecutionError.new("You can't access this", options: { status_code: 401 })
20
+ class RspecRequireGqlErrorHelpers < Cop
21
+ MSG = "Use the helpers provided by `GQLErrors` instead of raising `GraphQL::ExecutionError` directly.".freeze
22
+
23
+ def_node_matcher :graphql_const?, <<~PATTERN
24
+ (const (const _ :GraphQL) :ExecutionError)
25
+ PATTERN
26
+
27
+ def on_const(node)
28
+ return unless graphql_const?(node)
29
+
30
+ add_offense(node, location: :expression, message: MSG)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ 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: 0.51.4
4
+ version: 0.51.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ezCater, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-20 00:00:00.000000000 Z
11
+ date: 2018-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -131,6 +131,7 @@ files:
131
131
  - lib/rubocop/cop/ezcater/rspec_dot_not_self_dot.rb
132
132
  - lib/rubocop/cop/ezcater/rspec_require_browser_mock.rb
133
133
  - lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb
134
+ - lib/rubocop/cop/ezcater/rspec_require_gql_error_helpers.rb
134
135
  - lib/rubocop/cop/ezcater/style_dig.rb
135
136
  - lib/rubocop/rspec/language/each_selector.rb
136
137
  homepage: https://github.com/ezcater/ezcater_rubocop
@@ -154,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
155
  version: '0'
155
156
  requirements: []
156
157
  rubyforge_project:
157
- rubygems_version: 2.6.13
158
+ rubygems_version: 2.5.2
158
159
  signing_key:
159
160
  specification_version: 4
160
161
  summary: ezCater custom cops and shared configuration