ezcater_rubocop 0.49.3 → 0.49.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +1 -0
- data/config/default.yml +4 -0
- data/lib/ezcater_rubocop.rb +1 -0
- data/lib/ezcater_rubocop/version.rb +1 -1
- data/lib/rubocop/cop/ezcater/rspec_require_gql_error_helpers.rb +35 -0
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b1eebe376c776e260d533d0ed1df2af63fea9bd3
|
|
4
|
+
data.tar.gz: 8152ea09ee64ece4592a5bd03f8e03c45530de30
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 07b710a2d92db3db77b6eb9bdc2fd5c1b615f97d4356ee2af26ab0e176e93770db146efb3ae08e0cf532e08cd4355d7c1619179b580658fcc8f5b8baaff8dfd6
|
|
7
|
+
data.tar.gz: 93047bd242a44230b4d30e78dcb27ac32580eafcd767b9c6b1128500a620b8a5f008c28012f5ffea2726121ff903251d96d4cf851a7456d9f06d53c55f2542af
|
data/CHANGELOG.md
CHANGED
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
|
data/config/default.yml
CHANGED
|
@@ -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
|
data/lib/ezcater_rubocop.rb
CHANGED
|
@@ -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"
|
|
@@ -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.
|
|
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:
|
|
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.
|
|
163
|
+
rubygems_version: 2.5.2
|
|
163
164
|
signing_key:
|
|
164
165
|
specification_version: 4
|
|
165
166
|
summary: ezCater custom cops and shared configuration
|