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.
Files changed (34) hide show
  1. checksums.yaml +5 -5
  2. data/bin/check_coverage +2 -1
  3. data/bin/gergich +1 -0
  4. data/bin/master_bouncer +1 -1
  5. data/bin/run_tests.sh +0 -5
  6. data/lib/gergich.rb +17 -23
  7. data/lib/gergich/capture.rb +6 -2
  8. data/lib/gergich/capture/androidlint_capture.rb +4 -0
  9. data/lib/gergich/capture/brakeman_capture.rb +4 -2
  10. data/lib/gergich/capture/eslint_capture.rb +2 -0
  11. data/lib/gergich/capture/flake8_capture.rb +2 -0
  12. data/lib/gergich/capture/i18nliner_capture.rb +2 -0
  13. data/lib/gergich/capture/rubocop_capture.rb +2 -0
  14. data/lib/gergich/capture/shellcheck_capture.rb +2 -0
  15. data/lib/gergich/capture/stylelint_capture.rb +6 -4
  16. data/lib/gergich/capture/swiftlint_capture.rb +4 -0
  17. data/lib/gergich/cli.rb +4 -2
  18. data/lib/gergich/cli/gergich.rb +119 -118
  19. data/lib/gergich/cli/master_bouncer.rb +16 -14
  20. data/spec/gergich/capture/androidlint_capture_spec.rb +14 -9
  21. data/spec/gergich/capture/brakeman_capture_spec.rb +43 -41
  22. data/spec/gergich/capture/custom_capture_spec.rb +4 -2
  23. data/spec/gergich/capture/eslint_capture_spec.rb +6 -4
  24. data/spec/gergich/capture/flake8_capture_spec.rb +4 -2
  25. data/spec/gergich/capture/i18nliner_capture_spec.rb +6 -4
  26. data/spec/gergich/capture/rubocop_capture_spec.rb +24 -22
  27. data/spec/gergich/capture/shellcheck_capture_spec.rb +45 -43
  28. data/spec/gergich/capture/stylelint_capture_spec.rb +9 -7
  29. data/spec/gergich/capture/swiftlint_capture_spec.rb +7 -4
  30. data/spec/gergich/capture_spec.rb +6 -4
  31. data/spec/gergich_spec.rb +43 -4
  32. data/spec/spec_helper.rb +2 -0
  33. data/spec/support/capture_shared_examples.rb +2 -0
  34. 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.select { |c| c["subject"] !~ /\Awip($|\W)/i }
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
- <<-TEXT
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
- <<-TEXT
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
- <<-OUTPUT
11
- /path/to/some.xml:27: Warning: #{rtl_hardcoded}
12
- android:drawableLeft="@drawable/ic_cv_media"/>
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
- <plurals name="number">
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: "app/models/custom_data.rb",
15
+ path: "app/models/custom_data.rb",
14
16
  position: 36,
15
- message: <<-MESSAGE.strip,
16
- [brakeman] Attribute Restriction: attr_accessible is recommended over attr_protected
17
- See: http://brakemanscanner.org/docs/warning_types/attribute_restriction/
18
- MESSAGE
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: "app/models/submission_comment.rb",
24
+ path: "app/models/submission_comment.rb",
23
25
  position: 0,
24
- message: <<-MESSAGE.strip,
25
- [brakeman] Mass Assignment: Potentially dangerous attribute available for mass assignment
26
- Code: :context_id
27
- See: http://brakemanscanner.org/docs/warning_types/mass_assignment/
28
- MESSAGE
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: "app/controllers/context_controller.rb",
34
+ path: "app/controllers/context_controller.rb",
33
35
  position: 60,
34
- message: <<-MESSAGE.strip,
35
- [brakeman] Redirect: Possible unprotected redirect
36
- Code: redirect_to(CanvasKaltura::ClientV3.new.assetSwfUrl(params[:id]))
37
- User Input: params[:id]
38
- See: http://brakemanscanner.org/docs/warning_types/redirect/
39
- MESSAGE
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: "app/views/context/object_snippet.html.erb",
45
+ path: "app/views/context/object_snippet.html.erb",
44
46
  position: 6,
45
- message: <<-MESSAGE.strip,
46
- [brakeman] Cross Site Scripting: Unescaped parameter value
47
- Code: Base64.decode64((params[:object_data] or ""))
48
- User Input: params[:object_data]
49
- See: http://brakemanscanner.org/docs/warning_types/cross_site_scripting
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: "app/models/account.rb",
56
+ path: "app/models/account.rb",
55
57
  position: 795,
56
- message: <<-MESSAGE.strip,
57
- [brakeman] SQL Injection: Possible SQL injection
58
- Code: Account.find_by_sql(Account.sub_account_ids_recursive_sql(parent_account_id))
59
- User Input: Account.sub_account_ids_recursive_sql(parent_account_id)
60
- See: http://brakemanscanner.org/docs/warning_types/sql_injection/
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: "lib/cc/importer/blti_converter.rb",
67
+ path: "lib/cc/importer/blti_converter.rb",
66
68
  position: 145,
67
- message: <<-MESSAGE.strip,
68
- [brakeman] SSL Verification Bypass: SSL certificate verification was bypassed
69
- Code: Net::HTTP.new(URI.parse(url).host, URI.parse(url).port).verify_mode = OpenSSL::SSL::VERIFY_NONE
70
- See: http://brakemanscanner.org/docs/warning_types/ssl_verification_bypass/
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: "lib/cc/importer/canvas/quiz_converter.rb",
77
+ path: "lib/cc/importer/canvas/quiz_converter.rb",
76
78
  position: 44,
77
- message: <<-MESSAGE.strip,
78
- [brakeman] Command Injection: Possible command injection
79
- Code: `\#{Qti.get_conversion_command(File.join(qti_folder, "qti_2_1"), qti_folder)}`
80
- User Input: Qti.get_conversion_command(File.join(qti_folder, "qti_2_1"), qti_folder)
81
- See: http://brakemanscanner.org/docs/warning_types/command_injection/
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
- <<-OUTPUT
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
- <<-OUTPUT
6
- jsapp/models/user.js
7
- 4:21 error Missing semicolon semi
8
- 5:1 warning Too much cowbell cowbell-overload
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
- <<-OUTPUT
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
- <<-OUTPUT
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
- <<-OUTPUT
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
- def foo
16
- ^^^
17
- lib/gergich.rb:22:55: W: Line is too long. [55/54]
18
- def initialize(ref = "HEAD", revision_number = nil)
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: <<-OUTPUT,
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
- def foo
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: <<-OUTPUT,
53
- [rubocop] Line is too long. [55/54]
54
+ message: <<~OUTPUT,
55
+ [rubocop] Line is too long. [55/54]
54
56
 
55
- def initialize(ref = "HEAD", revision_number = nil)
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
- <<-'OUTPUT'
6
- [
7
- {
8
- "file": "bin/sync-translations.sh",
9
- "line": 23,
10
- "endLine": 23,
11
- "column": 21,
12
- "endColumn": 21,
13
- "level": "style",
14
- "code": 2006,
15
- "message": "Use $(..) instead of legacy `..`."
16
- },
17
- {
18
- "file": "bin/sync-translations.sh",
19
- "line": 23,
20
- "endLine": 23,
21
- "column": 43,
22
- "endColumn": 43,
23
- "level": "warning",
24
- "code": 2046,
25
- "message": "Quote this to prevent word splitting."
26
- },
27
- {
28
- "file": "bin/sync-translations.sh",
29
- "line": 32,
30
- "endLine": 32,
31
- "column": 62,
32
- "endColumn": 62,
33
- "level": "info",
34
- "code": 2086,
35
- "message": "Double quote to prevent globbing and word splitting."
36
- },
37
- {
38
- "file": "fail.sh",
39
- "line": 3,
40
- "endLine": 3,
41
- "column": 12,
42
- "endColumn": 12,
43
- "level": "error",
44
- "code": 1101,
45
- "message": "Delete trailing spaces after \\ to break line (or use quotes for literal space)."
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