rubocop-graphql 1.5.4 → 1.5.5
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/README.md +9 -4
- data/lib/rubocop/cop/graphql/ordered_fields.rb +2 -0
- data/lib/rubocop/cop/graphql/unused_argument.rb +4 -4
- data/lib/rubocop/graphql/heredoc.rb +1 -1
- data/lib/rubocop/graphql/plugin.rb +31 -0
- data/lib/rubocop/graphql/version.rb +1 -1
- data/lib/rubocop/graphql.rb +1 -6
- data/lib/rubocop-graphql.rb +1 -3
- metadata +21 -9
- data/lib/rubocop/graphql/inject.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ee5569071019423fb93f2d3a6ef5f20d9149e5d650cf13b3f54e54fbe2bb979
|
4
|
+
data.tar.gz: 53b3bb5710e42c42cc759195b762bbb9a5dc8073a7cebd6e6e10155909277582
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93602bdec3e0672725cb1607d28432c6279e6f28e1faee2eb7279d5a14601986bceaf0898eb86a702541f04c0648465eeb972b84ede3aafc42cb7603dc9f5335
|
7
|
+
data.tar.gz: d187ab697121d4e5d1f36ce1238febbfe2dd8d8e194f06d28ecfc768836a3f1d04a68d633effb4f20b5aa4f6ed7ef33227f426c7ceaa58c4966adae6bf51d4ca
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
[Rubocop](https://github.com/rubocop-hq/rubocop) extension for enforcing [graphql-ruby](https://github.com/rmosolgo/graphql-ruby) best practices.
|
4
4
|
|
5
|
+
You can support my open–source work [here](https://boosty.to/dmitry_tsepelev).
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
Install the gem:
|
@@ -25,30 +27,33 @@ You need to tell RuboCop to load the GraphQL extension. There are three ways to
|
|
25
27
|
Put this into your `.rubocop.yml`.
|
26
28
|
|
27
29
|
```yaml
|
28
|
-
|
30
|
+
plugins: rubocop-graphql
|
29
31
|
```
|
30
32
|
|
31
33
|
Alternatively, use the following array notation when specifying multiple extensions.
|
32
34
|
|
33
35
|
```yaml
|
34
|
-
|
36
|
+
plugins:
|
35
37
|
- rubocop-other-extension
|
36
38
|
- rubocop-graphql
|
37
39
|
```
|
38
40
|
|
39
41
|
Now you can run `rubocop` and it will automatically load the RuboCop GraphQL cops together with the standard cops.
|
40
42
|
|
43
|
+
> [!NOTE]
|
44
|
+
> The plugin system is supported in RuboCop 1.72+. In earlier versions, use `require` instead of `plugins`.
|
45
|
+
|
41
46
|
### Command line
|
42
47
|
|
43
48
|
```sh
|
44
|
-
rubocop --
|
49
|
+
rubocop --plugins rubocop-graphql
|
45
50
|
```
|
46
51
|
|
47
52
|
### Rake task
|
48
53
|
|
49
54
|
```ruby
|
50
55
|
RuboCop::RakeTask.new do |task|
|
51
|
-
task.
|
56
|
+
task.plugins << 'rubocop-graphql'
|
52
57
|
end
|
53
58
|
```
|
54
59
|
|
@@ -103,7 +103,7 @@ module RuboCop
|
|
103
103
|
|
104
104
|
def find_unresolved_args(method_node, declared_arg_nodes)
|
105
105
|
resolve_method_kwargs = method_node.arguments.select do |arg|
|
106
|
-
arg.
|
106
|
+
arg.type?(:kwarg, :kwoptarg)
|
107
107
|
end
|
108
108
|
resolve_method_kwargs_names = resolve_method_kwargs.map do |node|
|
109
109
|
node.node_parts[0]
|
@@ -116,7 +116,7 @@ module RuboCop
|
|
116
116
|
|
117
117
|
def ignore_arguments_type?(resolve_method_node)
|
118
118
|
resolve_method_node.arguments.any? do |arg|
|
119
|
-
arg.
|
119
|
+
arg.type?(:arg, :kwrestarg, :forward_arg)
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
@@ -172,11 +172,11 @@ module RuboCop
|
|
172
172
|
end
|
173
173
|
|
174
174
|
def scope_changing_syntax?(node)
|
175
|
-
node.
|
175
|
+
node.type?(:def, :defs, :class, :module)
|
176
176
|
end
|
177
177
|
|
178
178
|
def block_or_lambda?(node)
|
179
|
-
node.
|
179
|
+
node.type?(:block, :lambda)
|
180
180
|
end
|
181
181
|
|
182
182
|
# @!method argument_declaration?(node)
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "lint_roller"
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module GraphQL
|
7
|
+
# A plugin that integrates rubocop-graphql with RuboCop's plugin system.
|
8
|
+
class Plugin < LintRoller::Plugin
|
9
|
+
def about
|
10
|
+
LintRoller::About.new(
|
11
|
+
name: "rubocop-graphql",
|
12
|
+
version: VERSION,
|
13
|
+
homepage: "https://github.com/DmitryTsepelev/rubocop-graphql",
|
14
|
+
description: "RuboCop extension for enforcing graphql-ruby best practices."
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def supported?(context)
|
19
|
+
context.engine == :rubocop
|
20
|
+
end
|
21
|
+
|
22
|
+
def rules(_context)
|
23
|
+
LintRoller::Rules.new(
|
24
|
+
type: :path,
|
25
|
+
config_format: :rubocop,
|
26
|
+
value: Pathname.new(__dir__).join("../../../config/default.yml")
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/rubocop/graphql.rb
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module RuboCop
|
4
|
-
# RuboCop GraphQL project namespace
|
4
|
+
# RuboCop GraphQL project namespace.
|
5
5
|
module GraphQL
|
6
|
-
PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
|
7
|
-
CONFIG_DEFAULT = PROJECT_ROOT.join("config", "default.yml").freeze
|
8
|
-
CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
|
9
|
-
|
10
|
-
private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
|
11
6
|
end
|
12
7
|
end
|
data/lib/rubocop-graphql.rb
CHANGED
@@ -6,7 +6,7 @@ require_relative "rubocop/graphql/ext/snake_case"
|
|
6
6
|
|
7
7
|
require_relative "rubocop/graphql"
|
8
8
|
require_relative "rubocop/graphql/version"
|
9
|
-
require_relative "rubocop/graphql/
|
9
|
+
require_relative "rubocop/graphql/plugin"
|
10
10
|
require_relative "rubocop/graphql/compare_order"
|
11
11
|
require_relative "rubocop/graphql/description_method"
|
12
12
|
require_relative "rubocop/graphql/heredoc"
|
@@ -24,6 +24,4 @@ require_relative "rubocop/graphql/field/block"
|
|
24
24
|
require_relative "rubocop/graphql/field/kwargs"
|
25
25
|
require_relative "rubocop/graphql/schema_member"
|
26
26
|
|
27
|
-
RuboCop::GraphQL::Inject.defaults!
|
28
|
-
|
29
27
|
require_relative "rubocop/cop/graphql_cops"
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Tsepelev
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-03-18 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler
|
@@ -52,13 +51,27 @@ dependencies:
|
|
52
51
|
- - "~>"
|
53
52
|
- !ruby/object:Gem::Version
|
54
53
|
version: '3.9'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: lint_roller
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1.1'
|
61
|
+
type: :runtime
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.1'
|
55
68
|
- !ruby/object:Gem::Dependency
|
56
69
|
name: rubocop
|
57
70
|
requirement: !ruby/object:Gem::Requirement
|
58
71
|
requirements:
|
59
72
|
- - ">="
|
60
73
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
74
|
+
version: 1.72.1
|
62
75
|
- - "<"
|
63
76
|
- !ruby/object:Gem::Version
|
64
77
|
version: '2'
|
@@ -68,7 +81,7 @@ dependencies:
|
|
68
81
|
requirements:
|
69
82
|
- - ">="
|
70
83
|
- !ruby/object:Gem::Version
|
71
|
-
version:
|
84
|
+
version: 1.72.1
|
72
85
|
- - "<"
|
73
86
|
- !ruby/object:Gem::Version
|
74
87
|
version: '2'
|
@@ -123,9 +136,9 @@ files:
|
|
123
136
|
- lib/rubocop/graphql/field/block.rb
|
124
137
|
- lib/rubocop/graphql/field/kwargs.rb
|
125
138
|
- lib/rubocop/graphql/heredoc.rb
|
126
|
-
- lib/rubocop/graphql/inject.rb
|
127
139
|
- lib/rubocop/graphql/node_pattern.rb
|
128
140
|
- lib/rubocop/graphql/node_uniqueness.rb
|
141
|
+
- lib/rubocop/graphql/plugin.rb
|
129
142
|
- lib/rubocop/graphql/schema_member.rb
|
130
143
|
- lib/rubocop/graphql/sorbet.rb
|
131
144
|
- lib/rubocop/graphql/swap_range.rb
|
@@ -137,7 +150,7 @@ metadata:
|
|
137
150
|
homepage_uri: https://github.com/DmitryTsepelev/rubocop-graphql
|
138
151
|
source_code_uri: https://github.com/DmitryTsepelev/rubocop-graphql
|
139
152
|
changelog_uri: https://github.com/DmitryTsepelev/rubocop-graphql/blob/master/CHANGELOG.md
|
140
|
-
|
153
|
+
default_lint_roller_plugin: RuboCop::GraphQL::Plugin
|
141
154
|
rdoc_options: []
|
142
155
|
require_paths:
|
143
156
|
- lib
|
@@ -152,8 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
165
|
- !ruby/object:Gem::Version
|
153
166
|
version: '0'
|
154
167
|
requirements: []
|
155
|
-
rubygems_version: 3.
|
156
|
-
signing_key:
|
168
|
+
rubygems_version: 3.6.2
|
157
169
|
specification_version: 4
|
158
170
|
summary: Automatic performance checking tool for Ruby code.
|
159
171
|
test_files: []
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module GraphQL
|
5
|
-
# Because RuboCop doesn't yet support plugins, we have to monkey patch in a
|
6
|
-
# bit of our configuration.
|
7
|
-
module Inject
|
8
|
-
def self.defaults!
|
9
|
-
path = CONFIG_DEFAULT.to_s
|
10
|
-
hash = ConfigLoader.send(:load_yaml_configuration, path)
|
11
|
-
config = Config.new(hash, path).tap(&:make_excludes_absolute)
|
12
|
-
puts "configuration from \#{path}" if ConfigLoader.debug?
|
13
|
-
config = ConfigLoader.merge_with_default(config, path)
|
14
|
-
ConfigLoader.instance_variable_set(:@default_configuration, config)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|