ezcater_rubocop 3.0.2 → 4.0.0
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 +6 -0
- data/README.md +0 -1
- data/config/default.yml +12 -9
- data/ezcater_rubocop.gemspec +1 -0
- data/lib/ezcater_rubocop/version.rb +1 -1
- data/lib/ezcater_rubocop.rb +1 -1
- metadata +22 -3
- data/lib/rubocop/cop/ezcater/graphql_fields_naming.rb +0 -74
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e4ab0e968f3876d0ce517e56e4f4d4f85d4a512148d76eddc3b90afb27b030e
|
4
|
+
data.tar.gz: 1222c65a574b4aeab13b5372a4e2fc0c4c3af89e6f611dcfd82a41879343e198
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 173c89e6a3c9eb6b022b90ccc0d28c49b44331d42617e082d5fcd1380e0c2b2ad834250608a87556c9dd5e664d770009d1499a77fa002ad4270740b1069f2b44
|
7
|
+
data.tar.gz: 924a0d9ed141df769723ed76ab30aae9625da0f1890ab75125c94f74ca1fa9e0cb6c31b0b4f8c74d0418031890c07f6f4dad1eadedbc1424e314fff32c16bc0f
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,12 @@ 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
|
+
## 4.0.0
|
10
|
+
|
11
|
+
- Add the [rubcop-graphql](https://github.com/DmitryTsepelev/rubocop-graphql) helpers and enable
|
12
|
+
them by default
|
13
|
+
- Remove `Ezcater/GraphqlFieldsNaming` cop. The same rule exists in `rubocop-graphql`.
|
14
|
+
|
9
15
|
## v3.0.2
|
10
16
|
|
11
17
|
- Loosen restrictions to allow for Ruby 3.1 and latest dependency gems
|
data/README.md
CHANGED
@@ -82,7 +82,6 @@ This gem is using [Semantic Versioning](https://semver.org/). All version bumps
|
|
82
82
|
1. [RspecRequireFeatureFlagMock](https://github.com/ezcater/ezcater_rubocop/blob/main/lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb) - Enforce use of `mock_feature_flag` helper instead of mocking `FeatureFlag.is_active?` directly.
|
83
83
|
1. [RspecRequireHttpStatusMatcher](https://github.com/ezcater/ezcater_rubocop/blob/main/lib/rubocop/cop/ezcater/rspec_require_http_status_matcher.rb) - Use the HTTP status code matcher, like `expect(response).to have_http_status :bad_request`, rather than `expect(response.code).to eq 400`
|
84
84
|
1. [StyleDig](https://github.com/ezcater/ezcater_rubocop/blob/main/lib/rubocop/cop/ezcater/style_dig.rb) - Recommend `dig` for deeply nested access.
|
85
|
-
1. [GraphqlFieldsNaming](https://github.com/ezcater/ezcater_rubocop/blob/main/lib/rubocop/cop/ezcater/graphql_fields_naming.rb) - Enforce the configured style when naming graphQL fields and arguments.
|
86
85
|
|
87
86
|
## Development
|
88
87
|
|
data/config/default.yml
CHANGED
@@ -1,12 +1,3 @@
|
|
1
|
-
Ezcater/GraphqlFieldsNaming:
|
2
|
-
EnforcedStyle: snake_case
|
3
|
-
Enabled: true
|
4
|
-
SupportedStyles:
|
5
|
-
- snake_case
|
6
|
-
- camelCase
|
7
|
-
Include:
|
8
|
-
- "app/graphql/**/*.rb"
|
9
|
-
|
10
1
|
Ezcater/RailsConfiguration:
|
11
2
|
Description: "Enforce the use of `Rails.configuration` instead of `Rails.application.config`."
|
12
3
|
Enabled: true
|
@@ -59,3 +50,15 @@ Ezcater/StyleDig:
|
|
59
50
|
Ezcater/RubyTimeout:
|
60
51
|
Description: "Disallow use of `Timeout.timeout` because it is unsafe and can cause unexpected behavior."
|
61
52
|
Enabled: true
|
53
|
+
|
54
|
+
GraphQL/FieldDescription:
|
55
|
+
Enabled: false
|
56
|
+
GraphQL/ArgumentDescription:
|
57
|
+
Enabled: false
|
58
|
+
GraphQL/ObjectDescription:
|
59
|
+
Include:
|
60
|
+
- "**/types/**/*.rb"
|
61
|
+
- "**/mutations/**/*.rb"
|
62
|
+
GraphQL/ExtractInputType:
|
63
|
+
Exclude:
|
64
|
+
- "**/input_objects/**/*.rb"
|
data/ezcater_rubocop.gemspec
CHANGED
@@ -53,6 +53,7 @@ Gem::Specification.new do |spec|
|
|
53
53
|
|
54
54
|
spec.add_runtime_dependency "parser", ">= 2.6"
|
55
55
|
spec.add_runtime_dependency "rubocop", ">= 1.16.0", "< 2.0"
|
56
|
+
spec.add_runtime_dependency "rubocop-graphql", ">= 0.14.0", "< 1.0"
|
56
57
|
spec.add_runtime_dependency "rubocop-rails", ">= 2.10.1", "< 3.0"
|
57
58
|
spec.add_runtime_dependency "rubocop-rspec", ">= 2.3.0", "< 3.0"
|
58
59
|
end
|
data/lib/ezcater_rubocop.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "ezcater_rubocop/version"
|
4
|
+
require "rubocop-graphql"
|
4
5
|
require "rubocop-rails"
|
5
6
|
require "rubocop-rspec"
|
6
7
|
|
@@ -17,7 +18,6 @@ RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
|
|
17
18
|
|
18
19
|
require "rubocop/cop/ezcater/direct_env_check"
|
19
20
|
require "rubocop/cop/ezcater/feature_flag_active"
|
20
|
-
require "rubocop/cop/ezcater/graphql_fields_naming"
|
21
21
|
require "rubocop/cop/ezcater/rails_configuration"
|
22
22
|
require "rubocop/cop/ezcater/rails_env"
|
23
23
|
require "rubocop/cop/ezcater/ruby_timeout"
|
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:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ezCater, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -128,6 +128,26 @@ dependencies:
|
|
128
128
|
- - "<"
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '2.0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: rubocop-graphql
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 0.14.0
|
138
|
+
- - "<"
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '1.0'
|
141
|
+
type: :runtime
|
142
|
+
prerelease: false
|
143
|
+
version_requirements: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: 0.14.0
|
148
|
+
- - "<"
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '1.0'
|
131
151
|
- !ruby/object:Gem::Dependency
|
132
152
|
name: rubocop-rails
|
133
153
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,7 +213,6 @@ files:
|
|
193
213
|
- lib/ezcater_rubocop/version.rb
|
194
214
|
- lib/rubocop/cop/ezcater/direct_env_check.rb
|
195
215
|
- lib/rubocop/cop/ezcater/feature_flag_active.rb
|
196
|
-
- lib/rubocop/cop/ezcater/graphql_fields_naming.rb
|
197
216
|
- lib/rubocop/cop/ezcater/rails_configuration.rb
|
198
217
|
- lib/rubocop/cop/ezcater/rails_env.rb
|
199
218
|
- lib/rubocop/cop/ezcater/rails_top_level_sql_execute.rb
|
@@ -1,74 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module Ezcater
|
6
|
-
# This cop makes sure that GraphQL fields & arguments match the supported style
|
7
|
-
# https://git.io/JeofW
|
8
|
-
#
|
9
|
-
# The cop also ignores when users provide a :camelize option, because
|
10
|
-
# the user is manually requesting to override the value
|
11
|
-
#
|
12
|
-
# @example
|
13
|
-
# # bad
|
14
|
-
# field :fooBar, ID, null: false
|
15
|
-
# argument :barBaz, ID, required: true
|
16
|
-
#
|
17
|
-
# # good
|
18
|
-
# field :foo_bar, ID, null: true
|
19
|
-
# field :foo_bar, ID, null: true do
|
20
|
-
# argument :bar_baz, ID, required: true
|
21
|
-
# end
|
22
|
-
#
|
23
|
-
# field :fooBar, ID, null: true, camelize: true
|
24
|
-
#
|
25
|
-
class GraphqlFieldsNaming < Cop
|
26
|
-
include ConfigurableNaming
|
27
|
-
|
28
|
-
MSG = "Use %<style>s for GraphQL fields & arguments names. " \
|
29
|
-
"See https://git.io/JeofW for our guide. " \
|
30
|
-
"This can be overridden with camelize."
|
31
|
-
FIELD_ADDING_METHODS = %i(field argument).freeze
|
32
|
-
PROCESSABLE_TYPES = %i(sym string).freeze
|
33
|
-
|
34
|
-
def on_send(node)
|
35
|
-
method = method_name(node)
|
36
|
-
first_arg = node.first_argument
|
37
|
-
|
38
|
-
return unless FIELD_ADDING_METHODS.include? method
|
39
|
-
return unless PROCESSABLE_TYPES.include?(first_arg&.type)
|
40
|
-
|
41
|
-
return if includes_camelize?(node)
|
42
|
-
|
43
|
-
check_name(node, first_arg.value, node.first_argument)
|
44
|
-
end
|
45
|
-
|
46
|
-
alias on_super on_send
|
47
|
-
alias on_yield on_send
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def includes_camelize?(node)
|
52
|
-
results = []
|
53
|
-
node.last_argument.each_child_node { |arg| results << args_include_camelize?(arg) }
|
54
|
-
results.any?
|
55
|
-
end
|
56
|
-
|
57
|
-
def args_include_camelize?(arg_pair)
|
58
|
-
key_node = arg_pair.key
|
59
|
-
_value_node = arg_pair.value
|
60
|
-
|
61
|
-
key_node.value.match?(/camelize/)
|
62
|
-
end
|
63
|
-
|
64
|
-
def method_name(node)
|
65
|
-
node.children[1]
|
66
|
-
end
|
67
|
-
|
68
|
-
def message(msg_style)
|
69
|
-
format(MSG, style: msg_style)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|