gergich 1.2.1 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/gergich/capture/rubocop_capture.rb +19 -0
- data/lib/gergich/capture/yamllint_capture.rb +25 -0
- data/lib/gergich/cli/gergich.rb +2 -0
- data/lib/gergich.rb +3 -2
- data/spec/gergich/capture/rubocop_capture_spec.rb +9 -0
- data/spec/gergich/capture/yamllint_capture_spec.rb +31 -0
- data/spec/gergich_spec.rb +2 -0
- metadata +22 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 209022ec9ca1bfed90a33f905f9d0e36f016b7f25485e66041e276ff393fec6e
|
4
|
+
data.tar.gz: f6477fb1a8f75192b6f516cfe1197db7800a3b221a703d71da7a1204db3a23bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6ffba5044485692318eb057407f9d6032eccd9118942233e34b3d727201784ca2111c56adb1e5ce306814916d90585b6341ff19eeb1df6c1cc0bf98d4b6b5df
|
7
|
+
data.tar.gz: f7b5f8e726eabc13f722da011df51d7c0fb137480130573819c928d1bca02057f91330d995cbda0a7ad8ad7661ee28a026a3df12f5d87911f2848f9cfd369113
|
data/README.md
CHANGED
@@ -106,6 +106,7 @@ do `gergich comment` calls so you don't have to wire it up yourself.
|
|
106
106
|
* `i18nliner`
|
107
107
|
* `flake8`
|
108
108
|
* `stylelint`
|
109
|
+
* `yamllint`
|
109
110
|
* `shellcheck` - shellcheck json output
|
110
111
|
* `custom:<path>:<class_name>` - file path and ruby class_name of a custom
|
111
112
|
formatter.
|
@@ -16,10 +16,29 @@ module Gergich
|
|
16
16
|
# bin/gergich:47:8: C: Prefer double-quoted strings
|
17
17
|
# if ENV['DEBUG']
|
18
18
|
# ^^^^^^^
|
19
|
+
#
|
20
|
+
# 1 file inspected, 35 offenses detected, 27 offenses auto-correctable
|
21
|
+
#
|
22
|
+
# Example:
|
23
|
+
# 2 files inspected, 40 offenses detected, 31 offenses auto-correctable
|
24
|
+
#
|
25
|
+
# Example:
|
26
|
+
# 1 file inspected, no offenses detected
|
27
|
+
|
19
28
|
first_line_pattern = /^([^:\n]+):(\d+):\d+:\s(\w):\s/
|
20
29
|
|
21
30
|
parts = output.split(first_line_pattern)
|
31
|
+
|
32
|
+
unless parts.last.match?(/^\d+ files? inspect/)
|
33
|
+
raise "RuboCop failed to run properly:\n\n#{output}"
|
34
|
+
end
|
35
|
+
|
36
|
+
# strip off the summary line from the last error
|
37
|
+
parts[-1] = parts[-1].split("\n")[0..-2].join("\n")
|
38
|
+
|
39
|
+
# strip off the header
|
22
40
|
parts.shift
|
41
|
+
|
23
42
|
messages = []
|
24
43
|
|
25
44
|
until parts.empty?
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gergich
|
4
|
+
module Capture
|
5
|
+
class YamllintCapture < BaseCapture
|
6
|
+
SEVERITY_MAP = { "error" => "error", "warning" => "warn" }.freeze
|
7
|
+
|
8
|
+
def run(output)
|
9
|
+
# e.g. " 9:5 error string value redundantly (quoted-strings)"
|
10
|
+
error_pattern = %r{\s\s+(\d+):\d+\s+(\w+)\s+(.*?)\s+\([\w/-]+\)\n}
|
11
|
+
pattern = %r{ # Example:
|
12
|
+
^.\/([^\n]+)\n # ./api/config/lti/development/config.yml
|
13
|
+
((#{error_pattern})+) # 9:5 error string value redundantly (quoted-strings)
|
14
|
+
}mx
|
15
|
+
|
16
|
+
output.scan(pattern).map { |file, errors|
|
17
|
+
errors.scan(error_pattern).map { |line, severity, error|
|
18
|
+
severity = SEVERITY_MAP[severity]
|
19
|
+
{ path: file, message: "[yamllint] #{error}", position: line.to_i, severity: severity }
|
20
|
+
}
|
21
|
+
}.compact.flatten
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/gergich/cli/gergich.rb
CHANGED
@@ -18,6 +18,7 @@ CI_TEST_ARGS = {
|
|
18
18
|
bin/gergich:47:8: C: Prefer double-quoted strings
|
19
19
|
if ENV['DEBUG']
|
20
20
|
^^^^^^^
|
21
|
+
1 file inspected, 35 offenses detected, 27 offenses auto-correctable
|
21
22
|
OUTPUT
|
22
23
|
}.freeze
|
23
24
|
|
@@ -209,6 +210,7 @@ commands["capture"] = {
|
|
209
210
|
* i18nliner
|
210
211
|
* flake8
|
211
212
|
* stylelint
|
213
|
+
* yamllint
|
212
214
|
* custom:<path>:<class_name> - file path and ruby
|
213
215
|
class_name of a custom formatter.
|
214
216
|
|
data/lib/gergich.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "erb"
|
4
|
-
require "sqlite3"
|
5
4
|
require "json"
|
6
5
|
require "fileutils"
|
7
|
-
require "httparty"
|
8
6
|
require "base64"
|
9
7
|
|
10
8
|
GERGICH_REVIEW_LABEL = ENV.fetch("GERGICH_REVIEW_LABEL", "Code-Review")
|
@@ -292,6 +290,8 @@ module Gergich
|
|
292
290
|
private
|
293
291
|
|
294
292
|
def perform(method, url, options)
|
293
|
+
# delay requiring httparty until here, to make local command line runs as fast as possible
|
294
|
+
require "httparty"
|
295
295
|
options = prepare_options(options)
|
296
296
|
ret = HTTParty.send(method, url, options).body
|
297
297
|
return ret if options[:raw]
|
@@ -370,6 +370,7 @@ module Gergich
|
|
370
370
|
|
371
371
|
def db
|
372
372
|
@db ||= begin
|
373
|
+
require "sqlite3"
|
373
374
|
db_exists = File.exist?(db_file)
|
374
375
|
db = SQLite3::Database.new(db_file)
|
375
376
|
db.results_as_hash = true
|
@@ -19,6 +19,8 @@ RSpec.describe Gergich::Capture::RubocopCapture do
|
|
19
19
|
lib/gergich.rb:22:55: W: Line is too long. [55/54]
|
20
20
|
def initialize(ref = "HEAD", revision_number = nil)
|
21
21
|
^^
|
22
|
+
|
23
|
+
1 file inspected, 35 offenses detected, 27 offenses auto-correctable
|
22
24
|
OUTPUT
|
23
25
|
end
|
24
26
|
let(:comments) do
|
@@ -63,4 +65,11 @@ RSpec.describe Gergich::Capture::RubocopCapture do
|
|
63
65
|
end
|
64
66
|
|
65
67
|
it_behaves_like "a captor"
|
68
|
+
|
69
|
+
it "raises an error if it couldn't run" do
|
70
|
+
expect { subject.run(<<-OUTPUT) }.to raise_error(/RuboCop failed to run properly/)
|
71
|
+
Could not find i18n-1.8.9 in any of the sources
|
72
|
+
Run `bundle install` to install missing gems.
|
73
|
+
OUTPUT
|
74
|
+
end
|
66
75
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../support/capture_shared_examples"
|
4
|
+
|
5
|
+
RSpec.describe Gergich::Capture::YamllintCapture do
|
6
|
+
let(:output) do
|
7
|
+
<<~OUTPUT
|
8
|
+
./api/config/lti/development/config.yml
|
9
|
+
2:8 error string value is redundantly quoted with double quotes (quoted-strings)
|
10
|
+
12:3 warning comment not indented like content (comments-indentation)
|
11
|
+
OUTPUT
|
12
|
+
end
|
13
|
+
let(:comments) do
|
14
|
+
[
|
15
|
+
{
|
16
|
+
path: "api/config/lti/development/config.yml",
|
17
|
+
position: 2,
|
18
|
+
message: "[yamllint] string value is redundantly quoted with double quotes",
|
19
|
+
severity: "error"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
path: "api/config/lti/development/config.yml",
|
23
|
+
position: 12,
|
24
|
+
message: "[yamllint] comment not indented like content",
|
25
|
+
severity: "warn"
|
26
|
+
}
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
it_behaves_like "a captor"
|
31
|
+
end
|
data/spec/gergich_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gergich
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Jensen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: byebug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '11.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '11.1'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,6 +134,7 @@ files:
|
|
120
134
|
- lib/gergich/capture/shellcheck_capture.rb
|
121
135
|
- lib/gergich/capture/stylelint_capture.rb
|
122
136
|
- lib/gergich/capture/swiftlint_capture.rb
|
137
|
+
- lib/gergich/capture/yamllint_capture.rb
|
123
138
|
- lib/gergich/cli.rb
|
124
139
|
- lib/gergich/cli/gergich.rb
|
125
140
|
- lib/gergich/cli/master_bouncer.rb
|
@@ -133,6 +148,7 @@ files:
|
|
133
148
|
- spec/gergich/capture/shellcheck_capture_spec.rb
|
134
149
|
- spec/gergich/capture/stylelint_capture_spec.rb
|
135
150
|
- spec/gergich/capture/swiftlint_capture_spec.rb
|
151
|
+
- spec/gergich/capture/yamllint_capture_spec.rb
|
136
152
|
- spec/gergich/capture_spec.rb
|
137
153
|
- spec/gergich_spec.rb
|
138
154
|
- spec/spec_helper.rb
|
@@ -141,7 +157,7 @@ homepage: https://github.com/instructure/gergich
|
|
141
157
|
licenses:
|
142
158
|
- MIT
|
143
159
|
metadata: {}
|
144
|
-
post_install_message:
|
160
|
+
post_install_message:
|
145
161
|
rdoc_options: []
|
146
162
|
require_paths:
|
147
163
|
- lib
|
@@ -156,8 +172,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
172
|
- !ruby/object:Gem::Version
|
157
173
|
version: '0'
|
158
174
|
requirements: []
|
159
|
-
rubygems_version: 3.
|
160
|
-
signing_key:
|
175
|
+
rubygems_version: 3.2.24
|
176
|
+
signing_key:
|
161
177
|
specification_version: 4
|
162
178
|
summary: Command-line tool for adding Gerrit comments
|
163
179
|
test_files: []
|