ezcater_rubocop 0.49.3 → 0.49.4

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: 287e541c5f186427bfc57b726752e5d4408aa824
4
- data.tar.gz: 9bc958aef437ee556c7647a8f8d147cc2787cc35
3
+ metadata.gz: b1eebe376c776e260d533d0ed1df2af63fea9bd3
4
+ data.tar.gz: 8152ea09ee64ece4592a5bd03f8e03c45530de30
5
5
  SHA512:
6
- metadata.gz: 20ab3901dd6dc56de4371de61a42107df8f7a8eb4ce0ebc647dd6722f5f2e5e35667b8e8a711b0c40158f2e51a23ba4667db32626669054efbe308ae2c73435c
7
- data.tar.gz: 9f39db662304bf6b2fae9b2155708dd5b76b1528b0c9abaf8c09b639a4704fcda80ee1a474a5c3e6837598d1c95d8eb37977ccad091ff6d69af85a3c60adf5bf
6
+ metadata.gz: 07b710a2d92db3db77b6eb9bdc2fd5c1b615f97d4356ee2af26ab0e176e93770db146efb3ae08e0cf532e08cd4355d7c1619179b580658fcc8f5b8baaff8dfd6
7
+ data.tar.gz: 93047bd242a44230b4d30e78dcb27ac32580eafcd767b9c6b1128500a620b8a5f008c28012f5ffea2726121ff903251d96d4cf851a7456d9f06d53c55f2542af
@@ -1,5 +1,8 @@
1
1
  # ezcater_rubocop
2
2
 
3
+ # v0.49.4
4
+ - Add `Ezcater/RspecRequireGqlErrorHelpers` cop.
5
+
3
6
  # v0.49.3
4
7
  - Do not apply `Ezcater/StyleDig` to access using a range.
5
8
 
data/README.md CHANGED
@@ -50,6 +50,7 @@ is updated.
50
50
  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.
51
51
  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.
52
52
  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.
53
+ 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.
53
54
  1. [StyleDig](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/style_dig.rb) - Recommend `dig` for deeply nested access.
54
55
 
55
56
  ## Development
@@ -16,6 +16,10 @@ Ezcater/RspecRequireFeatureFlagMock:
16
16
  Include:
17
17
  - '**/*_spec.rb'
18
18
 
19
+ Ezcater/RspecRequireGqlErrorHelpers:
20
+ Description: 'Use the helpers provided by `GQLErrors` instead of raising `GraphQL::ExecutionError` directly.'
21
+ Enabled: true
22
+
19
23
  Ezcater/StyleDig:
20
24
  Description: 'Recommend `dig` for deeply nested access.'
21
25
  Enabled: true
@@ -14,5 +14,6 @@ RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
14
14
 
15
15
  require "rubocop/cop/ezcater/rspec_require_browser_mock"
16
16
  require "rubocop/cop/ezcater/rspec_require_feature_flag_mock"
17
+ require "rubocop/cop/ezcater/rspec_require_gql_error_helpers"
17
18
  require "rubocop/cop/ezcater/rspec_dot_not_self_dot"
18
19
  require "rubocop/cop/ezcater/style_dig"
@@ -1,3 +1,3 @@
1
1
  module EzcaterRubocop
2
- VERSION = "0.49.3".freeze
2
+ VERSION = "0.49.4".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, :expression, 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.49.3
4
+ version: 0.49.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ezCater, Inc
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-17 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
@@ -136,6 +136,7 @@ files:
136
136
  - lib/rubocop/cop/ezcater/rspec_dot_not_self_dot.rb
137
137
  - lib/rubocop/cop/ezcater/rspec_require_browser_mock.rb
138
138
  - lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb
139
+ - lib/rubocop/cop/ezcater/rspec_require_gql_error_helpers.rb
139
140
  - lib/rubocop/cop/ezcater/style_dig.rb
140
141
  - lib/rubocop/rspec/language/each_selector.rb
141
142
  homepage: https://github.com/ezcater/ezcater_rubocop
@@ -159,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
160
  version: '0'
160
161
  requirements: []
161
162
  rubyforge_project:
162
- rubygems_version: 2.6.13
163
+ rubygems_version: 2.5.2
163
164
  signing_key:
164
165
  specification_version: 4
165
166
  summary: ezCater custom cops and shared configuration