gergich 0.2.2 → 1.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 +5 -5
- data/bin/check_coverage +2 -1
- data/bin/gergich +1 -0
- data/bin/master_bouncer +1 -1
- data/bin/run_tests.sh +0 -5
- data/lib/gergich.rb +17 -23
- data/lib/gergich/capture.rb +6 -2
- data/lib/gergich/capture/androidlint_capture.rb +4 -0
- data/lib/gergich/capture/brakeman_capture.rb +4 -2
- data/lib/gergich/capture/eslint_capture.rb +2 -0
- data/lib/gergich/capture/flake8_capture.rb +2 -0
- data/lib/gergich/capture/i18nliner_capture.rb +2 -0
- data/lib/gergich/capture/rubocop_capture.rb +2 -0
- data/lib/gergich/capture/shellcheck_capture.rb +2 -0
- data/lib/gergich/capture/stylelint_capture.rb +6 -4
- data/lib/gergich/capture/swiftlint_capture.rb +4 -0
- data/lib/gergich/cli.rb +4 -2
- data/lib/gergich/cli/gergich.rb +119 -118
- data/lib/gergich/cli/master_bouncer.rb +16 -14
- data/spec/gergich/capture/androidlint_capture_spec.rb +14 -9
- data/spec/gergich/capture/brakeman_capture_spec.rb +43 -41
- data/spec/gergich/capture/custom_capture_spec.rb +4 -2
- data/spec/gergich/capture/eslint_capture_spec.rb +6 -4
- data/spec/gergich/capture/flake8_capture_spec.rb +4 -2
- data/spec/gergich/capture/i18nliner_capture_spec.rb +6 -4
- data/spec/gergich/capture/rubocop_capture_spec.rb +24 -22
- data/spec/gergich/capture/shellcheck_capture_spec.rb +45 -43
- data/spec/gergich/capture/stylelint_capture_spec.rb +9 -7
- data/spec/gergich/capture/swiftlint_capture_spec.rb +7 -4
- data/spec/gergich/capture_spec.rb +6 -4
- data/spec/gergich_spec.rb +43 -4
- data/spec/spec_helper.rb +2 -0
- data/spec/support/capture_shared_examples.rb +2 -0
- metadata +35 -35
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../cli"
|
2
4
|
|
3
5
|
ENV["GERGICH_USER"] = ENV.fetch("MASTER_BOUNCER_USER", "master_bouncer")
|
@@ -19,7 +21,7 @@ def potentially_mergeable_changes
|
|
19
21
|
"branch:master" \
|
20
22
|
"&o=CURRENT_REVISION"
|
21
23
|
changes = Gergich::API.get(url)
|
22
|
-
changes.
|
24
|
+
changes.reject { |c| c["subject"] =~ /\Awip($|\W)/i }
|
23
25
|
end
|
24
26
|
|
25
27
|
def maybe_bounce_commit!(commit)
|
@@ -67,22 +69,22 @@ commands = {}
|
|
67
69
|
|
68
70
|
commands["check"] = {
|
69
71
|
summary: "Check the current commit's age",
|
70
|
-
action: ->
|
72
|
+
action: -> {
|
71
73
|
maybe_bounce_commit! Gergich::Commit.new
|
72
74
|
},
|
73
|
-
help: ->
|
74
|
-
|
75
|
-
master_bouncer check
|
75
|
+
help: -> {
|
76
|
+
<<~TEXT
|
77
|
+
master_bouncer check
|
76
78
|
|
77
|
-
Check the current commit's age, and bounce it if it's too old (-1 or -2,
|
78
|
-
depending on the threshold)
|
79
|
-
TEXT
|
79
|
+
Check the current commit's age, and bounce it if it's too old (-1 or -2,
|
80
|
+
depending on the threshold)
|
81
|
+
TEXT
|
80
82
|
}
|
81
83
|
}
|
82
84
|
|
83
85
|
commands["check_all"] = {
|
84
86
|
summary: "Check the age of all potentially mergeable changes",
|
85
|
-
action: ->
|
87
|
+
action: -> {
|
86
88
|
Gergich.git("fetch")
|
87
89
|
gerrit_host = ENV["GERRIT_HOST"] || error("No GERRIT_HOST set")
|
88
90
|
|
@@ -102,12 +104,12 @@ commands["check_all"] = {
|
|
102
104
|
sleep 1
|
103
105
|
end
|
104
106
|
},
|
105
|
-
help: ->
|
106
|
-
|
107
|
-
master_bouncer check_all
|
107
|
+
help: -> {
|
108
|
+
<<~TEXT
|
109
|
+
master_bouncer check_all
|
108
110
|
|
109
|
-
Check all open Verified+1 patchsets and bounce any that are too old.
|
110
|
-
TEXT
|
111
|
+
Check all open Verified+1 patchsets and bounce any that are too old.
|
112
|
+
TEXT
|
111
113
|
}
|
112
114
|
}
|
113
115
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../../support/capture_shared_examples"
|
2
4
|
|
3
5
|
RSpec.describe Gergich::Capture::AndroidlintCapture do
|
@@ -6,19 +8,20 @@ RSpec.describe Gergich::Capture::AndroidlintCapture do
|
|
6
8
|
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
9
|
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
10
|
let(:unused_quantity) { 'For language "fr" (French) the following quantities are not relevant: few, zero [UnusedQuantity]' }
|
11
|
+
# rubocop:enable Metrics/LineLength
|
9
12
|
let(:output) do
|
10
|
-
|
11
|
-
/path/to/some.xml:27: Warning: #{rtl_hardcoded}
|
12
|
-
|
13
|
-
|
13
|
+
<<~OUTPUT
|
14
|
+
/path/to/some.xml:27: Warning: #{rtl_hardcoded}
|
15
|
+
android:drawableLeft="@drawable/ic_cv_media"/>
|
16
|
+
~~~~~~~~~~~~~~~~~~~~
|
14
17
|
|
15
|
-
/path/to/AndroidManifest.xml: Warning: #{rtl_enabled}
|
18
|
+
/path/to/AndroidManifest.xml: Warning: #{rtl_enabled}
|
16
19
|
|
17
|
-
/path/to/library/0.0.2: Error: #{lint_error}
|
20
|
+
/path/to/library/0.0.2: Error: #{lint_error}
|
18
21
|
|
19
|
-
/path/to/values.xml:5: Warning: #{unused_quantity}
|
20
|
-
|
21
|
-
|
22
|
+
/path/to/values.xml:5: Warning: #{unused_quantity}
|
23
|
+
<plurals name="number">
|
24
|
+
^
|
22
25
|
|
23
26
|
OUTPUT
|
24
27
|
end
|
@@ -28,7 +31,9 @@ RSpec.describe Gergich::Capture::AndroidlintCapture do
|
|
28
31
|
{
|
29
32
|
path: "/path/to/some.xml",
|
30
33
|
position: 27,
|
34
|
+
# rubocop:disable Metrics/LineLength
|
31
35
|
message: "[androidlint] #{rtl_hardcoded}\n\n android:drawableLeft=\"@drawable/ic_cv_media\"/>\n ~~~~~~~~~~~~~~~~~~~~",
|
36
|
+
# rubocop:enable Metrics/LineLength
|
32
37
|
severity: "warn"
|
33
38
|
},
|
34
39
|
{
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../../support/capture_shared_examples"
|
2
4
|
|
3
5
|
RSpec.describe Gergich::Capture::BrakemanCapture do
|
@@ -10,75 +12,75 @@ RSpec.describe Gergich::Capture::BrakemanCapture do
|
|
10
12
|
let(:comments) do
|
11
13
|
[
|
12
14
|
{
|
13
|
-
path:
|
15
|
+
path: "app/models/custom_data.rb",
|
14
16
|
position: 36,
|
15
|
-
message:
|
16
|
-
[brakeman] Attribute Restriction: attr_accessible is recommended over attr_protected
|
17
|
-
|
18
|
-
|
17
|
+
message: <<~MESSAGE.strip,
|
18
|
+
[brakeman] Attribute Restriction: attr_accessible is recommended over attr_protected
|
19
|
+
See: http://brakemanscanner.org/docs/warning_types/attribute_restriction/
|
20
|
+
MESSAGE
|
19
21
|
severity: "warn"
|
20
22
|
},
|
21
23
|
{
|
22
|
-
path:
|
24
|
+
path: "app/models/submission_comment.rb",
|
23
25
|
position: 0,
|
24
|
-
message:
|
25
|
-
[brakeman] Mass Assignment: Potentially dangerous attribute available for mass assignment
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
message: <<~MESSAGE.strip,
|
27
|
+
[brakeman] Mass Assignment: Potentially dangerous attribute available for mass assignment
|
28
|
+
Code: :context_id
|
29
|
+
See: http://brakemanscanner.org/docs/warning_types/mass_assignment/
|
30
|
+
MESSAGE
|
29
31
|
severity: "warn"
|
30
32
|
},
|
31
33
|
{
|
32
|
-
path:
|
34
|
+
path: "app/controllers/context_controller.rb",
|
33
35
|
position: 60,
|
34
|
-
message:
|
35
|
-
[brakeman] Redirect: Possible unprotected redirect
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
message: <<~MESSAGE.strip,
|
37
|
+
[brakeman] Redirect: Possible unprotected redirect
|
38
|
+
Code: redirect_to(CanvasKaltura::ClientV3.new.assetSwfUrl(params[:id]))
|
39
|
+
User Input: params[:id]
|
40
|
+
See: http://brakemanscanner.org/docs/warning_types/redirect/
|
41
|
+
MESSAGE
|
40
42
|
severity: "warn"
|
41
43
|
},
|
42
44
|
{
|
43
|
-
path:
|
45
|
+
path: "app/views/context/object_snippet.html.erb",
|
44
46
|
position: 6,
|
45
|
-
message:
|
46
|
-
[brakeman] Cross Site Scripting: Unescaped parameter value
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
message: <<~MESSAGE.strip,
|
48
|
+
[brakeman] Cross Site Scripting: Unescaped parameter value
|
49
|
+
Code: Base64.decode64((params[:object_data] or ""))
|
50
|
+
User Input: params[:object_data]
|
51
|
+
See: http://brakemanscanner.org/docs/warning_types/cross_site_scripting
|
50
52
|
MESSAGE
|
51
53
|
severity: "warn"
|
52
54
|
},
|
53
55
|
{
|
54
|
-
path:
|
56
|
+
path: "app/models/account.rb",
|
55
57
|
position: 795,
|
56
|
-
message:
|
57
|
-
[brakeman] SQL Injection: Possible SQL injection
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
message: <<~MESSAGE.strip,
|
59
|
+
[brakeman] SQL Injection: Possible SQL injection
|
60
|
+
Code: Account.find_by_sql(Account.sub_account_ids_recursive_sql(parent_account_id))
|
61
|
+
User Input: Account.sub_account_ids_recursive_sql(parent_account_id)
|
62
|
+
See: http://brakemanscanner.org/docs/warning_types/sql_injection/
|
61
63
|
MESSAGE
|
62
64
|
severity: "error"
|
63
65
|
},
|
64
66
|
{
|
65
|
-
path:
|
67
|
+
path: "lib/cc/importer/blti_converter.rb",
|
66
68
|
position: 145,
|
67
|
-
message:
|
68
|
-
[brakeman] SSL Verification Bypass: SSL certificate verification was bypassed
|
69
|
-
|
70
|
-
|
69
|
+
message: <<~MESSAGE.strip,
|
70
|
+
[brakeman] SSL Verification Bypass: SSL certificate verification was bypassed
|
71
|
+
Code: Net::HTTP.new(URI.parse(url).host, URI.parse(url).port).verify_mode = OpenSSL::SSL::VERIFY_NONE
|
72
|
+
See: http://brakemanscanner.org/docs/warning_types/ssl_verification_bypass/
|
71
73
|
MESSAGE
|
72
74
|
severity: "error"
|
73
75
|
},
|
74
76
|
{
|
75
|
-
path:
|
77
|
+
path: "lib/cc/importer/canvas/quiz_converter.rb",
|
76
78
|
position: 44,
|
77
|
-
message:
|
78
|
-
[brakeman] Command Injection: Possible command injection
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
message: <<~MESSAGE.strip,
|
80
|
+
[brakeman] Command Injection: Possible command injection
|
81
|
+
Code: `\#{Qti.get_conversion_command(File.join(qti_folder, "qti_2_1"), qti_folder)}`
|
82
|
+
User Input: Qti.get_conversion_command(File.join(qti_folder, "qti_2_1"), qti_folder)
|
83
|
+
See: http://brakemanscanner.org/docs/warning_types/command_injection/
|
82
84
|
MESSAGE
|
83
85
|
severity: "warn"
|
84
86
|
}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../../../lib/gergich/capture"
|
2
4
|
|
3
5
|
RSpec.describe "CustomCaptor" do
|
@@ -12,8 +14,8 @@ RSpec.describe "CustomCaptor" do
|
|
12
14
|
let(:described_class) { CustomCaptor }
|
13
15
|
let(:capture_format) { "custom:sqlite3:CustomCaptor" }
|
14
16
|
let(:output) do
|
15
|
-
|
16
|
-
foo.rb:1: you done screwed up
|
17
|
+
<<~OUTPUT
|
18
|
+
foo.rb:1: you done screwed up
|
17
19
|
OUTPUT
|
18
20
|
end
|
19
21
|
let(:comments) do
|
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../../support/capture_shared_examples"
|
2
4
|
|
3
5
|
RSpec.describe Gergich::Capture::EslintCapture do
|
4
6
|
let(:output) do
|
5
|
-
|
6
|
-
jsapp/models/user.js
|
7
|
-
|
8
|
-
|
7
|
+
<<~OUTPUT
|
8
|
+
jsapp/models/user.js
|
9
|
+
4:21 error Missing semicolon semi
|
10
|
+
5:1 warning Too much cowbell cowbell-overload
|
9
11
|
OUTPUT
|
10
12
|
end
|
11
13
|
let(:comments) do
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../../support/capture_shared_examples"
|
2
4
|
|
3
5
|
RSpec.describe Gergich::Capture::Flake8Capture do
|
4
6
|
let(:output) do
|
5
|
-
|
6
|
-
./djangogeneric/settings/base.py:73:80: E501 line too long (81 > 79 characters)
|
7
|
+
<<~OUTPUT
|
8
|
+
./djangogeneric/settings/base.py:73:80: E501 line too long (81 > 79 characters)
|
7
9
|
OUTPUT
|
8
10
|
end
|
9
11
|
let(:comments) do
|
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../../support/capture_shared_examples"
|
2
4
|
|
3
5
|
RSpec.describe Gergich::Capture::I18nlinerCapture do
|
4
6
|
let(:output) do
|
5
|
-
|
6
|
-
1)
|
7
|
-
invalid signature on line 4: <unsupported expression>
|
8
|
-
jsapp/models/user.js
|
7
|
+
<<~OUTPUT
|
8
|
+
1)
|
9
|
+
invalid signature on line 4: <unsupported expression>
|
10
|
+
jsapp/models/user.js
|
9
11
|
OUTPUT
|
10
12
|
end
|
11
13
|
let(:comments) do
|
@@ -1,22 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../../support/capture_shared_examples"
|
2
4
|
|
3
5
|
RSpec.describe Gergich::Capture::RubocopCapture do
|
4
6
|
let(:output) do
|
5
|
-
|
6
|
-
Offenses:
|
7
|
+
<<~OUTPUT
|
8
|
+
Offenses:
|
7
9
|
|
8
|
-
bin/gergich:47:8: C: Prefer double-quoted strings
|
9
|
-
if ENV['DEBUG']
|
10
|
-
|
11
|
-
foo/bar/baz.rb:1:2: W: no context for this one :shrug:
|
12
|
-
lib/gergich.rb:10:9: E: this is a terrible name
|
10
|
+
bin/gergich:47:8: C: Prefer double-quoted strings
|
11
|
+
if ENV['DEBUG']
|
12
|
+
^^^^^^^
|
13
|
+
foo/bar/baz.rb:1:2: W: no context for this one :shrug:
|
14
|
+
lib/gergich.rb:10:9: E: this is a terrible name
|
13
15
|
|
14
|
-
seriously, what were you thinking?
|
15
|
-
|
16
|
-
|
17
|
-
lib/gergich.rb:22:55: W: Line is too long. [55/54]
|
18
|
-
|
19
|
-
|
16
|
+
seriously, what were you thinking?
|
17
|
+
def foo
|
18
|
+
^^^
|
19
|
+
lib/gergich.rb:22:55: W: Line is too long. [55/54]
|
20
|
+
def initialize(ref = "HEAD", revision_number = nil)
|
21
|
+
^^
|
20
22
|
OUTPUT
|
21
23
|
end
|
22
24
|
let(:comments) do
|
@@ -36,24 +38,24 @@ lib/gergich.rb:22:55: W: Line is too long. [55/54]
|
|
36
38
|
{
|
37
39
|
path: "lib/gergich.rb",
|
38
40
|
position: 10,
|
39
|
-
message:
|
40
|
-
[rubocop] this is a terrible name
|
41
|
+
message: <<~OUTPUT,
|
42
|
+
[rubocop] this is a terrible name
|
41
43
|
|
42
|
-
seriously, what were you thinking?
|
44
|
+
seriously, what were you thinking?
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
+
def foo
|
47
|
+
^^^
|
46
48
|
OUTPUT
|
47
49
|
severity: "error"
|
48
50
|
},
|
49
51
|
{
|
50
52
|
path: "lib/gergich.rb",
|
51
53
|
position: 22,
|
52
|
-
message:
|
53
|
-
[rubocop] Line is too long. [55/54]
|
54
|
+
message: <<~OUTPUT,
|
55
|
+
[rubocop] Line is too long. [55/54]
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
+
def initialize(ref = "HEAD", revision_number = nil)
|
58
|
+
^^
|
57
59
|
OUTPUT
|
58
60
|
severity: "warn"
|
59
61
|
}
|
@@ -1,50 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../../support/capture_shared_examples"
|
2
4
|
|
3
5
|
RSpec.describe Gergich::Capture::ShellcheckCapture do
|
4
6
|
let(:output) do
|
5
|
-
|
6
|
-
[
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
]
|
7
|
+
<<~'OUTPUT'
|
8
|
+
[
|
9
|
+
{
|
10
|
+
"file": "bin/sync-translations.sh",
|
11
|
+
"line": 23,
|
12
|
+
"endLine": 23,
|
13
|
+
"column": 21,
|
14
|
+
"endColumn": 21,
|
15
|
+
"level": "style",
|
16
|
+
"code": 2006,
|
17
|
+
"message": "Use $(..) instead of legacy `..`."
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"file": "bin/sync-translations.sh",
|
21
|
+
"line": 23,
|
22
|
+
"endLine": 23,
|
23
|
+
"column": 43,
|
24
|
+
"endColumn": 43,
|
25
|
+
"level": "warning",
|
26
|
+
"code": 2046,
|
27
|
+
"message": "Quote this to prevent word splitting."
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"file": "bin/sync-translations.sh",
|
31
|
+
"line": 32,
|
32
|
+
"endLine": 32,
|
33
|
+
"column": 62,
|
34
|
+
"endColumn": 62,
|
35
|
+
"level": "info",
|
36
|
+
"code": 2086,
|
37
|
+
"message": "Double quote to prevent globbing and word splitting."
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"file": "fail.sh",
|
41
|
+
"line": 3,
|
42
|
+
"endLine": 3,
|
43
|
+
"column": 12,
|
44
|
+
"endColumn": 12,
|
45
|
+
"level": "error",
|
46
|
+
"code": 1101,
|
47
|
+
"message": "Delete trailing spaces after \\ to break line (or use quotes for literal space)."
|
48
|
+
}
|
49
|
+
]
|
48
50
|
OUTPUT
|
49
51
|
end
|
50
52
|
|