danger-warnings 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.rubocop.yml +45 -0
- data/.travis.yml +27 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +4 -0
- data/Guardfile +19 -0
- data/LICENSE.txt +22 -0
- data/README.md +213 -0
- data/Rakefile +26 -0
- data/danger-warnings.gemspec +54 -0
- data/lib/danger_plugin.rb +1 -0
- data/lib/danger_warnings.rb +1 -0
- data/lib/warnings/gem_version.rb +3 -0
- data/lib/warnings/issue.rb +31 -0
- data/lib/warnings/markdown_util.rb +61 -0
- data/lib/warnings/parser/bandit_parser.rb +45 -0
- data/lib/warnings/parser/parser.rb +65 -0
- data/lib/warnings/parser/parser_factory.rb +25 -0
- data/lib/warnings/plugin.rb +82 -0
- data/lib/warnings/reporter.rb +158 -0
- data/lib/warnings/severity.rb +12 -0
- data/sonar-project.properties +9 -0
- data/spec/assets/assets.rb +8 -0
- data/spec/assets/bandit.json +74 -0
- data/spec/assets/bandit_empty.json +20 -0
- data/spec/assets/bandit_missing_results.json +2 -0
- data/spec/markdown_util_spec.rb +65 -0
- data/spec/parser/bandit_parser_spec.rb +102 -0
- data/spec/parser/parser_factory_spec.rb +34 -0
- data/spec/reporter_spec.rb +255 -0
- data/spec/severity_spec.rb +26 -0
- data/spec/spec_helper.rb +76 -0
- data/spec/warnings_spec.rb +28 -0
- metadata +283 -0
@@ -0,0 +1,26 @@
|
|
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
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
ROOT = Pathname.new(File.expand_path('..', __dir__))
|
3
|
+
$LOAD_PATH.unshift((ROOT + 'lib').to_s)
|
4
|
+
$LOAD_PATH.unshift((ROOT + 'spec').to_s)
|
5
|
+
|
6
|
+
require 'bundler/setup'
|
7
|
+
require 'pry'
|
8
|
+
|
9
|
+
require 'rspec'
|
10
|
+
require 'danger'
|
11
|
+
require 'mocha'
|
12
|
+
require 'simplecov'
|
13
|
+
|
14
|
+
require_relative 'assets/assets'
|
15
|
+
|
16
|
+
SimpleCov.start
|
17
|
+
|
18
|
+
if `git remote -v` == ''
|
19
|
+
puts 'You cannot run tests without setting a local git remote on this repo'
|
20
|
+
puts "It's a weird side-effect of Danger's internals."
|
21
|
+
exit(0)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Use coloured output, it's the best.
|
25
|
+
RSpec.configure do |config|
|
26
|
+
config.filter_gems_from_backtrace 'bundler'
|
27
|
+
config.color = true
|
28
|
+
config.tty = true
|
29
|
+
config.mock_with :mocha
|
30
|
+
end
|
31
|
+
|
32
|
+
require 'danger_plugin'
|
33
|
+
|
34
|
+
# These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
|
35
|
+
# If you are expanding these files, see if it's already been done ^.
|
36
|
+
|
37
|
+
# A silent version of the user interface,
|
38
|
+
# it comes with an extra function `.string` which will
|
39
|
+
# strip all ANSI colours from the string.
|
40
|
+
|
41
|
+
# rubocop:disable Lint/NestedMethodDefinition
|
42
|
+
def testing_ui
|
43
|
+
@output = StringIO.new
|
44
|
+
|
45
|
+
def @output.winsize
|
46
|
+
[20, 9999]
|
47
|
+
end
|
48
|
+
|
49
|
+
cork = Cork::Board.new(out: @output)
|
50
|
+
|
51
|
+
def cork.string
|
52
|
+
out.string.gsub(/\e\[([;\d]+)?m/, '')
|
53
|
+
end
|
54
|
+
|
55
|
+
cork
|
56
|
+
end
|
57
|
+
|
58
|
+
# rubocop:enable Lint/NestedMethodDefinition
|
59
|
+
|
60
|
+
# Example environment (ENV) that would come from
|
61
|
+
# running a PR on TravisCI
|
62
|
+
def testing_env
|
63
|
+
{
|
64
|
+
'HAS_JOSH_K_SEAL_OF_APPROVAL' => 'true',
|
65
|
+
'TRAVIS_PULL_REQUEST' => '800',
|
66
|
+
'TRAVIS_REPO_SLUG' => 'artsy/eigen',
|
67
|
+
'TRAVIS_COMMIT_RANGE' => '759adcbd0d8f...13c4dc8bb61d',
|
68
|
+
'DANGER_GITHUB_API_TOKEN' => '123sbdq54erfsd3422gdfio'
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
# A stubbed out Dangerfile for use in tests
|
73
|
+
def testing_dangerfile
|
74
|
+
env = Danger::EnvironmentManager.new(testing_env)
|
75
|
+
Danger::Dangerfile.new(env, testing_ui)
|
76
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path('spec_helper', __dir__)
|
2
|
+
|
3
|
+
module Danger
|
4
|
+
describe Danger::DangerWarnings do
|
5
|
+
ASSETS_DIR = File.expand_path('assets', __dir__)
|
6
|
+
BANDIT_EMPTY = "#{ASSETS_DIR}/bandit_empty.json".freeze
|
7
|
+
BANDIT_FILE = "#{ASSETS_DIR}/bandit.json".freeze
|
8
|
+
|
9
|
+
it 'should be a plugin' do
|
10
|
+
expect(Danger::DangerWarnings.new(nil)).to be_a Danger::Plugin
|
11
|
+
end
|
12
|
+
|
13
|
+
#
|
14
|
+
# You should test your custom attributes and methods here
|
15
|
+
#
|
16
|
+
describe 'with Dangerfile' do
|
17
|
+
before do
|
18
|
+
@dangerfile = testing_dangerfile
|
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
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,283 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: danger-warnings
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kyaak
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: abstract_method
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: danger-plugin-api
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mocha
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.4'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.4'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.16'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.16'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov-console
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.4'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.4'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.60'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.60'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: yard
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.9'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.9'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: guard
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '2.14'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '2.14'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: guard-rspec
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '4.7'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '4.7'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: listen
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - '='
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 3.0.7
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - '='
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 3.0.7
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: pry
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
description: Report lint warnings
|
210
|
+
email:
|
211
|
+
- kyaak.dev@gmail.com
|
212
|
+
executables: []
|
213
|
+
extensions: []
|
214
|
+
extra_rdoc_files: []
|
215
|
+
files:
|
216
|
+
- ".gitignore"
|
217
|
+
- ".rubocop.yml"
|
218
|
+
- ".travis.yml"
|
219
|
+
- CHANGELOG.md
|
220
|
+
- Gemfile
|
221
|
+
- Guardfile
|
222
|
+
- LICENSE.txt
|
223
|
+
- README.md
|
224
|
+
- Rakefile
|
225
|
+
- danger-warnings.gemspec
|
226
|
+
- lib/danger_plugin.rb
|
227
|
+
- lib/danger_warnings.rb
|
228
|
+
- lib/warnings/gem_version.rb
|
229
|
+
- lib/warnings/issue.rb
|
230
|
+
- lib/warnings/markdown_util.rb
|
231
|
+
- lib/warnings/parser/bandit_parser.rb
|
232
|
+
- lib/warnings/parser/parser.rb
|
233
|
+
- lib/warnings/parser/parser_factory.rb
|
234
|
+
- lib/warnings/plugin.rb
|
235
|
+
- lib/warnings/reporter.rb
|
236
|
+
- lib/warnings/severity.rb
|
237
|
+
- sonar-project.properties
|
238
|
+
- spec/assets/assets.rb
|
239
|
+
- spec/assets/bandit.json
|
240
|
+
- spec/assets/bandit_empty.json
|
241
|
+
- spec/assets/bandit_missing_results.json
|
242
|
+
- spec/markdown_util_spec.rb
|
243
|
+
- spec/parser/bandit_parser_spec.rb
|
244
|
+
- spec/parser/parser_factory_spec.rb
|
245
|
+
- spec/reporter_spec.rb
|
246
|
+
- spec/severity_spec.rb
|
247
|
+
- spec/spec_helper.rb
|
248
|
+
- spec/warnings_spec.rb
|
249
|
+
homepage: https://github.com/Kyaak/danger-warnings
|
250
|
+
licenses:
|
251
|
+
- MIT
|
252
|
+
metadata: {}
|
253
|
+
post_install_message:
|
254
|
+
rdoc_options: []
|
255
|
+
require_paths:
|
256
|
+
- lib
|
257
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
258
|
+
requirements:
|
259
|
+
- - ">="
|
260
|
+
- !ruby/object:Gem::Version
|
261
|
+
version: 2.2.0
|
262
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
263
|
+
requirements:
|
264
|
+
- - ">="
|
265
|
+
- !ruby/object:Gem::Version
|
266
|
+
version: '0'
|
267
|
+
requirements: []
|
268
|
+
rubygems_version: 3.0.2
|
269
|
+
signing_key:
|
270
|
+
specification_version: 4
|
271
|
+
summary: Report lint warnings of different tools.
|
272
|
+
test_files:
|
273
|
+
- spec/assets/assets.rb
|
274
|
+
- spec/assets/bandit.json
|
275
|
+
- spec/assets/bandit_empty.json
|
276
|
+
- spec/assets/bandit_missing_results.json
|
277
|
+
- spec/markdown_util_spec.rb
|
278
|
+
- spec/parser/bandit_parser_spec.rb
|
279
|
+
- spec/parser/parser_factory_spec.rb
|
280
|
+
- spec/reporter_spec.rb
|
281
|
+
- spec/severity_spec.rb
|
282
|
+
- spec/spec_helper.rb
|
283
|
+
- spec/warnings_spec.rb
|