gergich 1.1.1 → 2.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 (37) hide show
  1. checksums.yaml +5 -5
  2. data/{bin → exe}/gergich +0 -0
  3. data/{bin → exe}/master_bouncer +0 -0
  4. data/lib/gergich/capture/androidlint_capture.rb +10 -5
  5. data/lib/gergich/capture/brakeman_capture.rb +3 -2
  6. data/lib/gergich/capture/eslint_capture.rb +2 -1
  7. data/lib/gergich/capture/flake8_capture.rb +1 -1
  8. data/lib/gergich/capture/i18nliner_capture.rb +1 -1
  9. data/lib/gergich/capture/rubocop_capture.rb +38 -3
  10. data/lib/gergich/capture/shellcheck_capture.rb +2 -1
  11. data/lib/gergich/capture/stylelint_capture.rb +2 -5
  12. data/lib/gergich/capture/swiftlint_capture.rb +3 -3
  13. data/lib/gergich/capture/yamllint_capture.rb +31 -0
  14. data/lib/gergich/capture.rb +12 -5
  15. data/lib/gergich/cli/gergich.rb +6 -4
  16. data/lib/gergich/cli/master_bouncer.rb +6 -6
  17. data/lib/gergich/cli.rb +1 -1
  18. data/lib/gergich.rb +27 -28
  19. metadata +65 -41
  20. data/LICENSE +0 -20
  21. data/README.md +0 -178
  22. data/bin/check_coverage +0 -8
  23. data/bin/run_tests.sh +0 -52
  24. data/spec/gergich/capture/androidlint_capture_spec.rb +0 -61
  25. data/spec/gergich/capture/brakeman_capture_spec.rb +0 -91
  26. data/spec/gergich/capture/custom_capture_spec.rb +0 -41
  27. data/spec/gergich/capture/eslint_capture_spec.rb +0 -31
  28. data/spec/gergich/capture/flake8_capture_spec.rb +0 -23
  29. data/spec/gergich/capture/i18nliner_capture_spec.rb +0 -25
  30. data/spec/gergich/capture/rubocop_capture_spec.rb +0 -66
  31. data/spec/gergich/capture/shellcheck_capture_spec.rb +0 -83
  32. data/spec/gergich/capture/stylelint_capture_spec.rb +0 -54
  33. data/spec/gergich/capture/swiftlint_capture_spec.rb +0 -42
  34. data/spec/gergich/capture_spec.rb +0 -75
  35. data/spec/gergich_spec.rb +0 -379
  36. data/spec/spec_helper.rb +0 -92
  37. data/spec/support/capture_shared_examples.rb +0 -19
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.1.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Jensen
8
- autorequire:
9
- bindir: bin
8
+ autorequire:
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-07 00:00:00.000000000 Z
11
+ date: 2021-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -16,84 +16,126 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.16'
19
+ version: '0.17'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.16'
26
+ version: '0.17'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.3'
33
+ version: '1.4'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.3'
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
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '12.0'
61
+ version: '13.0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '12.0'
68
+ version: '13.0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '3.5'
75
+ version: '3.9'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '3.5'
82
+ version: '3.9'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rubocop
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '0.49'
89
+ version: '1.21'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.21'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.6'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.6'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.5'
76
118
  type: :development
77
119
  prerelease: false
78
120
  version_requirements: !ruby/object:Gem::Requirement
79
121
  requirements:
80
122
  - - "~>"
81
123
  - !ruby/object:Gem::Version
82
- version: '0.49'
124
+ version: '2.5'
83
125
  - !ruby/object:Gem::Dependency
84
126
  name: simplecov
85
127
  requirement: !ruby/object:Gem::Requirement
86
128
  requirements:
87
129
  - - "~>"
88
130
  - !ruby/object:Gem::Version
89
- version: 0.16.0
131
+ version: 0.21.2
90
132
  type: :development
91
133
  prerelease: false
92
134
  version_requirements: !ruby/object:Gem::Requirement
93
135
  requirements:
94
136
  - - "~>"
95
137
  - !ruby/object:Gem::Version
96
- version: 0.16.0
138
+ version: 0.21.2
97
139
  description: Gergich is a little command-line tool for wiring up linters to Gerrit
98
140
  so you can get nice inline comments right on the review
99
141
  email: jon@instructure.com
@@ -103,12 +145,8 @@ executables:
103
145
  extensions: []
104
146
  extra_rdoc_files: []
105
147
  files:
106
- - LICENSE
107
- - README.md
108
- - bin/check_coverage
109
- - bin/gergich
110
- - bin/master_bouncer
111
- - bin/run_tests.sh
148
+ - exe/gergich
149
+ - exe/master_bouncer
112
150
  - lib/gergich.rb
113
151
  - lib/gergich/capture.rb
114
152
  - lib/gergich/capture/androidlint_capture.rb
@@ -120,28 +158,15 @@ files:
120
158
  - lib/gergich/capture/shellcheck_capture.rb
121
159
  - lib/gergich/capture/stylelint_capture.rb
122
160
  - lib/gergich/capture/swiftlint_capture.rb
161
+ - lib/gergich/capture/yamllint_capture.rb
123
162
  - lib/gergich/cli.rb
124
163
  - lib/gergich/cli/gergich.rb
125
164
  - lib/gergich/cli/master_bouncer.rb
126
- - spec/gergich/capture/androidlint_capture_spec.rb
127
- - spec/gergich/capture/brakeman_capture_spec.rb
128
- - spec/gergich/capture/custom_capture_spec.rb
129
- - spec/gergich/capture/eslint_capture_spec.rb
130
- - spec/gergich/capture/flake8_capture_spec.rb
131
- - spec/gergich/capture/i18nliner_capture_spec.rb
132
- - spec/gergich/capture/rubocop_capture_spec.rb
133
- - spec/gergich/capture/shellcheck_capture_spec.rb
134
- - spec/gergich/capture/stylelint_capture_spec.rb
135
- - spec/gergich/capture/swiftlint_capture_spec.rb
136
- - spec/gergich/capture_spec.rb
137
- - spec/gergich_spec.rb
138
- - spec/spec_helper.rb
139
- - spec/support/capture_shared_examples.rb
140
165
  homepage: https://github.com/instructure/gergich
141
166
  licenses:
142
167
  - MIT
143
168
  metadata: {}
144
- post_install_message:
169
+ post_install_message:
145
170
  rdoc_options: []
146
171
  require_paths:
147
172
  - lib
@@ -149,16 +174,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
174
  requirements:
150
175
  - - ">="
151
176
  - !ruby/object:Gem::Version
152
- version: 2.4.0
177
+ version: '2.5'
153
178
  required_rubygems_version: !ruby/object:Gem::Requirement
154
179
  requirements:
155
180
  - - ">="
156
181
  - !ruby/object:Gem::Version
157
182
  version: '0'
158
183
  requirements: []
159
- rubyforge_project:
160
- rubygems_version: 2.6.14.4
161
- signing_key:
184
+ rubygems_version: 3.2.24
185
+ signing_key:
162
186
  specification_version: 4
163
187
  summary: Command-line tool for adding Gerrit comments
164
188
  test_files: []
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2015-2016 Instructure, Inc.
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md DELETED
@@ -1,178 +0,0 @@
1
- # Gergich
2
-
3
- [![Gem Version](https://badge.fury.io/rb/gergich.svg)](https://rubygems.org/gems/gergich)
4
- [![Dependency Status](https://gemnasium.com/badges/a2946a7849cd94f5ec0f4c3173a968f4.svg)](https://gemnasium.com/cc6fb44edee9fcf855cec82d3b6aed0f)
5
- [![Build Status](https://travis-ci.org/instructure/gergich.svg?branch=master)](https://travis-ci.org/instructure/gergich)
6
-
7
- Gergich is a command-line tool (and ruby lib) for easily posting comments
8
- on a [Gerrit](https://www.gerritcodereview.com/) review from a CI
9
- environment. It can be wired up to linters (rubocop, eslint, etc.) so that
10
- you can get nice inline comments right on the Gerrit review. That way
11
- developers don't have to go digging through CI logs to see why their
12
- builds failed.
13
-
14
- ## How does it work?
15
-
16
- Gergich maintains a little sqlite db of any draft comments/labels/etc.
17
- for the current patchset (defined by revision+ChangeId). This way
18
- different processes can all contribute to the review. For example,
19
- various linters add inline comments, and when the CI build finishes,
20
- Gergich publishes the review to Gerrit.
21
-
22
- ## Limitations
23
-
24
- Because everything is synchronized/stored in a local sqlite db, you
25
- should only call Gergich from a single box/build per patchset unless you
26
- have a unique `GERGICH_COMMENT_PREFIX` set for each box/build per patchset.
27
- Gergich does a check when publishing to ensure he hasn't already posted on
28
- this patchset before (w/ the same `GERGICH_COMMENT_PREFIX`); if he has,
29
- publish will be a no-op. This protects against reposts (say, on a retrigger),
30
- but it does mean that you shouldn't have completely different builds posting
31
- Gergich comments on the same revision, unless you set up different
32
- credentials for each.
33
-
34
- ## Installation
35
-
36
- Add the following to your Gemfile (perhaps in your `:test` group?):
37
-
38
- ```ruby
39
- gem "gergich"
40
- ```
41
-
42
- To use Gergich, you'll need a Gerrit user whose credentials it'll use
43
- (ideally not your own). With your shiny new username and password in hand,
44
- set `GERGICH_USER` and `GERGICH_KEY` accordingly in your CI environment.
45
-
46
- Additionally, Gergich needs to know where your Gerrit installation
47
- lives, so be sure to set `GERRIT_BASE_URL` (e.g.
48
- `https://gerrit.example.com`) or `GERRIT_HOST` (e.g. `gerrit.example.com`).
49
-
50
- Lastly, if you have no .git directory in CI land (say if you are building
51
- in docker and want to keep your images small), you also need to set
52
- `GERRIT_CHANGE_ID` and `GERRIT_PATCHSET_REVISION`. If you use Jenkins and
53
- the gerrit-trigger plugin, typcially all `GERRIT_*` vars will already be
54
- set, it's just a matter of plumbing them down to docker.
55
-
56
- ## Usage
57
-
58
- Run `gergich help` for detailed information about all supported commands.
59
- In your build scripts, you'll typically be using `gergich comment`,
60
- `gergich capture` and `gergich publish`. Comments are stored locally in a
61
- sqlite database until you publish. This way you can queue up comments from
62
- many disparate processes. Comments are published to `HEAD`'s corresponding
63
- patchset in Gerrit (based on Change-Id + `<sha>`)
64
-
65
- ### `gergich comment <comment_data>`
66
-
67
- `<comment_data>` is a JSON object (or array of objects). Each comment
68
- object should have the following properties:
69
-
70
- * **path** - the relative file path, e.g. "app/models/user.rb"
71
- * **position** - either a number (line) or an object (range). If an object,
72
- must have the following numeric properties:
73
- * start_line
74
- * start_character
75
- * end_line
76
- * end_character
77
- * **message** - the text of the comment
78
- * **severity** - `"info"|"warn"|"error"` - this will automatically prefix
79
- the comment (e.g. `"[ERROR] message here"`), and the most severe comment
80
- will be used to determine the overall `Code-Review` score (0, -1, or -2
81
- respectively)
82
-
83
- Note that a cover message and `Code-Review` score will be inferred from the
84
- most severe comment.
85
-
86
- #### Examples
87
-
88
- ```bash
89
- gergich comment '{"path":"foo.rb","position":3,"severity":"error",
90
- "message":"ಠ_ಠ"}'
91
- gergich comment '{"path":"bar.rb","severity":"warn",
92
- "position":{"start_line":3,"start_character":5,...},
93
- "message":"¯\_(ツ)_/¯"}'
94
- gergich comment '[{"path":"baz.rb",...}, {...}, {...}]'
95
- ```
96
-
97
- ### `gergich capture <format> <command>`
98
-
99
- For common linting formats, `gergich capture` can be used to automatically
100
- do `gergich comment` calls so you don't have to wire it up yourself.
101
-
102
- `<format>` - One of the following:
103
-
104
- * `brakeman`
105
- * `rubocop`
106
- * `eslint`
107
- * `i18nliner`
108
- * `flake8`
109
- * `stylelint`
110
- * `shellcheck` - shellcheck json output
111
- * `custom:<path>:<class_name>` - file path and ruby class_name of a custom
112
- formatter.
113
-
114
- `<command>` - The command to run whose output conforms to `<format>`.
115
- Output from the command will still go to STDOUT, and Gergich will
116
- preserve its exit status. If command is "-", Gergich will simply read
117
- from STDIN and the exit status will always be 0.
118
-
119
- #### Custom formatters:
120
-
121
- To create a custom formatter, create a class that implements a `run`
122
- method that takes a string of command output and returns an array of
123
- comment hashes (see `gergich comment`'s `<comment_data>` format), e.g.
124
-
125
- ```ruby
126
- class MyFormatter
127
- def run(output)
128
- output.scan(/^Oh noes! (.+?):(\d+): (.*)$/).map do |file, line, error|
129
- { path: file, message: error, position: line.to_i, severity: "error" }
130
- end
131
- end
132
- end
133
- ```
134
-
135
- #### Examples:
136
-
137
- ```bash
138
- gergich capture rubocop "bundle exec rubocop"
139
-
140
- gergich capture eslint eslint
141
-
142
- gergich capture i18nliner "rake i18nliner:check"
143
-
144
- gergich capture shellcheck "shellcheck --format json build.sh"
145
-
146
- gergich capture custom:./gergich/xss:Gergich::XSS "node script/xsslint"
147
-
148
- docker-compose run --rm web eslint | gergich capture eslint -
149
- # you might be interested in $PIPESTATUS[0]
150
- ```
151
-
152
- ### `gergich publish`
153
-
154
- Publish all draft comments/labels/messages for this patchset. no-op if
155
- there are none.
156
-
157
- The cover message and `Code-Review` label (e.g. -2) are inferred from the
158
- comments, but labels and messages may be manually set (via `gergich
159
- message` and `gergich labels`)
160
-
161
- ## How do I test my changes?
162
-
163
- Write tests of course, but also be sure to test it end-to-end via the
164
- CLI... Run `gergich` for a list of commands, as well as help for each
165
- command. There's also a `citest` thing that we run on our Jenkins that
166
- ensures each CLI command succeeds, but it doesn't test all branches for
167
- each command.
168
-
169
- After running a given command, you can run `gergich status` to see the
170
- current draft of the review (what will be sent to Gerrit when you do
171
- `gergich publish`).
172
-
173
- You can even do a test `publish` to Gerrit, if you have valid Gerrit
174
- credentials in `GERGICH_USER` / `GERGICH_KEY`. It infers the Gerrit patchset
175
- from the working directory, which may or may not correspond to something
176
- actually in Gerrit, so YMMV. That means you can post to a Gergich commit
177
- in Gerrit, or if you run it from another project's directory, you can post
178
- to its Gerrit revision.
data/bin/check_coverage DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "simplecov"
5
-
6
- SimpleCov.command_name "check_coverage"
7
- SimpleCov.minimum_coverage 85
8
- SimpleCov.at_exit { SimpleCov.result.format! }
data/bin/run_tests.sh DELETED
@@ -1,52 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -e
4
-
5
- function run_command {
6
- echo -e "\n[$@] STARTING $(date)"
7
- last_status=0
8
- "$@" || last_status=$?
9
- if [[ $last_status == 0 ]]; then
10
- echo -e "[$@] \033[32mOK\033[0m"
11
- else
12
- echo -e "[$@] \033[31mFAILED!\033[0m"
13
- fi
14
- echo -e "[$@] FINISHED $(date)\n"
15
-
16
- [[ $last_status == 0 ]] || clean_up_and_exit
17
- }
18
-
19
- function clean_up_and_exit {
20
- end_timestamp=$(date +%s)
21
- duration=$((end_timestamp-start_timestamp))
22
-
23
- if [[ $last_status != 0 ]]; then
24
- echo -e "\033[31mBUILD FAILED\033[0m in $duration seconds\n"
25
- else
26
- echo "BUILD PASSED in $duration seconds"
27
- fi
28
- exit $last_status
29
- }
30
-
31
- start_timestamp=$(date +%s)
32
-
33
- run_command bundle exec rubocop
34
-
35
- export COVERAGE=1
36
-
37
- run_command bundle exec rspec
38
-
39
- # these actually hit gerrit; only run them in CI land (you can do it
40
- # locally if you set all the docker-compose env vars)
41
- if [[ "$GERRIT_PATCHSET_REVISION" ]]; then
42
- run_command bin/gergich citest
43
- run_command bin/master_bouncer check
44
- DRY_RUN=1 run_command bin/master_bouncer check_all
45
- # ensure gergich works without .git directories
46
- rm -rf .git
47
- run_command bin/gergich status
48
- fi
49
-
50
- run_command bin/check_coverage
51
-
52
- clean_up_and_exit
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "../../support/capture_shared_examples"
4
-
5
- RSpec.describe Gergich::Capture::AndroidlintCapture do
6
- # rubocop:disable Metrics/LineLength
7
- let(:rtl_hardcoded) { 'Consider adding android:drawableStart="@drawable/a_media" to better support right-to-left layouts [RtlHardcoded]' }
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]" }
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]' }
10
- let(:unused_quantity) { 'For language "fr" (French) the following quantities are not relevant: few, zero [UnusedQuantity]' }
11
- # rubocop:enable Metrics/LineLength
12
- let(:output) do
13
- <<~OUTPUT
14
- /path/to/some.xml:27: Warning: #{rtl_hardcoded}
15
- android:drawableLeft="@drawable/ic_cv_media"/>
16
- ~~~~~~~~~~~~~~~~~~~~
17
-
18
- /path/to/AndroidManifest.xml: Warning: #{rtl_enabled}
19
-
20
- /path/to/library/0.0.2: Error: #{lint_error}
21
-
22
- /path/to/values.xml:5: Warning: #{unused_quantity}
23
- <plurals name="number">
24
- ^
25
-
26
- OUTPUT
27
- end
28
-
29
- let(:comments) do
30
- [
31
- {
32
- path: "/path/to/some.xml",
33
- position: 27,
34
- # rubocop:disable Metrics/LineLength
35
- message: "[androidlint] #{rtl_hardcoded}\n\n android:drawableLeft=\"@drawable/ic_cv_media\"/>\n ~~~~~~~~~~~~~~~~~~~~",
36
- # rubocop:enable Metrics/LineLength
37
- severity: "warn"
38
- },
39
- {
40
- path: "/path/to/AndroidManifest.xml",
41
- position: 0,
42
- message: "[androidlint] #{rtl_enabled}",
43
- severity: "warn"
44
- },
45
- {
46
- path: "/path/to/library/0.0.2",
47
- position: 0,
48
- message: "[androidlint] #{lint_error}",
49
- severity: "error"
50
- },
51
- {
52
- path: "/path/to/values.xml",
53
- position: 5,
54
- message: "[androidlint] #{unused_quantity}\n\n <plurals name=\"number\">\n ^",
55
- severity: "warn"
56
- }
57
- ]
58
- end
59
-
60
- it_behaves_like "a captor"
61
- end
@@ -1,91 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "../../support/capture_shared_examples"
4
-
5
- RSpec.describe Gergich::Capture::BrakemanCapture do
6
- let(:output) do
7
- File.read(
8
- File.expand_path(File.dirname(__FILE__) + "/brakeman_example.json")
9
- )
10
- end
11
-
12
- let(:comments) do
13
- [
14
- {
15
- path: "app/models/custom_data.rb",
16
- position: 36,
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
21
- severity: "warn"
22
- },
23
- {
24
- path: "app/models/submission_comment.rb",
25
- position: 0,
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
31
- severity: "warn"
32
- },
33
- {
34
- path: "app/controllers/context_controller.rb",
35
- position: 60,
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
42
- severity: "warn"
43
- },
44
- {
45
- path: "app/views/context/object_snippet.html.erb",
46
- position: 6,
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
52
- MESSAGE
53
- severity: "warn"
54
- },
55
- {
56
- path: "app/models/account.rb",
57
- position: 795,
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/
63
- MESSAGE
64
- severity: "error"
65
- },
66
- {
67
- path: "lib/cc/importer/blti_converter.rb",
68
- position: 145,
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/
73
- MESSAGE
74
- severity: "error"
75
- },
76
- {
77
- path: "lib/cc/importer/canvas/quiz_converter.rb",
78
- position: 44,
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/
84
- MESSAGE
85
- severity: "warn"
86
- }
87
- ]
88
- end
89
-
90
- it_behaves_like "a captor"
91
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "../../../lib/gergich/capture"
4
-
5
- RSpec.describe "CustomCaptor" do
6
- class CustomCaptor
7
- def run(output)
8
- output.scan(/^(.+?):(\d+): (.*)$/).map do |file, line, error|
9
- { path: file, message: error, position: line.to_i, severity: "error" }
10
- end
11
- end
12
- end
13
-
14
- let(:described_class) { CustomCaptor }
15
- let(:capture_format) { "custom:sqlite3:CustomCaptor" }
16
- let(:output) do
17
- <<~OUTPUT
18
- foo.rb:1: you done screwed up
19
- OUTPUT
20
- end
21
- let(:comments) do
22
- [
23
- {
24
- path: "foo.rb",
25
- position: 1,
26
- message: "you done screwed up",
27
- severity: "error"
28
- }
29
- ]
30
- end
31
-
32
- it "loads" do
33
- captor = Gergich::Capture.load_captor(capture_format)
34
- expect(captor).to eq(described_class)
35
- end
36
-
37
- it "catches errors" do
38
- comments = subject.run(output)
39
- expect(comments).to match_array(comments)
40
- end
41
- end