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.
@@ -0,0 +1,265 @@
1
+ {
2
+ "metadata": {
3
+ "rubocop_version": "0.49.1",
4
+ "ruby_engine": "ruby",
5
+ "ruby_version": "2.5.1",
6
+ "ruby_patchlevel": "57",
7
+ "ruby_platform": "x86_64-darwin18"
8
+ },
9
+ "files": [
10
+ {
11
+ "path": "spec/lib/danger/danger_core/plugins/dangerfile_gitlab_plugin_spec.rb",
12
+ "offenses": [
13
+ {
14
+ "severity": "convention",
15
+ "message": "Do not use semicolons to terminate expressions.",
16
+ "cop_name": "Style/Semicolon",
17
+ "corrected": false,
18
+ "location": {
19
+ "line": 82,
20
+ "column": 65,
21
+ "length": 1
22
+ }
23
+ }
24
+ ]
25
+ },
26
+ {
27
+ "path": "lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb",
28
+ "offenses": [
29
+ {
30
+ "severity": "convention",
31
+ "message": "Use `alias` instead of `alias_method` in a class body.",
32
+ "cop_name": "Style/Alias",
33
+ "corrected": false,
34
+ "location": {
35
+ "line": 181,
36
+ "column": 5,
37
+ "length": 12
38
+ }
39
+ }
40
+ ]
41
+ },
42
+ {
43
+ "path": "lib/danger/danger_core/plugins/dangerfile_local_only_plugin.rb",
44
+ "offenses": [
45
+ {
46
+ "severity": "convention",
47
+ "message": "Trailing whitespace detected.",
48
+ "cop_name": "Layout/TrailingWhitespace",
49
+ "corrected": false,
50
+ "location": {
51
+ "line": 9,
52
+ "column": 66,
53
+ "length": 1
54
+ }
55
+ },
56
+ {
57
+ "severity": "convention",
58
+ "message": "Trailing whitespace detected.",
59
+ "cop_name": "Layout/TrailingWhitespace",
60
+ "corrected": false,
61
+ "location": {
62
+ "line": 14,
63
+ "column": 82,
64
+ "length": 1
65
+ }
66
+ }
67
+ ]
68
+ },
69
+ {
70
+ "path": "lib/danger/request_sources/gitlab.rb",
71
+ "offenses": [
72
+ {
73
+ "severity": "convention",
74
+ "message": "Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.",
75
+ "cop_name": "Style/StringLiterals",
76
+ "corrected": false,
77
+ "location": {
78
+ "line": 171,
79
+ "column": 20,
80
+ "length": 8
81
+ }
82
+ }
83
+ ]
84
+ },
85
+ {
86
+ "path": "lib/danger/ci_source/support/find_repo_info_from_url.rb",
87
+ "offenses": [
88
+ {
89
+ "severity": "convention",
90
+ "message": "Trailing whitespace detected.",
91
+ "cop_name": "Layout/TrailingWhitespace",
92
+ "corrected": false,
93
+ "location": {
94
+ "line": 11,
95
+ "column": 1,
96
+ "length": 4
97
+ }
98
+ }
99
+ ]
100
+ },
101
+ {
102
+ "path": "lib/danger/ci_source/code_build.rb",
103
+ "offenses": [
104
+ {
105
+ "severity": "warning",
106
+ "message": "Assignment in condition - you probably meant to use `==`.",
107
+ "cop_name": "Lint/AssignmentInCondition",
108
+ "corrected": false,
109
+ "location": {
110
+ "line": 19,
111
+ "column": 31,
112
+ "length": 1
113
+ }
114
+ },
115
+ {
116
+ "severity": "convention",
117
+ "message": "Keep a blank line before and after `private`.",
118
+ "cop_name": "Layout/EmptyLinesAroundAccessModifier",
119
+ "corrected": false,
120
+ "location": {
121
+ "line": 33,
122
+ "column": 5,
123
+ "length": 7
124
+ }
125
+ },
126
+ {
127
+ "severity": "warning",
128
+ "message": "Useless `private` access modifier.",
129
+ "cop_name": "Lint/UselessAccessModifier",
130
+ "corrected": false,
131
+ "location": {
132
+ "line": 33,
133
+ "column": 5,
134
+ "length": 7
135
+ }
136
+ },
137
+ {
138
+ "severity": "convention",
139
+ "message": "Inconsistent indentation detected.",
140
+ "cop_name": "Layout/IndentationConsistency",
141
+ "corrected": false,
142
+ "location": {
143
+ "line": 34,
144
+ "column": 7,
145
+ "length": 189
146
+ }
147
+ },
148
+ {
149
+ "severity": "warning",
150
+ "message": "`private` (on line 33) does not make singleton methods private. Use `private_class_method` or `private` inside a `class << self` block instead.",
151
+ "cop_name": "Lint/IneffectiveAccessModifier",
152
+ "corrected": false,
153
+ "location": {
154
+ "line": 34,
155
+ "column": 7,
156
+ "length": 3
157
+ }
158
+ },
159
+ {
160
+ "severity": "convention",
161
+ "message": "Use `%r` around regular expression.",
162
+ "cop_name": "Style/RegexpLiteral",
163
+ "corrected": false,
164
+ "location": {
165
+ "line": 37,
166
+ "column": 47,
167
+ "length": 30
168
+ }
169
+ },
170
+ {
171
+ "severity": "convention",
172
+ "message": "Inconsistent indentation detected.",
173
+ "cop_name": "Layout/IndentationConsistency",
174
+ "corrected": false,
175
+ "location": {
176
+ "line": 40,
177
+ "column": 7,
178
+ "length": 164
179
+ }
180
+ },
181
+ {
182
+ "severity": "warning",
183
+ "message": "`private` (on line 33) does not make singleton methods private. Use `private_class_method` or `private` inside a `class << self` block instead.",
184
+ "cop_name": "Lint/IneffectiveAccessModifier",
185
+ "corrected": false,
186
+ "location": {
187
+ "line": 40,
188
+ "column": 7,
189
+ "length": 3
190
+ }
191
+ },
192
+ {
193
+ "severity": "convention",
194
+ "message": "Inconsistent indentation detected.",
195
+ "cop_name": "Layout/IndentationConsistency",
196
+ "corrected": false,
197
+ "location": {
198
+ "line": 46,
199
+ "column": 7,
200
+ "length": 449
201
+ }
202
+ },
203
+ {
204
+ "severity": "warning",
205
+ "message": "`private` (on line 33) does not make singleton methods private. Use `private_class_method` or `private` inside a `class << self` block instead.",
206
+ "cop_name": "Lint/IneffectiveAccessModifier",
207
+ "corrected": false,
208
+ "location": {
209
+ "line": 46,
210
+ "column": 7,
211
+ "length": 3
212
+ }
213
+ },
214
+ {
215
+ "severity": "warning",
216
+ "message": "Useless assignment to variable - `source_origin`. Use `_` or `_source_origin` as a variable name to indicate that it won't be used.",
217
+ "cop_name": "Lint/UselessAssignment",
218
+ "corrected": false,
219
+ "location": {
220
+ "line": 51,
221
+ "column": 9,
222
+ "length": 13
223
+ }
224
+ }
225
+ ]
226
+ },
227
+ {
228
+ "path": "lib/danger/commands/init_helpers/interviewer.rb",
229
+ "offenses": []
230
+ },
231
+ {
232
+ "path": "lib/danger/commands/runner.rb",
233
+ "offenses": []
234
+ },
235
+ {
236
+ "path": "lib/danger/helpers/find_max_num_violations.rb",
237
+ "offenses": []
238
+ },
239
+ {
240
+ "path": "lib/danger/helpers/comments_helper.rb",
241
+ "offenses": []
242
+ },
243
+ {
244
+ "path": "lib/danger/helpers/emoji_mapper.rb",
245
+ "offenses": []
246
+ },
247
+ {
248
+ "path": "lib/danger/helpers/array_subclass.rb",
249
+ "offenses": []
250
+ },
251
+ {
252
+ "path": "lib/danger/helpers/comments_parsing_helper.rb",
253
+ "offenses": []
254
+ },
255
+ {
256
+ "path": "lib/danger/helpers/comment.rb",
257
+ "offenses": []
258
+ }
259
+ ],
260
+ "summary": {
261
+ "offense_count": 18,
262
+ "target_file_count": 183,
263
+ "inspected_file_count": 183
264
+ }
265
+ }
@@ -0,0 +1,27 @@
1
+ == spec/lib/danger/danger_core/plugins/dangerfile_gitlab_plugin_spec.rb ==
2
+ C: 82: 65: Do not use semicolons to terminate expressions.
3
+ == spec/lib/danger/request_sources/github_spec.rb ==
4
+ C:598: 16: Avoid comma after the last parameter of a method call.
5
+ == lib/danger/danger_core/plugins/dangerfile_messaging_plugin.rb ==
6
+ C:181: 5: Use alias instead of alias_method in a class body.
7
+ == lib/danger/danger_core/plugins/dangerfile_local_only_plugin.rb ==
8
+ C: 9: 66: Trailing whitespace detected.
9
+ C: 14: 82: Trailing whitespace detected.
10
+ == lib/danger/request_sources/gitlab.rb ==
11
+ C:171: 20: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
12
+ == lib/danger/ci_source/support/find_repo_info_from_url.rb ==
13
+ C: 11: 1: Trailing whitespace detected.
14
+ == lib/danger/ci_source/code_build.rb ==
15
+ W: 19: 31: Assignment in condition - you probably meant to use ==.
16
+ C: 33: 5: Keep a blank line before and after private.
17
+ W: 33: 5: Useless private access modifier.
18
+ C: 34: 7: Inconsistent indentation detected.
19
+ W: 34: 7: private (on line 33) does not make singleton methods private. Use private_class_method or private inside a class << self block instead.
20
+ C: 37: 47: Use %r around regular expression.
21
+ C: 40: 7: Inconsistent indentation detected.
22
+ W: 40: 7: private (on line 33) does not make singleton methods private. Use private_class_method or private inside a class << self block instead.
23
+ C: 46: 7: Inconsistent indentation detected.
24
+ W: 46: 7: private (on line 33) does not make singleton methods private. Use private_class_method or private inside a class << self block instead.
25
+ W: 51: 9: Useless assignment to variable - source_origin. Use _ or _source_origin as a variable name to indicate that it won't be used.
26
+
27
+ 183 files inspected, 18 offenses detected
@@ -0,0 +1,142 @@
1
+ {
2
+ "metadata": {
3
+ "rubocop_version": "0.49.1",
4
+ "ruby_engine": "ruby",
5
+ "ruby_version": "2.5.1",
6
+ "ruby_patchlevel": "57",
7
+ "ruby_platform": "x86_64-darwin18"
8
+ },
9
+ "files": [
10
+ {
11
+ "path": "lib/danger/ci_source/code_build.rb",
12
+ "offenses": [
13
+ {
14
+ "severity": "warning",
15
+ "message": "Assignment in condition - you probably meant to use `==`.",
16
+ "cop_name": "Lint/AssignmentInCondition",
17
+ "corrected": false,
18
+ "location": {
19
+ "line": 19,
20
+ "column": 31,
21
+ "length": 1
22
+ }
23
+ },
24
+ {
25
+ "severity": "convention",
26
+ "message": "Keep a blank line before and after `private`.",
27
+ "cop_name": "Layout/EmptyLinesAroundAccessModifier",
28
+ "corrected": false,
29
+ "location": {
30
+ "line": 33,
31
+ "column": 5,
32
+ "length": 7
33
+ }
34
+ },
35
+ {
36
+ "severity": "warning",
37
+ "message": "Useless `private` access modifier.",
38
+ "cop_name": "Lint/UselessAccessModifier",
39
+ "corrected": false,
40
+ "location": {
41
+ "line": 33,
42
+ "column": 5,
43
+ "length": 7
44
+ }
45
+ },
46
+ {
47
+ "severity": "convention",
48
+ "message": "Inconsistent indentation detected.",
49
+ "cop_name": "Layout/IndentationConsistency",
50
+ "corrected": false,
51
+ "location": {
52
+ "line": 34,
53
+ "column": 7,
54
+ "length": 189
55
+ }
56
+ },
57
+ {
58
+ "severity": "warning",
59
+ "message": "`private` (on line 33) does not make singleton methods private. Use `private_class_method` or `private` inside a `class << self` block instead.",
60
+ "cop_name": "Lint/IneffectiveAccessModifier",
61
+ "corrected": false,
62
+ "location": {
63
+ "line": 34,
64
+ "column": 7,
65
+ "length": 3
66
+ }
67
+ },
68
+ {
69
+ "severity": "convention",
70
+ "message": "Use `%r` around regular expression.",
71
+ "cop_name": "Style/RegexpLiteral",
72
+ "corrected": false,
73
+ "location": {
74
+ "line": 37,
75
+ "column": 47,
76
+ "length": 30
77
+ }
78
+ },
79
+ {
80
+ "severity": "convention",
81
+ "message": "Inconsistent indentation detected.",
82
+ "cop_name": "Layout/IndentationConsistency",
83
+ "corrected": false,
84
+ "location": {
85
+ "line": 40,
86
+ "column": 7,
87
+ "length": 164
88
+ }
89
+ },
90
+ {
91
+ "severity": "warning",
92
+ "message": "`private` (on line 33) does not make singleton methods private. Use `private_class_method` or `private` inside a `class << self` block instead.",
93
+ "cop_name": "Lint/IneffectiveAccessModifier",
94
+ "corrected": false,
95
+ "location": {
96
+ "line": 40,
97
+ "column": 7,
98
+ "length": 3
99
+ }
100
+ },
101
+ {
102
+ "severity": "convention",
103
+ "message": "Inconsistent indentation detected.",
104
+ "cop_name": "Layout/IndentationConsistency",
105
+ "corrected": false,
106
+ "location": {
107
+ "line": 46,
108
+ "column": 7,
109
+ "length": 449
110
+ }
111
+ },
112
+ {
113
+ "severity": "warning",
114
+ "message": "`private` (on line 33) does not make singleton methods private. Use `private_class_method` or `private` inside a `class << self` block instead.",
115
+ "cop_name": "Lint/IneffectiveAccessModifier",
116
+ "corrected": false,
117
+ "location": {
118
+ "line": 46,
119
+ "column": 7,
120
+ "length": 3
121
+ }
122
+ },
123
+ {
124
+ "severity": "warning",
125
+ "message": "Useless assignment to variable - `source_origin`. Use `_` or `_source_origin` as a variable name to indicate that it won't be used.",
126
+ "cop_name": "Lint/UselessAssignment",
127
+ "corrected": false,
128
+ "location": {
129
+ "line": 51,
130
+ "column": 9,
131
+ "length": 13
132
+ }
133
+ }
134
+ ]
135
+ }
136
+ ],
137
+ "summary": {
138
+ "offense_count": 11,
139
+ "target_file_count": 1,
140
+ "inspected_file_count": 1
141
+ }
142
+ }
@@ -0,0 +1,108 @@
1
+ require_relative '../spec_helper'
2
+ require_relative '../../lib/warnings/helper/message_util'
3
+
4
+ module Warnings
5
+ describe Warnings::MessageUtil do
6
+ MARKDOWN_TEST_REPORT_NAME = 'My Report Name'.freeze
7
+ COLUMN_ONE = 1
8
+ COLUMN_TWO = 2
9
+ COLUMN_THREE = 3
10
+
11
+ context '#markdown' do
12
+ context 'header' do
13
+ it 'adds header name at first line' do
14
+ result = MessageUtil.markdown(MARKDOWN_TEST_REPORT_NAME, [])
15
+ header_name = result.split(MessageUtil::LINE_SEPARATOR).first
16
+ expect(header_name).to eq("# #{MARKDOWN_TEST_REPORT_NAME}")
17
+ end
18
+
19
+ it 'adds table header at second line' do
20
+ result = MessageUtil.markdown(MARKDOWN_TEST_REPORT_NAME, [])
21
+ table_header = result.split(MessageUtil::LINE_SEPARATOR)[1]
22
+ expect(table_header).to eq(MessageUtil::TABLE_HEADER)
23
+ end
24
+
25
+ it 'adds table separator at third line' do
26
+ result = MessageUtil.markdown(MARKDOWN_TEST_REPORT_NAME, [])
27
+ table_header = result.split(MessageUtil::LINE_SEPARATOR)[2]
28
+ expect(table_header).to eq(MessageUtil::TABLE_SEPARATOR)
29
+ end
30
+ end
31
+
32
+ context 'with issues' do
33
+ before do
34
+ @issue = Issue.new
35
+ @issue.severity = :low
36
+ @issue.file_name = 'hello/test.py'
37
+ @issue.message = 'Consider possible security implications associated with pickle module.'
38
+ @issue.line = 1234
39
+ @issue.category = 'B403-blacklist'
40
+
41
+ result = MessageUtil.markdown(MARKDOWN_TEST_REPORT_NAME, [@issue])
42
+ issue_line = result.split(MessageUtil::LINE_SEPARATOR)[3]
43
+ @issue_columns = issue_line.split(MessageUtil::COLUMN_SEPARATOR)
44
+ end
45
+
46
+ it 'first column contains severity upcase' do
47
+ text = @issue_columns[COLUMN_ONE]
48
+ expect(text).not_to be_nil
49
+ expect(text).to eq(@issue.severity.to_s.capitalize)
50
+ end
51
+
52
+ it 'second column contains filename:line' do
53
+ text = @issue_columns[COLUMN_TWO]
54
+ expect(text).not_to be_nil
55
+ expect(text).to eq("#{@issue.file_name}:#{@issue.line}")
56
+ end
57
+
58
+ it 'third column contains [category-name]' do
59
+ text = @issue_columns[COLUMN_THREE]
60
+ expect(text).not_to be_nil
61
+ match = text.match(/^\[#{@issue.category}\]/)
62
+ expect(match).not_to be_nil
63
+ end
64
+
65
+ it 'third column contains message' do
66
+ text = @issue_columns[COLUMN_THREE]
67
+ expect(text).not_to be_nil
68
+ match = text.match(/#{@issue.message}/)
69
+ expect(match).not_to be_nil
70
+ end
71
+ end
72
+ end
73
+
74
+ context '#inline' do
75
+ before do
76
+ @issue = Issue.new
77
+ @issue.severity = :low
78
+ @issue.file_name = 'hello/test.py'
79
+ @issue.message = 'Consider possible security implications associated with pickle module.'
80
+ @issue.line = 1234
81
+ @issue.category = 'B403-blacklist'
82
+
83
+ result = MessageUtil.inline(@issue)
84
+ @issue_lines = result.split(MessageUtil::LINE_SEPARATOR)
85
+ end
86
+
87
+ it 'first line contains severity upcase' do
88
+ text = @issue_lines[0]
89
+ expect(text).not_to be_nil
90
+ expect(text).to eq(@issue.severity.to_s.capitalize)
91
+ end
92
+
93
+ it 'second line contains [category-name]' do
94
+ text = @issue_lines[1]
95
+ expect(text).not_to be_nil
96
+ match = text.match(/^\[#{@issue.category}\]/)
97
+ expect(match).not_to be_nil
98
+ end
99
+
100
+ it 'third line contains message' do
101
+ text = @issue_lines[2]
102
+ expect(text).not_to be_nil
103
+ match = text.match(/#{@issue.message}/)
104
+ expect(match).not_to be_nil
105
+ end
106
+ end
107
+ end
108
+ end