danger-wcc 0.0.3 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +22 -15
  3. data/danger-wcc.gemspec +3 -3
  4. data/lib/version.rb +1 -1
  5. data/lib/wcc/commit_lint.rb +2 -1
  6. data/lib/wcc/commit_lint/commit_check.rb +0 -1
  7. data/lib/wcc/commit_lint/empty_line_check.rb +0 -1
  8. data/lib/wcc/commit_lint/subject_cap_check.rb +0 -1
  9. data/lib/wcc/commit_lint/subject_length_check.rb +0 -1
  10. data/lib/wcc/commit_lint/subject_period_check.rb +0 -1
  11. data/lib/wcc/commit_lint/subject_words_check.rb +0 -1
  12. data/lib/wcc/defaults.reek +8 -8
  13. data/lib/wcc/dependencies.rb +100 -0
  14. data/lib/wcc/jshint.rb +2 -2
  15. data/lib/wcc/plugin.rb +30 -12
  16. data/lib/wcc/reek.rb +2 -2
  17. data/lib/wcc/rubocop_exceptions.rb +13 -8
  18. data/lib/wcc/todos.rb +5 -4
  19. data/lib/wcc/util/yarn_info.rb +84 -0
  20. data/lib/wcc/utils.rb +17 -5
  21. data/lib/wcc/yarn_deduplicate.rb +72 -0
  22. data/spec/fixtures/dependencies/package.json +112 -0
  23. data/spec/fixtures/dependencies/package.json.diff +28 -0
  24. data/spec/fixtures/dependencies/package.json_patch_bumps_minor.diff +13 -0
  25. data/spec/fixtures/dependencies/package.json_patch_bumps_minor.json +112 -0
  26. data/spec/fixtures/dependencies/package.json_second_level_effect.diff +17 -0
  27. data/spec/fixtures/dependencies/package.json_second_level_effect.json +133 -0
  28. data/spec/fixtures/dependencies/yarn.lock +19609 -0
  29. data/spec/fixtures/dependencies/yarn.lock_patch_bumps_minor.lock +19614 -0
  30. data/spec/fixtures/dependencies/yarn.lock_second_level_effect.lock +20022 -0
  31. data/spec/fixtures/dependencies/yarn_list_second_level_effect.txt +1243 -0
  32. data/spec/fixtures/dependencies/yarn_list_second_level_effect.txt.diff +141 -0
  33. data/spec/fixtures/dependencies/yarn_minor_version.diff +33 -0
  34. data/spec/fixtures/dependencies/yarn_minor_version.txt +1151 -0
  35. data/spec/fixtures/dependencies/yarn_old.txt +1152 -0
  36. data/spec/fixtures/dependencies/yarn_patch_bumps_minor.diff +28 -0
  37. data/spec/fixtures/exception_inline_disabled_rule.diff +12 -0
  38. data/spec/fixtures/rubocop_exception.rb +3 -0
  39. data/spec/fixtures/yarn_deduplicate/list.a.txt +293 -0
  40. data/spec/fixtures/yarn_deduplicate/list.b.txt +295 -0
  41. data/spec/fixtures/yarn_deduplicate/list.diff +11 -0
  42. data/spec/fixtures/yarn_deduplicate/yarn.lock +20031 -0
  43. data/spec/fixtures_helper.rb +0 -1
  44. data/spec/spec_helper.rb +1 -1
  45. data/spec/wcc/commit_lint_spec.rb +6 -10
  46. data/spec/wcc/dependencies_spec.rb +129 -0
  47. data/spec/wcc/github_spec.rb +13 -7
  48. data/spec/wcc/jshint_spec.rb +1 -1
  49. data/spec/wcc/plugin_spec.rb +22 -17
  50. data/spec/wcc/reek_spec.rb +1 -1
  51. data/spec/wcc/rubocop_exceptions_spec.rb +34 -15
  52. data/spec/wcc/todos_spec.rb +10 -10
  53. data/spec/wcc/utils_spec.rb +2 -2
  54. data/spec/wcc/yarn_deduplicate_spec.rb +57 -0
  55. data/spec/wcc_spec.rb +1 -1
  56. metadata +71 -10
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require File.expand_path('../../spec_helper', __FILE__)
3
+ require File.expand_path('../spec_helper', __dir__)
4
4
 
5
5
  module Danger
6
6
  describe Danger::DangerWCC do
@@ -50,7 +50,7 @@ module Danger
50
50
  [
51
51
  load_diff('spec/fixtures/todo.rb', 'no_todo'),
52
52
  load_diff('spec/fixtures/find_in_diff.rb',
53
- 'find_in_diff_2_chunks')
53
+ 'find_in_diff_2_chunks')
54
54
  ]
55
55
  )
56
56
 
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('../spec_helper', __dir__)
4
+
5
+ module Danger
6
+ describe Danger::DangerWCC do
7
+ before do
8
+ @dangerfile = testing_dangerfile
9
+ @my_plugin = @dangerfile.wcc
10
+ @git = @dangerfile.git
11
+ @github = @dangerfile.github
12
+
13
+ allow(@github).to receive(:pr_json)
14
+ .and_return(JSON.parse(load_fixture('github_pr.json')))
15
+ allow(subject).to receive(:run)
16
+ .with(/npm/)
17
+ .and_return('')
18
+ allow(subject).to receive(:run_and_diff)
19
+ .and_return(load_fixture('yarn_deduplicate/list.diff'))
20
+
21
+ allow(File).to receive(:exist?).and_call_original
22
+ allow(File).to receive(:read).and_call_original
23
+ allow(File).to receive(:exist?).with('yarn.lock')
24
+ .and_return(true)
25
+ allow(File).to receive(:readlines).with('yarn.lock')
26
+ .and_return(load_fixture('yarn_deduplicate/yarn.lock').split("\n"))
27
+ end
28
+
29
+ describe 'yarn_deduplicate' do
30
+ let(:subject) { Danger::DangerWCC::YarnDeduplicate.new(@my_plugin) }
31
+
32
+ it 'runs yarn-deduplicate and parses diff' do
33
+ # act
34
+ subject.perform
35
+
36
+ # assert
37
+ warnings = @dangerfile.violation_report[:warnings]
38
+ expect(warnings.length).to eq(2)
39
+
40
+ expect(warnings[0].message)
41
+ .to include('You have an opportunity to deduplicate "@babel/core".')
42
+ expect(warnings[0].message)
43
+ .to include('It wants >=7.1.0 and could unify with 7.12.10,'\
44
+ ' but instead 7.4.0')
45
+ expect(warnings[0].message)
46
+ .to include('npx yarn-deduplicate -s fewer --packages "@babel/core"')
47
+ expect(warnings[0].file).to eq('yarn.lock')
48
+ expect(warnings[0].line).to eq(24)
49
+
50
+ expect(warnings[1].message)
51
+ .to include('npx yarn-deduplicate -s fewer --packages "@babel/core"')
52
+ expect(warnings[1].file).to eq('yarn.lock')
53
+ expect(warnings[1].line).to eq(24)
54
+ end
55
+ end
56
+ end
57
+ end
data/spec/wcc_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require File.expand_path('../spec_helper', __FILE__)
3
+ require File.expand_path('spec_helper', __dir__)
4
4
 
5
5
  module Danger
6
6
  describe Danger::DangerWCC do
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-wcc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Watermark Dev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-25 00:00:00.000000000 Z
11
+ date: 2021-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: '5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: '5'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: brakeman
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -154,16 +168,16 @@ dependencies:
154
168
  name: rubocop
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
- - - ">="
171
+ - - "~>"
158
172
  - !ruby/object:Gem::Version
159
- version: '0'
173
+ version: '0.81'
160
174
  type: :development
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
- - - ">="
178
+ - - "~>"
165
179
  - !ruby/object:Gem::Version
166
- version: '0'
180
+ version: '0.81'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: yard
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -279,18 +293,37 @@ files:
279
293
  - lib/wcc/commit_lint/subject_words_check.rb
280
294
  - lib/wcc/default.jshintrc
281
295
  - lib/wcc/defaults.reek
296
+ - lib/wcc/dependencies.rb
282
297
  - lib/wcc/github.rb
283
298
  - lib/wcc/jshint.rb
284
299
  - lib/wcc/plugin.rb
285
300
  - lib/wcc/reek.rb
286
301
  - lib/wcc/rubocop_exceptions.rb
287
302
  - lib/wcc/todos.rb
303
+ - lib/wcc/util/yarn_info.rb
288
304
  - lib/wcc/utils.rb
305
+ - lib/wcc/yarn_deduplicate.rb
289
306
  - spec/fixtures/brakeman/a.tmp
290
307
  - spec/fixtures/brakeman/b.tmp
291
308
  - spec/fixtures/brakeman/brakeman.diff
292
309
  - spec/fixtures/brakeman/brakeman.out
310
+ - spec/fixtures/dependencies/package.json
311
+ - spec/fixtures/dependencies/package.json.diff
312
+ - spec/fixtures/dependencies/package.json_patch_bumps_minor.diff
313
+ - spec/fixtures/dependencies/package.json_patch_bumps_minor.json
314
+ - spec/fixtures/dependencies/package.json_second_level_effect.diff
315
+ - spec/fixtures/dependencies/package.json_second_level_effect.json
316
+ - spec/fixtures/dependencies/yarn.lock
317
+ - spec/fixtures/dependencies/yarn.lock_patch_bumps_minor.lock
318
+ - spec/fixtures/dependencies/yarn.lock_second_level_effect.lock
319
+ - spec/fixtures/dependencies/yarn_list_second_level_effect.txt
320
+ - spec/fixtures/dependencies/yarn_list_second_level_effect.txt.diff
321
+ - spec/fixtures/dependencies/yarn_minor_version.diff
322
+ - spec/fixtures/dependencies/yarn_minor_version.txt
323
+ - spec/fixtures/dependencies/yarn_old.txt
324
+ - spec/fixtures/dependencies/yarn_patch_bumps_minor.diff
293
325
  - spec/fixtures/exception_context.diff
326
+ - spec/fixtures/exception_inline_disabled_rule.diff
294
327
  - spec/fixtures/exception_insert_context.diff
295
328
  - spec/fixtures/exception_misspelled.diff
296
329
  - spec/fixtures/exception_multiline_context.diff
@@ -315,9 +348,14 @@ files:
315
348
  - spec/fixtures/todo_link_same_line.diff
316
349
  - spec/fixtures/todo_no_link.diff
317
350
  - spec/fixtures/todo_removed.diff
351
+ - spec/fixtures/yarn_deduplicate/list.a.txt
352
+ - spec/fixtures/yarn_deduplicate/list.b.txt
353
+ - spec/fixtures/yarn_deduplicate/list.diff
354
+ - spec/fixtures/yarn_deduplicate/yarn.lock
318
355
  - spec/fixtures_helper.rb
319
356
  - spec/spec_helper.rb
320
357
  - spec/wcc/commit_lint_spec.rb
358
+ - spec/wcc/dependencies_spec.rb
321
359
  - spec/wcc/github_spec.rb
322
360
  - spec/wcc/jshint_spec.rb
323
361
  - spec/wcc/plugin_spec.rb
@@ -325,12 +363,13 @@ files:
325
363
  - spec/wcc/rubocop_exceptions_spec.rb
326
364
  - spec/wcc/todos_spec.rb
327
365
  - spec/wcc/utils_spec.rb
366
+ - spec/wcc/yarn_deduplicate_spec.rb
328
367
  - spec/wcc_spec.rb
329
368
  homepage: https://github.com/watermarkchurch/danger-wcc
330
369
  licenses:
331
370
  - Apache-2.0
332
371
  metadata: {}
333
- post_install_message:
372
+ post_install_message:
334
373
  rdoc_options: []
335
374
  require_paths:
336
375
  - lib
@@ -345,9 +384,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
345
384
  - !ruby/object:Gem::Version
346
385
  version: '0'
347
386
  requirements: []
348
- rubyforge_project:
387
+ rubyforge_project:
349
388
  rubygems_version: 2.5.2
350
- signing_key:
389
+ signing_key:
351
390
  specification_version: 4
352
391
  summary: A Danger plugin for Watermark Church custom rules.
353
392
  test_files:
@@ -355,7 +394,23 @@ test_files:
355
394
  - spec/fixtures/brakeman/b.tmp
356
395
  - spec/fixtures/brakeman/brakeman.diff
357
396
  - spec/fixtures/brakeman/brakeman.out
397
+ - spec/fixtures/dependencies/package.json
398
+ - spec/fixtures/dependencies/package.json.diff
399
+ - spec/fixtures/dependencies/package.json_patch_bumps_minor.diff
400
+ - spec/fixtures/dependencies/package.json_patch_bumps_minor.json
401
+ - spec/fixtures/dependencies/package.json_second_level_effect.diff
402
+ - spec/fixtures/dependencies/package.json_second_level_effect.json
403
+ - spec/fixtures/dependencies/yarn.lock
404
+ - spec/fixtures/dependencies/yarn.lock_patch_bumps_minor.lock
405
+ - spec/fixtures/dependencies/yarn.lock_second_level_effect.lock
406
+ - spec/fixtures/dependencies/yarn_list_second_level_effect.txt
407
+ - spec/fixtures/dependencies/yarn_list_second_level_effect.txt.diff
408
+ - spec/fixtures/dependencies/yarn_minor_version.diff
409
+ - spec/fixtures/dependencies/yarn_minor_version.txt
410
+ - spec/fixtures/dependencies/yarn_old.txt
411
+ - spec/fixtures/dependencies/yarn_patch_bumps_minor.diff
358
412
  - spec/fixtures/exception_context.diff
413
+ - spec/fixtures/exception_inline_disabled_rule.diff
359
414
  - spec/fixtures/exception_insert_context.diff
360
415
  - spec/fixtures/exception_misspelled.diff
361
416
  - spec/fixtures/exception_multiline_context.diff
@@ -380,9 +435,14 @@ test_files:
380
435
  - spec/fixtures/todo_link_same_line.diff
381
436
  - spec/fixtures/todo_no_link.diff
382
437
  - spec/fixtures/todo_removed.diff
438
+ - spec/fixtures/yarn_deduplicate/list.a.txt
439
+ - spec/fixtures/yarn_deduplicate/list.b.txt
440
+ - spec/fixtures/yarn_deduplicate/list.diff
441
+ - spec/fixtures/yarn_deduplicate/yarn.lock
383
442
  - spec/fixtures_helper.rb
384
443
  - spec/spec_helper.rb
385
444
  - spec/wcc/commit_lint_spec.rb
445
+ - spec/wcc/dependencies_spec.rb
386
446
  - spec/wcc/github_spec.rb
387
447
  - spec/wcc/jshint_spec.rb
388
448
  - spec/wcc/plugin_spec.rb
@@ -390,4 +450,5 @@ test_files:
390
450
  - spec/wcc/rubocop_exceptions_spec.rb
391
451
  - spec/wcc/todos_spec.rb
392
452
  - spec/wcc/utils_spec.rb
453
+ - spec/wcc/yarn_deduplicate_spec.rb
393
454
  - spec/wcc_spec.rb