graphql-doctor 0.1.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 +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +71 -0
- data/Rakefile +9 -0
- data/docs/diagnostics/GQLD101.md +7 -0
- data/docs/diagnostics/GQLD102.md +7 -0
- data/docs/diagnostics/GQLD103.md +7 -0
- data/docs/diagnostics/GQLD104.md +7 -0
- data/docs/diagnostics/GQLD201.md +7 -0
- data/docs/diagnostics/GQLD202.md +7 -0
- data/docs/diagnostics/GQLD203.md +7 -0
- data/docs/diagnostics/GQLD204.md +7 -0
- data/docs/diagnostics/GQLD205.md +7 -0
- data/docs/diagnostics/GQLD301.md +7 -0
- data/docs/diagnostics/GQLD302.md +7 -0
- data/docs/diagnostics/GQLD303.md +7 -0
- data/docs/diagnostics/GQLD305.md +7 -0
- data/docs/diagnostics/GQLD306.md +7 -0
- data/docs/diagnostics/GQLD307.md +7 -0
- data/docs/diagnostics/GQLD401.md +7 -0
- data/docs/diagnostics/README.md +29 -0
- data/exe/graphql-doctor +6 -0
- data/lib/graphql/doctor/cache.rb +47 -0
- data/lib/graphql/doctor/checks/argument_keyword_match.rb +308 -0
- data/lib/graphql/doctor/checks/base.rb +121 -0
- data/lib/graphql/doctor/checks/engine.rb +74 -0
- data/lib/graphql/doctor/checks/resolver_method_presence.rb +68 -0
- data/lib/graphql/doctor/cli.rb +227 -0
- data/lib/graphql/doctor/config.rb +168 -0
- data/lib/graphql/doctor/correlation/correlator.rb +58 -0
- data/lib/graphql/doctor/diagnostic.rb +51 -0
- data/lib/graphql/doctor/ir.rb +30 -0
- data/lib/graphql/doctor/location.rb +52 -0
- data/lib/graphql/doctor/reporters/github.rb +34 -0
- data/lib/graphql/doctor/reporters/json.rb +19 -0
- data/lib/graphql/doctor/reporters/sarif.rb +82 -0
- data/lib/graphql/doctor/reporters/text.rb +47 -0
- data/lib/graphql/doctor/runner.rb +71 -0
- data/lib/graphql/doctor/runtime/dump.rb +137 -0
- data/lib/graphql/doctor/runtime/reflector.rb +313 -0
- data/lib/graphql/doctor/runtime/schema_loader.rb +40 -0
- data/lib/graphql/doctor/source/file_visitor.rb +366 -0
- data/lib/graphql/doctor/source/index.rb +164 -0
- data/lib/graphql/doctor/source/loader.rb +146 -0
- data/lib/graphql/doctor/source/name_mangler.rb +31 -0
- data/lib/graphql/doctor/suppression.rb +39 -0
- data/lib/graphql/doctor/version.rb +7 -0
- data/lib/graphql/doctor.rb +23 -0
- metadata +105 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module GraphQL
|
|
4
|
+
module Doctor
|
|
5
|
+
module Suppression
|
|
6
|
+
PATTERN = Regexp.new(
|
|
7
|
+
"\\A#\\s*graphql-doctor:disable(?<file>-file)?\\s+(?<codes>GQLD\\d+(?:[\\s,]+GQLD\\d+)*)" \
|
|
8
|
+
"(?:\\s*(?:--|:)\\s*(?<reason>\\S.*))?\\s*\\z"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
module_function
|
|
12
|
+
|
|
13
|
+
def filter(diagnostics, comments, require_reason: false)
|
|
14
|
+
rules = comments.filter_map { |comment| rule(comment, require_reason) }
|
|
15
|
+
diagnostics.reject do |diagnostic|
|
|
16
|
+
rules.any? do |candidate|
|
|
17
|
+
candidate[:path] == diagnostic.location.path &&
|
|
18
|
+
candidate[:codes].include?(diagnostic.code) &&
|
|
19
|
+
(candidate[:file] || candidate[:line] == diagnostic.location.start_line)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def rule(comment, require_reason)
|
|
25
|
+
match = PATTERN.match(comment.text)
|
|
26
|
+
return unless match
|
|
27
|
+
return if match[:file] && comment.location.start_line != 1
|
|
28
|
+
return if require_reason && match[:reason].to_s.empty?
|
|
29
|
+
|
|
30
|
+
{
|
|
31
|
+
file: !match[:file].nil?,
|
|
32
|
+
codes: match[:codes].scan(/GQLD\d+/),
|
|
33
|
+
path: comment.location.path,
|
|
34
|
+
line: comment.location.start_line
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "prism"
|
|
4
|
+
require_relative "doctor/version"
|
|
5
|
+
require_relative "doctor/location"
|
|
6
|
+
require_relative "doctor/diagnostic"
|
|
7
|
+
require_relative "doctor/config"
|
|
8
|
+
require_relative "doctor/ir"
|
|
9
|
+
require_relative "doctor/source/loader"
|
|
10
|
+
require_relative "doctor/source/name_mangler"
|
|
11
|
+
require_relative "doctor/runtime/schema_loader"
|
|
12
|
+
require_relative "doctor/runtime/reflector"
|
|
13
|
+
require_relative "doctor/runtime/dump"
|
|
14
|
+
require_relative "doctor/correlation/correlator"
|
|
15
|
+
require_relative "doctor/checks/engine"
|
|
16
|
+
require_relative "doctor/suppression"
|
|
17
|
+
require_relative "doctor/runner"
|
|
18
|
+
|
|
19
|
+
module GraphQL
|
|
20
|
+
module Doctor
|
|
21
|
+
class Error < StandardError; end
|
|
22
|
+
end
|
|
23
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: graphql-doctor
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Yudai Takada
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: prism
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '1.0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '1.0'
|
|
26
|
+
description: Maps GraphQL-Ruby runtime fields to Prism source locations and reports
|
|
27
|
+
resolver contract errors.
|
|
28
|
+
email:
|
|
29
|
+
- t.yudai92@gmail.com
|
|
30
|
+
executables:
|
|
31
|
+
- graphql-doctor
|
|
32
|
+
extensions: []
|
|
33
|
+
extra_rdoc_files: []
|
|
34
|
+
files:
|
|
35
|
+
- LICENSE.txt
|
|
36
|
+
- README.md
|
|
37
|
+
- Rakefile
|
|
38
|
+
- docs/diagnostics/GQLD101.md
|
|
39
|
+
- docs/diagnostics/GQLD102.md
|
|
40
|
+
- docs/diagnostics/GQLD103.md
|
|
41
|
+
- docs/diagnostics/GQLD104.md
|
|
42
|
+
- docs/diagnostics/GQLD201.md
|
|
43
|
+
- docs/diagnostics/GQLD202.md
|
|
44
|
+
- docs/diagnostics/GQLD203.md
|
|
45
|
+
- docs/diagnostics/GQLD204.md
|
|
46
|
+
- docs/diagnostics/GQLD205.md
|
|
47
|
+
- docs/diagnostics/GQLD301.md
|
|
48
|
+
- docs/diagnostics/GQLD302.md
|
|
49
|
+
- docs/diagnostics/GQLD303.md
|
|
50
|
+
- docs/diagnostics/GQLD305.md
|
|
51
|
+
- docs/diagnostics/GQLD306.md
|
|
52
|
+
- docs/diagnostics/GQLD307.md
|
|
53
|
+
- docs/diagnostics/GQLD401.md
|
|
54
|
+
- docs/diagnostics/README.md
|
|
55
|
+
- exe/graphql-doctor
|
|
56
|
+
- lib/graphql/doctor.rb
|
|
57
|
+
- lib/graphql/doctor/cache.rb
|
|
58
|
+
- lib/graphql/doctor/checks/argument_keyword_match.rb
|
|
59
|
+
- lib/graphql/doctor/checks/base.rb
|
|
60
|
+
- lib/graphql/doctor/checks/engine.rb
|
|
61
|
+
- lib/graphql/doctor/checks/resolver_method_presence.rb
|
|
62
|
+
- lib/graphql/doctor/cli.rb
|
|
63
|
+
- lib/graphql/doctor/config.rb
|
|
64
|
+
- lib/graphql/doctor/correlation/correlator.rb
|
|
65
|
+
- lib/graphql/doctor/diagnostic.rb
|
|
66
|
+
- lib/graphql/doctor/ir.rb
|
|
67
|
+
- lib/graphql/doctor/location.rb
|
|
68
|
+
- lib/graphql/doctor/reporters/github.rb
|
|
69
|
+
- lib/graphql/doctor/reporters/json.rb
|
|
70
|
+
- lib/graphql/doctor/reporters/sarif.rb
|
|
71
|
+
- lib/graphql/doctor/reporters/text.rb
|
|
72
|
+
- lib/graphql/doctor/runner.rb
|
|
73
|
+
- lib/graphql/doctor/runtime/dump.rb
|
|
74
|
+
- lib/graphql/doctor/runtime/reflector.rb
|
|
75
|
+
- lib/graphql/doctor/runtime/schema_loader.rb
|
|
76
|
+
- lib/graphql/doctor/source/file_visitor.rb
|
|
77
|
+
- lib/graphql/doctor/source/index.rb
|
|
78
|
+
- lib/graphql/doctor/source/loader.rb
|
|
79
|
+
- lib/graphql/doctor/source/name_mangler.rb
|
|
80
|
+
- lib/graphql/doctor/suppression.rb
|
|
81
|
+
- lib/graphql/doctor/version.rb
|
|
82
|
+
homepage: https://github.com/ydah/graphql-doctor
|
|
83
|
+
licenses:
|
|
84
|
+
- MIT
|
|
85
|
+
metadata:
|
|
86
|
+
homepage_uri: https://github.com/ydah/graphql-doctor
|
|
87
|
+
rubygems_mfa_required: 'true'
|
|
88
|
+
rdoc_options: []
|
|
89
|
+
require_paths:
|
|
90
|
+
- lib
|
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '3.1'
|
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
|
+
requirements:
|
|
98
|
+
- - ">="
|
|
99
|
+
- !ruby/object:Gem::Version
|
|
100
|
+
version: '0'
|
|
101
|
+
requirements: []
|
|
102
|
+
rubygems_version: 4.0.19
|
|
103
|
+
specification_version: 4
|
|
104
|
+
summary: Check GraphQL-Ruby resolver contracts against Ruby source
|
|
105
|
+
test_files: []
|