gergich 0.1.5 → 0.1.6
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.rb +7 -1
- data/lib/gergich/capture/stylelint_capture.rb +50 -0
- data/lib/gergich/cli/gergich.rb +1 -0
- data/spec/gergich/capture/androidlint_capture_spec.rb +56 -0
- data/spec/gergich/capture/custom_capture_spec.rb +39 -0
- data/spec/gergich/capture/eslint_capture_spec.rb +29 -0
- data/spec/gergich/capture/flake8_capture_spec.rb +21 -0
- data/spec/gergich/capture/i18nliner_capture_spec.rb +23 -0
- data/spec/gergich/capture/rubocop_capture_spec.rb +37 -0
- data/spec/gergich/capture/stylelint_capture_spec.rb +45 -0
- data/spec/gergich/capture/swiftlint_capture_spec.rb +39 -0
- data/spec/gergich/capture_spec.rb +0 -179
- data/spec/gergich_spec.rb +0 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/support/capture_shared_examples.rb +17 -0
- metadata +13 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 899a2175e74f907763c70a483437eefd9bda8b2b
|
4
|
+
data.tar.gz: 77fad0f1d44722607d1cb6e1af67d15205a4ac16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 163de2c94245b125515c2dec581e314db68fe6cfc42e0cc9b661c485818c6a03cf2ceb160a93bd9101e78d4564f0275c0697aa1decd3adf4d9e48e4e1f726570
|
7
|
+
data.tar.gz: ea96e37e0ea8ce2c3374f6354699116768ce87e45f01fd9a288a32aa2e4679d2b59914c76761c020691945f04d82af631749270072b51053a85c913d0dbcc1e3
|
data/README.md
CHANGED
data/lib/gergich/capture.rb
CHANGED
@@ -1,7 +1,14 @@
|
|
1
|
+
require "English"
|
2
|
+
|
1
3
|
module Gergich
|
2
4
|
module Capture
|
3
5
|
class BaseCapture
|
4
6
|
def self.inherited(subclass)
|
7
|
+
name = normalize_captor_class_name(subclass)
|
8
|
+
Capture.captors[name] = subclass
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.normalize_captor_class_name(subclass)
|
5
12
|
name = subclass.name
|
6
13
|
# borrowed from AS underscore, since we may not have it
|
7
14
|
name.gsub!(/.*::|Capture\z/, "")
|
@@ -9,7 +16,6 @@ module Gergich
|
|
9
16
|
name.gsub!(/([a-z\d])([A-Z])/, "\\1_\\2")
|
10
17
|
name.tr!("-", "_")
|
11
18
|
name.downcase!
|
12
|
-
Capture.captors[name] = subclass
|
13
19
|
end
|
14
20
|
end
|
15
21
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Gergich
|
2
|
+
module Capture
|
3
|
+
class StylelintCapture < BaseCapture
|
4
|
+
# stylelint is a css linter
|
5
|
+
# https://github.com/stylelint/stylelint
|
6
|
+
#
|
7
|
+
# rubocop:disable Style/AsciiComments
|
8
|
+
# example full output:
|
9
|
+
# app/stylesheets/base/_print.scss
|
10
|
+
# 3:17 ✖ Unexpected invalid hex color "#owiehfi" color-no-invalid-hex
|
11
|
+
# 3:17 ⚠ Expected "#owiehfi" to be "#OWIEHFI" color-hex-case
|
12
|
+
#
|
13
|
+
# app/stylesheets/base/_variables.scss
|
14
|
+
# 2:15 ✖ Unexpected invalid hex color "#2D3B4" color-no-invalid-hex
|
15
|
+
# 30:15 ⚠ Expected "#2d3b4a" to be "#2D3B4A" color-hex-case
|
16
|
+
|
17
|
+
MESSAGE_PREFIX = "[stylelint]".freeze
|
18
|
+
|
19
|
+
SEVERITY_MAP = {
|
20
|
+
"✖" => "error",
|
21
|
+
"⚠" => "warn"
|
22
|
+
}.freeze
|
23
|
+
|
24
|
+
# example file line:
|
25
|
+
# app/stylesheets/base/_variables.scss
|
26
|
+
FILE_PATH_PATTERN = /([^\n]+)\n/
|
27
|
+
|
28
|
+
# example error line:
|
29
|
+
# 1:15 ✖ Unexpected invalid hex color "#2D3B4" color-no-invalid-hex
|
30
|
+
ERROR_PATTERN = /^\s+(\d+):\d+\s+(✖|⚠)\s+(.*?)\s\s+[^\n]+\n/
|
31
|
+
# rubocop:enable Style/AsciiComments
|
32
|
+
|
33
|
+
PATTERN = /#{FILE_PATH_PATTERN}((#{ERROR_PATTERN})+)/
|
34
|
+
|
35
|
+
def run(output)
|
36
|
+
output.scan(PATTERN).map { |file, errors|
|
37
|
+
errors.scan(ERROR_PATTERN).map { |line, severity, error|
|
38
|
+
severity = SEVERITY_MAP[severity]
|
39
|
+
{
|
40
|
+
path: file,
|
41
|
+
message: "#{MESSAGE_PREFIX} #{error}",
|
42
|
+
position: line.to_i,
|
43
|
+
severity: severity
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}.flatten.compact
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/gergich/cli/gergich.rb
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative "../../support/capture_shared_examples"
|
2
|
+
|
3
|
+
RSpec.describe Gergich::Capture::AndroidlintCapture do
|
4
|
+
# rubocop:disable Metrics/LineLength
|
5
|
+
let(:rtl_hardcoded) { 'Consider adding android:drawableStart="@drawable/a_media" to better support right-to-left layouts [RtlHardcoded]' }
|
6
|
+
let(:rtl_enabled) { "The project references RTL attributes, but does not explicitly enable or disable RTL support with android:supportsRtl in the manifest [RtlEnabled]" }
|
7
|
+
let(:lint_error) { 'No .class files were found in project "0.0.2", so none of the classfile based checks could be run. Does the project need to be built first? [LintError]' }
|
8
|
+
let(:unused_quantity) { 'For language "fr" (French) the following quantities are not relevant: few, zero [UnusedQuantity]' }
|
9
|
+
let(:output) do
|
10
|
+
<<-OUTPUT
|
11
|
+
/path/to/some.xml:27: Warning: #{rtl_hardcoded}
|
12
|
+
android:drawableLeft="@drawable/ic_cv_media"/>
|
13
|
+
~~~~~~~~~~~~~~~~~~~~
|
14
|
+
|
15
|
+
/path/to/AndroidManifest.xml: Warning: #{rtl_enabled}
|
16
|
+
|
17
|
+
/path/to/library/0.0.2: Error: #{lint_error}
|
18
|
+
|
19
|
+
/path/to/values.xml:5: Warning: #{unused_quantity}
|
20
|
+
<plurals name="number">
|
21
|
+
^
|
22
|
+
|
23
|
+
OUTPUT
|
24
|
+
end
|
25
|
+
|
26
|
+
let(:comments) do
|
27
|
+
[
|
28
|
+
{
|
29
|
+
path: "/path/to/some.xml",
|
30
|
+
position: 27,
|
31
|
+
message: "[androidlint] #{rtl_hardcoded}\n\n android:drawableLeft=\"@drawable/ic_cv_media\"/>\n ~~~~~~~~~~~~~~~~~~~~",
|
32
|
+
severity: "warn"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
path: "/path/to/AndroidManifest.xml",
|
36
|
+
position: 0,
|
37
|
+
message: "[androidlint] #{rtl_enabled}",
|
38
|
+
severity: "warn"
|
39
|
+
},
|
40
|
+
{
|
41
|
+
path: "/path/to/library/0.0.2",
|
42
|
+
position: 0,
|
43
|
+
message: "[androidlint] #{lint_error}",
|
44
|
+
severity: "error"
|
45
|
+
},
|
46
|
+
{
|
47
|
+
path: "/path/to/values.xml",
|
48
|
+
position: 5,
|
49
|
+
message: "[androidlint] #{unused_quantity}\n\n <plurals name=\"number\">\n ^",
|
50
|
+
severity: "warn"
|
51
|
+
}
|
52
|
+
]
|
53
|
+
end
|
54
|
+
|
55
|
+
it_behaves_like "a captor"
|
56
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative "../../../lib/gergich/capture"
|
2
|
+
|
3
|
+
RSpec.describe "CustomCaptor" do
|
4
|
+
class CustomCaptor
|
5
|
+
def run(output)
|
6
|
+
output.scan(/^(.+?):(\d+): (.*)$/).map do |file, line, error|
|
7
|
+
{ path: file, message: error, position: line.to_i, severity: "error" }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:described_class) { CustomCaptor }
|
13
|
+
let(:capture_format) { "custom:sqlite3:CustomCaptor" }
|
14
|
+
let(:output) do
|
15
|
+
<<-OUTPUT
|
16
|
+
foo.rb:1: you done screwed up
|
17
|
+
OUTPUT
|
18
|
+
end
|
19
|
+
let(:comments) do
|
20
|
+
[
|
21
|
+
{
|
22
|
+
path: "foo.rb",
|
23
|
+
position: 1,
|
24
|
+
message: "you done screwed up",
|
25
|
+
severity: "error"
|
26
|
+
}
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
it "loads" do
|
31
|
+
captor = Gergich::Capture.load_captor(capture_format)
|
32
|
+
expect(captor).to eq(described_class)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "catches errors" do
|
36
|
+
comments = subject.run(output)
|
37
|
+
expect(comments).to match_array(comments)
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative "../../support/capture_shared_examples"
|
2
|
+
|
3
|
+
RSpec.describe Gergich::Capture::EslintCapture do
|
4
|
+
let(:output) do
|
5
|
+
<<-OUTPUT
|
6
|
+
jsapp/models/user.js
|
7
|
+
4:21 error Missing semicolon semi
|
8
|
+
5:1 warning Too much cowbell cowbell-overload
|
9
|
+
OUTPUT
|
10
|
+
end
|
11
|
+
let(:comments) do
|
12
|
+
[
|
13
|
+
{
|
14
|
+
path: "jsapp/models/user.js",
|
15
|
+
position: 4,
|
16
|
+
message: "[eslint] Missing semicolon",
|
17
|
+
severity: "error"
|
18
|
+
},
|
19
|
+
{
|
20
|
+
path: "jsapp/models/user.js",
|
21
|
+
position: 5,
|
22
|
+
message: "[eslint] Too much cowbell",
|
23
|
+
severity: "warn"
|
24
|
+
}
|
25
|
+
]
|
26
|
+
end
|
27
|
+
|
28
|
+
it_behaves_like "a captor"
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative "../../support/capture_shared_examples"
|
2
|
+
|
3
|
+
RSpec.describe Gergich::Capture::Flake8Capture do
|
4
|
+
let(:output) do
|
5
|
+
<<-OUTPUT
|
6
|
+
./djangogeneric/settings/base.py:73:80: E501 line too long (81 > 79 characters)
|
7
|
+
OUTPUT
|
8
|
+
end
|
9
|
+
let(:comments) do
|
10
|
+
[
|
11
|
+
{
|
12
|
+
path: "./djangogeneric/settings/base.py",
|
13
|
+
position: 73,
|
14
|
+
message: "[flake8] E501 line too long (81 > 79 characters)",
|
15
|
+
severity: "error"
|
16
|
+
}
|
17
|
+
]
|
18
|
+
end
|
19
|
+
|
20
|
+
it_behaves_like "a captor"
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative "../../support/capture_shared_examples"
|
2
|
+
|
3
|
+
RSpec.describe Gergich::Capture::I18nlinerCapture do
|
4
|
+
let(:output) do
|
5
|
+
<<-OUTPUT
|
6
|
+
1)
|
7
|
+
invalid signature on line 4: <unsupported expression>
|
8
|
+
jsapp/models/user.js
|
9
|
+
OUTPUT
|
10
|
+
end
|
11
|
+
let(:comments) do
|
12
|
+
[
|
13
|
+
{
|
14
|
+
path: "jsapp/models/user.js",
|
15
|
+
position: 4,
|
16
|
+
message: "[i18n] invalid signature: <unsupported expression>",
|
17
|
+
severity: "error"
|
18
|
+
}
|
19
|
+
]
|
20
|
+
end
|
21
|
+
|
22
|
+
it_behaves_like "a captor"
|
23
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative "../../support/capture_shared_examples"
|
2
|
+
|
3
|
+
RSpec.describe Gergich::Capture::RubocopCapture do
|
4
|
+
let(:output) do
|
5
|
+
<<-OUTPUT
|
6
|
+
bin/gergich:47:8: C: Prefer double-quoted strings
|
7
|
+
if ENV['DEBUG']
|
8
|
+
^^^^^^^
|
9
|
+
lib/gergich.rb:22:55: W: Line is too long. [55/54]
|
10
|
+
def initialize(ref = "HEAD", revision_number = nil)
|
11
|
+
^^
|
12
|
+
OUTPUT
|
13
|
+
end
|
14
|
+
let(:comments) do
|
15
|
+
[
|
16
|
+
{
|
17
|
+
path: "bin/gergich",
|
18
|
+
position: 47,
|
19
|
+
message: "[rubocop] Prefer double-quoted strings\n\n if ENV['DEBUG']\n ^^^^^^^\n",
|
20
|
+
severity: "info"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
path: "lib/gergich.rb",
|
24
|
+
position: 22,
|
25
|
+
message: <<-OUTPUT,
|
26
|
+
[rubocop] Line is too long. [55/54]
|
27
|
+
|
28
|
+
def initialize(ref = "HEAD", revision_number = nil)
|
29
|
+
^^
|
30
|
+
OUTPUT
|
31
|
+
severity: "warn"
|
32
|
+
}
|
33
|
+
]
|
34
|
+
end
|
35
|
+
|
36
|
+
it_behaves_like "a captor"
|
37
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative "../../support/capture_shared_examples"
|
2
|
+
|
3
|
+
RSpec.describe Gergich::Capture::StylelintCapture do
|
4
|
+
let(:output) do
|
5
|
+
<<-OUTPUT
|
6
|
+
app/stylesheets/base/_print.scss
|
7
|
+
3:17 ✖ Unexpected invalid hex color "#owiehfi" color-no-invalid-hex
|
8
|
+
3:17 ⚠ Expected "#owiehfi" to be "#OWIEHFI" color-hex-case
|
9
|
+
|
10
|
+
app/stylesheets/base/_variables.scss
|
11
|
+
2:15 ✖ Unexpected invalid hex color "#2D3B4" color-no-invalid-hex
|
12
|
+
30:15 ⚠ Expected "#2d3b4a" to be "#2D3B4A" color-hex-case
|
13
|
+
OUTPUT
|
14
|
+
end
|
15
|
+
let(:comments) do
|
16
|
+
[
|
17
|
+
{
|
18
|
+
path: "app/stylesheets/base/_print.scss",
|
19
|
+
position: 3,
|
20
|
+
message: "[stylelint] Unexpected invalid hex color \"#owiehfi\"",
|
21
|
+
severity: "error"
|
22
|
+
},
|
23
|
+
{
|
24
|
+
path: "app/stylesheets/base/_print.scss",
|
25
|
+
position: 3,
|
26
|
+
message: "[stylelint] Expected \"#owiehfi\" to be \"#OWIEHFI\"",
|
27
|
+
severity: "warn"
|
28
|
+
},
|
29
|
+
{
|
30
|
+
path: "app/stylesheets/base/_variables.scss",
|
31
|
+
position: 2,
|
32
|
+
message: "[stylelint] Unexpected invalid hex color \"#2D3B4\"",
|
33
|
+
severity: "error"
|
34
|
+
},
|
35
|
+
{
|
36
|
+
path: "app/stylesheets/base/_variables.scss",
|
37
|
+
position: 30,
|
38
|
+
message: "[stylelint] Expected \"#2d3b4a\" to be \"#2D3B4A\"",
|
39
|
+
severity: "warn"
|
40
|
+
}
|
41
|
+
]
|
42
|
+
end
|
43
|
+
|
44
|
+
it_behaves_like "a captor"
|
45
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative "../../support/capture_shared_examples"
|
2
|
+
|
3
|
+
RSpec.describe Gergich::Capture::SwiftlintCapture do
|
4
|
+
# rubocop:disable Metrics/LineLength
|
5
|
+
let(:colon_violation) { "Colon Violation: Colons should be next to the identifier when specifying a type. (colon)" }
|
6
|
+
let(:line_length_violation) { "Line Length Violation: Line should be 100 characters or less: currently 129 characters (line_length)" }
|
7
|
+
let(:force_cast_violation) { "Force Cast Violation: Force casts should be avoided. (force_cast)" }
|
8
|
+
let(:output) do
|
9
|
+
<<-OUTPUT
|
10
|
+
/path/to/My.swift:13:22: warning: #{colon_violation}
|
11
|
+
/path/to/Fail.swift:76: warning: #{line_length_violation}
|
12
|
+
/path/to/Cast.swift:15:9: error: #{force_cast_violation}
|
13
|
+
OUTPUT
|
14
|
+
end
|
15
|
+
let(:comments) do
|
16
|
+
[
|
17
|
+
{
|
18
|
+
path: "/path/to/My.swift",
|
19
|
+
position: 13,
|
20
|
+
message: "[swiftlint] #{colon_violation}",
|
21
|
+
severity: "warn"
|
22
|
+
},
|
23
|
+
{
|
24
|
+
path: "/path/to/Fail.swift",
|
25
|
+
position: 76,
|
26
|
+
message: "[swiftlint] #{line_length_violation}",
|
27
|
+
severity: "warn"
|
28
|
+
},
|
29
|
+
{
|
30
|
+
path: "/path/to/Cast.swift",
|
31
|
+
position: 15,
|
32
|
+
message: "[swiftlint] #{force_cast_violation}",
|
33
|
+
severity: "error"
|
34
|
+
}
|
35
|
+
]
|
36
|
+
end
|
37
|
+
|
38
|
+
it_behaves_like "a captor"
|
39
|
+
end
|
@@ -1,189 +1,10 @@
|
|
1
1
|
require_relative "../../lib/gergich/capture"
|
2
|
-
require_relative "../../lib/gergich"
|
3
2
|
|
4
3
|
RSpec.describe Gergich::Capture do
|
5
4
|
let!(:draft) { double }
|
6
5
|
|
7
6
|
before do
|
8
7
|
allow(Gergich::Draft).to receive(:new).and_return(draft)
|
9
|
-
$stdout = StringIO.new
|
10
|
-
end
|
11
|
-
|
12
|
-
after do
|
13
|
-
$stdout = STDOUT
|
14
|
-
end
|
15
|
-
|
16
|
-
context "rubocop" do
|
17
|
-
it "should catch errors" do
|
18
|
-
allow(described_class).to receive(:run_command).and_return([0, <<-OUTPUT])
|
19
|
-
bin/gergich:47:8: C: Prefer double-quoted strings
|
20
|
-
if ENV['DEBUG']
|
21
|
-
^^^^^^^
|
22
|
-
lib/gergich.rb:22:55: W: Line is too long. [55/54]
|
23
|
-
def initialize(ref = "HEAD", revision_number = nil)
|
24
|
-
^^
|
25
|
-
OUTPUT
|
26
|
-
expect(draft).to receive(:add_comment).with(
|
27
|
-
"bin/gergich",
|
28
|
-
47,
|
29
|
-
"[rubocop] Prefer double-quoted strings\n\n if ENV['DEBUG']\n ^^^^^^^\n",
|
30
|
-
"info"
|
31
|
-
)
|
32
|
-
expect(draft).to receive(:add_comment)
|
33
|
-
.with("lib/gergich.rb", 22, <<-OUTPUT, "warn")
|
34
|
-
[rubocop] Line is too long. [55/54]
|
35
|
-
|
36
|
-
def initialize(ref = "HEAD", revision_number = nil)
|
37
|
-
^^
|
38
|
-
OUTPUT
|
39
|
-
described_class.run("rubocop", "false")
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# rubocop:disable Metrics/LineLength
|
44
|
-
context "swiftlint" do
|
45
|
-
it "should catch errors" do
|
46
|
-
colon_violation = "Colon Violation: Colons should be next to the identifier when specifying a type. (colon)"
|
47
|
-
line_length_violation = "Line Length Violation: Line should be 100 characters or less: currently 129 characters (line_length)"
|
48
|
-
force_cast_violation = "Force Cast Violation: Force casts should be avoided. (force_cast)"
|
49
|
-
allow(described_class).to receive(:run_command).and_return([0, <<-OUTPUT])
|
50
|
-
/path/to/My.swift:13:22: warning: #{colon_violation}
|
51
|
-
/path/to/Fail.swift:76: warning: #{line_length_violation}
|
52
|
-
/path/to/Cast.swift:15:9: error: #{force_cast_violation}
|
53
|
-
OUTPUT
|
54
|
-
expect(draft).to receive(:add_comment).with(
|
55
|
-
"/path/to/My.swift",
|
56
|
-
13,
|
57
|
-
"[swiftlint] #{colon_violation}",
|
58
|
-
"warn"
|
59
|
-
)
|
60
|
-
expect(draft).to receive(:add_comment).with(
|
61
|
-
"/path/to/Fail.swift",
|
62
|
-
76,
|
63
|
-
"[swiftlint] #{line_length_violation}",
|
64
|
-
"warn"
|
65
|
-
)
|
66
|
-
expect(draft).to receive(:add_comment).with(
|
67
|
-
"/path/to/Cast.swift",
|
68
|
-
15,
|
69
|
-
"[swiftlint] #{force_cast_violation}",
|
70
|
-
"error"
|
71
|
-
)
|
72
|
-
described_class.run("swiftlint", "false")
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context "androidlint" do
|
77
|
-
it "should catch errors" do
|
78
|
-
rtl_hardcoded = 'Consider adding android:drawableStart="@drawable/a_media" to better support right-to-left layouts [RtlHardcoded]'
|
79
|
-
rtl_enabled = "The project references RTL attributes, but does not explicitly enable or disable RTL support with android:supportsRtl in the manifest [RtlEnabled]"
|
80
|
-
lint_error = 'No .class files were found in project "0.0.2", so none of the classfile based checks could be run. Does the project need to be built first? [LintError]'
|
81
|
-
unused_quantity = 'For language "fr" (French) the following quantities are not relevant: few, zero [UnusedQuantity]'
|
82
|
-
allow(described_class).to receive(:run_command).and_return([0, <<-OUTPUT])
|
83
|
-
/path/to/some.xml:27: Warning: #{rtl_hardcoded}
|
84
|
-
android:drawableLeft="@drawable/ic_cv_media"/>
|
85
|
-
~~~~~~~~~~~~~~~~~~~~
|
86
|
-
|
87
|
-
/path/to/AndroidManifest.xml: Warning: #{rtl_enabled}
|
88
|
-
|
89
|
-
/path/to/library/0.0.2: Error: #{lint_error}
|
90
|
-
|
91
|
-
/path/to/values.xml:5: Warning: #{unused_quantity}
|
92
|
-
<plurals name="number">
|
93
|
-
^
|
94
|
-
|
95
|
-
OUTPUT
|
96
|
-
expect(draft).to receive(:add_comment).with(
|
97
|
-
"/path/to/some.xml",
|
98
|
-
27,
|
99
|
-
"[androidlint] #{rtl_hardcoded}\n\n android:drawableLeft=\"@drawable/ic_cv_media\"/>\n ~~~~~~~~~~~~~~~~~~~~",
|
100
|
-
"warn"
|
101
|
-
)
|
102
|
-
expect(draft).to receive(:add_comment).with(
|
103
|
-
"/path/to/AndroidManifest.xml",
|
104
|
-
0,
|
105
|
-
"[androidlint] #{rtl_enabled}",
|
106
|
-
"warn"
|
107
|
-
)
|
108
|
-
expect(draft).to receive(:add_comment).with(
|
109
|
-
"/path/to/library/0.0.2",
|
110
|
-
0,
|
111
|
-
"[androidlint] #{lint_error}",
|
112
|
-
"error"
|
113
|
-
)
|
114
|
-
expect(draft).to receive(:add_comment).with(
|
115
|
-
"/path/to/values.xml",
|
116
|
-
5,
|
117
|
-
"[androidlint] #{unused_quantity}\n\n <plurals name=\"number\">\n ^",
|
118
|
-
"warn"
|
119
|
-
)
|
120
|
-
described_class.run("androidlint", "false")
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
context "eslint" do
|
125
|
-
it "should catch errors" do
|
126
|
-
allow(described_class).to receive(:run_command).and_return([0, <<-OUTPUT])
|
127
|
-
jsapp/models/user.js
|
128
|
-
4:21 error Missing semicolon semi
|
129
|
-
5:1 warning Too much cowbell cowbell-overload
|
130
|
-
OUTPUT
|
131
|
-
expect(draft).to receive(:add_comment).with(
|
132
|
-
"jsapp/models/user.js",
|
133
|
-
4,
|
134
|
-
"[eslint] Missing semicolon",
|
135
|
-
"error"
|
136
|
-
)
|
137
|
-
|
138
|
-
expect(draft).to receive(:add_comment).with(
|
139
|
-
"jsapp/models/user.js",
|
140
|
-
5,
|
141
|
-
"[eslint] Too much cowbell",
|
142
|
-
"warn"
|
143
|
-
)
|
144
|
-
described_class.run("eslint", "false")
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
context "i18nliner" do
|
149
|
-
it "should catch errors" do
|
150
|
-
allow(described_class).to receive(:run_command).and_return([0, <<-OUTPUT])
|
151
|
-
1)
|
152
|
-
invalid signature on line 4: <unsupported expression>
|
153
|
-
jsapp/models/user.js
|
154
|
-
OUTPUT
|
155
|
-
expect(draft).to receive(:add_comment).with(
|
156
|
-
"jsapp/models/user.js",
|
157
|
-
4,
|
158
|
-
"[i18n] invalid signature: <unsupported expression>",
|
159
|
-
"error"
|
160
|
-
)
|
161
|
-
described_class.run("i18nliner", "false")
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
context "custom" do
|
166
|
-
class CustomCaptor
|
167
|
-
def run(output)
|
168
|
-
puts output
|
169
|
-
output.scan(/^(.+?):(\d+): (.*)$/).map do |file, line, error|
|
170
|
-
{ path: file, message: error, position: line.to_i, severity: "error" }
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
it "should catch errors" do
|
176
|
-
allow(described_class).to receive(:run_command).and_return([0, <<-OUTPUT])
|
177
|
-
foo.rb:1: you done screwed up
|
178
|
-
OUTPUT
|
179
|
-
expect(draft).to receive(:add_comment).with(
|
180
|
-
"foo.rb",
|
181
|
-
1,
|
182
|
-
"you done screwed up",
|
183
|
-
"error"
|
184
|
-
)
|
185
|
-
described_class.run("custom:sqlite3:CustomCaptor", "false")
|
186
|
-
end
|
187
8
|
end
|
188
9
|
|
189
10
|
context "stdin" do
|
data/spec/gergich_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative "../../lib/gergich/capture"
|
2
|
+
|
3
|
+
RSpec.shared_examples_for "a captor" do
|
4
|
+
let(:capture_format) do
|
5
|
+
Gergich::Capture::BaseCapture.normalize_captor_class_name(described_class)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "loads" do
|
9
|
+
captor = Gergich::Capture.load_captor(capture_format)
|
10
|
+
expect(captor).to eq(described_class)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "catches errors" do
|
14
|
+
comments = subject.run(output)
|
15
|
+
expect(comments).to match_array(comments)
|
16
|
+
end
|
17
|
+
end
|
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: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Jensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|
@@ -60,13 +60,23 @@ files:
|
|
60
60
|
- lib/gergich/capture/flake8_capture.rb
|
61
61
|
- lib/gergich/capture/i18nliner_capture.rb
|
62
62
|
- lib/gergich/capture/rubocop_capture.rb
|
63
|
+
- lib/gergich/capture/stylelint_capture.rb
|
63
64
|
- lib/gergich/capture/swiftlint_capture.rb
|
64
65
|
- lib/gergich/cli.rb
|
65
66
|
- lib/gergich/cli/gergich.rb
|
66
67
|
- lib/gergich/cli/master_bouncer.rb
|
68
|
+
- spec/gergich/capture/androidlint_capture_spec.rb
|
69
|
+
- spec/gergich/capture/custom_capture_spec.rb
|
70
|
+
- spec/gergich/capture/eslint_capture_spec.rb
|
71
|
+
- spec/gergich/capture/flake8_capture_spec.rb
|
72
|
+
- spec/gergich/capture/i18nliner_capture_spec.rb
|
73
|
+
- spec/gergich/capture/rubocop_capture_spec.rb
|
74
|
+
- spec/gergich/capture/stylelint_capture_spec.rb
|
75
|
+
- spec/gergich/capture/swiftlint_capture_spec.rb
|
67
76
|
- spec/gergich/capture_spec.rb
|
68
77
|
- spec/gergich_spec.rb
|
69
78
|
- spec/spec_helper.rb
|
79
|
+
- spec/support/capture_shared_examples.rb
|
70
80
|
homepage: https://github.com/instructure/gergich
|
71
81
|
licenses:
|
72
82
|
- MIT
|
@@ -87,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
97
|
version: '0'
|
88
98
|
requirements: []
|
89
99
|
rubyforge_project:
|
90
|
-
rubygems_version: 2.2.
|
100
|
+
rubygems_version: 2.2.3
|
91
101
|
signing_key:
|
92
102
|
specification_version: 4
|
93
103
|
summary: Command-line tool for adding Gerrit comments
|