danger-warnings 0.0.1 → 0.1.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 +4 -4
- data/CHANGELOG.md +11 -0
- data/Dangerfile +5 -0
- data/README.md +33 -5
- data/lib/warnings/gem_version.rb +1 -1
- data/lib/warnings/{markdown_util.rb → helper/message_util.rb} +31 -7
- data/lib/warnings/helper/severity_util.rb +45 -0
- data/lib/warnings/parser/bandit_parser.rb +2 -8
- data/lib/warnings/parser/parser.rb +23 -15
- data/lib/warnings/parser/parser_factory.rb +5 -1
- data/lib/warnings/parser/pylint_parser.rb +38 -0
- data/lib/warnings/parser/rubocop_parser.rb +77 -0
- data/lib/warnings/plugin.rb +1 -1
- data/lib/warnings/{issue.rb → report/issue.rb} +2 -7
- data/lib/warnings/{reporter.rb → report/reporter.rb} +4 -9
- data/spec/assets/empty.txt +0 -0
- data/spec/assets/pylint.txt +582 -0
- data/spec/assets/rubocop.json +265 -0
- data/spec/assets/rubocop.txt +27 -0
- data/spec/assets/rubocop_multi_offenses.json +142 -0
- data/spec/helper/message_util_spec.rb +108 -0
- data/spec/helper/severity_util_spec.rb +70 -0
- data/spec/parser/bandit_parser_spec.rb +8 -36
- data/spec/parser/parser_factory_spec.rb +24 -12
- data/spec/parser/pylint_parser_spec.rb +57 -0
- data/spec/parser/rubocop_parser_spec.rb +94 -0
- data/spec/{reporter_spec.rb → report/reporter_spec.rb} +42 -2
- data/spec/spec_helper.rb +1 -1
- data/spec/spec_helper/assets.rb +53 -0
- data/spec/warnings_spec.rb +0 -5
- metadata +31 -14
- data/lib/warnings/severity.rb +0 -12
- data/spec/assets/assets.rb +0 -8
- data/spec/markdown_util_spec.rb +0 -65
- data/spec/severity_spec.rb +0 -26
data/spec/warnings_spec.rb
CHANGED
@@ -17,11 +17,6 @@ module Danger
|
|
17
17
|
before do
|
18
18
|
@dangerfile = testing_dangerfile
|
19
19
|
@my_plugin = @dangerfile.warnings
|
20
|
-
|
21
|
-
# mock the PR data
|
22
|
-
# you can then use this, eg. github.pr_author, later in the spec
|
23
|
-
# json = File.read(File.dirname(__FILE__) + '/support/fixtures/github_pr.json') # example json: `curl https://api.github.com/repos/danger/danger-plugin-template/pulls/18 > github_pr.json`
|
24
|
-
# allow(@my_plugin.github).to receive(:pr_json).and_return(json)
|
25
20
|
end
|
26
21
|
end
|
27
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-warnings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyaak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: abstract_method
|
@@ -217,6 +217,7 @@ files:
|
|
217
217
|
- ".rubocop.yml"
|
218
218
|
- ".travis.yml"
|
219
219
|
- CHANGELOG.md
|
220
|
+
- Dangerfile
|
220
221
|
- Gemfile
|
221
222
|
- Guardfile
|
222
223
|
- LICENSE.txt
|
@@ -226,25 +227,34 @@ files:
|
|
226
227
|
- lib/danger_plugin.rb
|
227
228
|
- lib/danger_warnings.rb
|
228
229
|
- lib/warnings/gem_version.rb
|
229
|
-
- lib/warnings/
|
230
|
-
- lib/warnings/
|
230
|
+
- lib/warnings/helper/message_util.rb
|
231
|
+
- lib/warnings/helper/severity_util.rb
|
231
232
|
- lib/warnings/parser/bandit_parser.rb
|
232
233
|
- lib/warnings/parser/parser.rb
|
233
234
|
- lib/warnings/parser/parser_factory.rb
|
235
|
+
- lib/warnings/parser/pylint_parser.rb
|
236
|
+
- lib/warnings/parser/rubocop_parser.rb
|
234
237
|
- lib/warnings/plugin.rb
|
235
|
-
- lib/warnings/
|
236
|
-
- lib/warnings/
|
238
|
+
- lib/warnings/report/issue.rb
|
239
|
+
- lib/warnings/report/reporter.rb
|
237
240
|
- sonar-project.properties
|
238
|
-
- spec/assets/assets.rb
|
239
241
|
- spec/assets/bandit.json
|
240
242
|
- spec/assets/bandit_empty.json
|
241
243
|
- spec/assets/bandit_missing_results.json
|
242
|
-
- spec/
|
244
|
+
- spec/assets/empty.txt
|
245
|
+
- spec/assets/pylint.txt
|
246
|
+
- spec/assets/rubocop.json
|
247
|
+
- spec/assets/rubocop.txt
|
248
|
+
- spec/assets/rubocop_multi_offenses.json
|
249
|
+
- spec/helper/message_util_spec.rb
|
250
|
+
- spec/helper/severity_util_spec.rb
|
243
251
|
- spec/parser/bandit_parser_spec.rb
|
244
252
|
- spec/parser/parser_factory_spec.rb
|
245
|
-
- spec/
|
246
|
-
- spec/
|
253
|
+
- spec/parser/pylint_parser_spec.rb
|
254
|
+
- spec/parser/rubocop_parser_spec.rb
|
255
|
+
- spec/report/reporter_spec.rb
|
247
256
|
- spec/spec_helper.rb
|
257
|
+
- spec/spec_helper/assets.rb
|
248
258
|
- spec/warnings_spec.rb
|
249
259
|
homepage: https://github.com/Kyaak/danger-warnings
|
250
260
|
licenses:
|
@@ -270,14 +280,21 @@ signing_key:
|
|
270
280
|
specification_version: 4
|
271
281
|
summary: Report lint warnings of different tools.
|
272
282
|
test_files:
|
273
|
-
- spec/assets/assets.rb
|
274
283
|
- spec/assets/bandit.json
|
275
284
|
- spec/assets/bandit_empty.json
|
276
285
|
- spec/assets/bandit_missing_results.json
|
277
|
-
- spec/
|
286
|
+
- spec/assets/empty.txt
|
287
|
+
- spec/assets/pylint.txt
|
288
|
+
- spec/assets/rubocop.json
|
289
|
+
- spec/assets/rubocop.txt
|
290
|
+
- spec/assets/rubocop_multi_offenses.json
|
291
|
+
- spec/helper/message_util_spec.rb
|
292
|
+
- spec/helper/severity_util_spec.rb
|
278
293
|
- spec/parser/bandit_parser_spec.rb
|
279
294
|
- spec/parser/parser_factory_spec.rb
|
280
|
-
- spec/
|
281
|
-
- spec/
|
295
|
+
- spec/parser/pylint_parser_spec.rb
|
296
|
+
- spec/parser/rubocop_parser_spec.rb
|
297
|
+
- spec/report/reporter_spec.rb
|
282
298
|
- spec/spec_helper.rb
|
299
|
+
- spec/spec_helper/assets.rb
|
283
300
|
- spec/warnings_spec.rb
|
data/lib/warnings/severity.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
module Warnings
|
2
|
-
# Defines severity levels and provides helper methods.
|
3
|
-
class Severity
|
4
|
-
SEVERITIES = %i(low medium high).freeze
|
5
|
-
|
6
|
-
def self.valid?(value)
|
7
|
-
key = value
|
8
|
-
key = value.to_sym if value.method_exists?(:to_sym)
|
9
|
-
SEVERITIES.include?(key)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
data/spec/assets/assets.rb
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
module Warnings
|
2
|
-
module Assets
|
3
|
-
ASSETS_DIR = Pathname.new(File.expand_path('.', __dir__))
|
4
|
-
BANDIT_JSON = "#{ASSETS_DIR}/bandit.json".freeze
|
5
|
-
BANDIT_EMPTY = "#{ASSETS_DIR}/bandit_empty.json".freeze
|
6
|
-
BANDIT_MISSING_RESULTS = "#{ASSETS_DIR}/bandit_missing_results.json".freeze
|
7
|
-
end
|
8
|
-
end
|
data/spec/markdown_util_spec.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
require_relative 'spec_helper'
|
2
|
-
require_relative '../lib/warnings/markdown_util'
|
3
|
-
|
4
|
-
module Warnings
|
5
|
-
describe Warnings::MarkdownUtil do
|
6
|
-
MARKDOWN_TEST_REPORT_NAME = 'My Report Name'.freeze
|
7
|
-
|
8
|
-
context '#generate' do
|
9
|
-
context 'header' do
|
10
|
-
it 'adds header name at first line' do
|
11
|
-
result = MarkdownUtil.generate(MARKDOWN_TEST_REPORT_NAME, [])
|
12
|
-
header_name = result.split(MarkdownUtil::LINE_SEPARATOR).first
|
13
|
-
expect(header_name).to eq("# #{MARKDOWN_TEST_REPORT_NAME}")
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'adds table header at second line' do
|
17
|
-
result = MarkdownUtil.generate(MARKDOWN_TEST_REPORT_NAME, [])
|
18
|
-
table_header = result.split(MarkdownUtil::LINE_SEPARATOR)[1]
|
19
|
-
expect(table_header).to eq(MarkdownUtil::TABLE_HEADER)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'adds table separator at third line' do
|
23
|
-
result = MarkdownUtil.generate(MARKDOWN_TEST_REPORT_NAME, [])
|
24
|
-
table_header = result.split(MarkdownUtil::LINE_SEPARATOR)[2]
|
25
|
-
expect(table_header).to eq(MarkdownUtil::TABLE_SEPARATOR)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'with issues' do
|
30
|
-
before do
|
31
|
-
@issue = Issue.new
|
32
|
-
@issue.severity = :low
|
33
|
-
@issue.name = 'blacklist'
|
34
|
-
@issue.file_name = 'hello/test.py'
|
35
|
-
@issue.message = 'Consider possible security implications associated with pickle module.'
|
36
|
-
@issue.line = 1234
|
37
|
-
@issue.id = 'B403'
|
38
|
-
|
39
|
-
result = MarkdownUtil.generate(MARKDOWN_TEST_REPORT_NAME, [@issue])
|
40
|
-
@issue_line = result.split(MarkdownUtil::LINE_SEPARATOR)[3]
|
41
|
-
@issue_columns = @issue_line.split(MarkdownUtil::COLUMN_SEPARATOR)
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'first column contains severity upcase' do
|
45
|
-
text = @issue_columns[0]
|
46
|
-
expect(text).not_to be_nil
|
47
|
-
expect(text).to eq(@issue.severity.to_s.capitalize)
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'second column contains filename:line' do
|
51
|
-
text = @issue_columns[1]
|
52
|
-
expect(text).not_to be_nil
|
53
|
-
expect(text).to eq("#{@issue.file_name}:#{@issue.line}")
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'third column contains [id-name]' do
|
57
|
-
text = @issue_columns[2]
|
58
|
-
expect(text).not_to be_nil
|
59
|
-
match = text.match(/^\[#{@issue.id}-#{@issue.name}\]/)
|
60
|
-
expect(match).not_to be_nil
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
data/spec/severity_spec.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require_relative 'spec_helper'
|
2
|
-
require_relative '../lib/warnings/severity'
|
3
|
-
|
4
|
-
module Warnings
|
5
|
-
describe Severity do
|
6
|
-
context 'valid severity' do
|
7
|
-
it 'low' do
|
8
|
-
expect(Severity.valid?(:low)).to be_truthy
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'medium' do
|
12
|
-
expect(Severity.valid?(:medium)).to be_truthy
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'high' do
|
16
|
-
expect(Severity.valid?(:high)).to be_truthy
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context 'invalid severity' do
|
21
|
-
it 'is not valid' do
|
22
|
-
expect(Severity.valid?(:unknown)).not_to be_truthy
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|