danger-wcc 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,28 @@
1
+ diff --git a/spec/fixtures/dependencies/yarn_old.txt b/spec/fixtures/dependencies/yarn_old.txt
2
+ index 2fe9d0e..8ceb5eb 100644
3
+ --- a/spec/fixtures/dependencies/yarn_old.txt
4
+ +++ b/spec/fixtures/dependencies/yarn_old.txt
5
+ @@ -671,7 +671,7 @@ yarn list v1.22.4
6
+ ├─ lodash.trimstart@4.5.1
7
+ ├─ lodash.unescape@4.0.1
8
+ ├─ lodash.uniq@4.5.0
9
+ -├─ lodash@4.17.15
10
+ +├─ lodash@4.18.1
11
+ ├─ log-symbols@1.0.2
12
+ ├─ log-update@1.0.2
13
+ ├─ lolex@3.0.0
14
+ @@ -923,10 +923,10 @@ yarn list v1.22.4
15
+ ├─ react-calendar@2.19.0
16
+ ├─ react-dom@16.13.1
17
+ ├─ react-infinite-scroller@1.2.2
18
+ -├─ react-instantsearch-core@5.3.2
19
+ -├─ react-instantsearch-dom@5.3.2
20
+ -├─ react-instantsearch-native@5.3.2
21
+ -├─ react-instantsearch@5.3.2
22
+ +├─ react-instantsearch-core@5.3.3
23
+ +├─ react-instantsearch-dom@5.3.3
24
+ +├─ react-instantsearch-native@5.3.3
25
+ +├─ react-instantsearch@5.3.3
26
+ ├─ react-is@16.6.3
27
+ ├─ react-lifecycles-compat@3.0.4
28
+ ├─ react-property@1.0.1
@@ -0,0 +1,95 @@
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(:html_link) do |text|
14
+ "<a href=\"github_html_link\">#{text}</a>"
15
+ end
16
+
17
+ allow(File).to receive(:exist?).and_call_original
18
+ allow(File).to receive(:read).and_call_original
19
+ allow(File).to receive(:exist?).with('yarn.lock')
20
+ .and_return(true)
21
+ allow(File).to receive(:readlines).with('yarn.lock')
22
+ .and_return(load_fixture('dependencies/yarn.lock').split("\n"))
23
+ allow(File).to receive(:read).with('package.json')
24
+ .and_return(load_fixture('dependencies/package.json'))
25
+ end
26
+
27
+ describe 'yarn dependencies' do
28
+ let(:subject) { Danger::DangerWCC::Dependencies.new(@my_plugin) }
29
+
30
+ it 'Errors when minor version changes' do
31
+ allow(subject).to receive(:run_and_diff)
32
+ .with(/yarn list/)
33
+ .and_return(load_fixture('dependencies/yarn_minor_version.diff'))
34
+ allow(@git).to receive(:diff)
35
+ .and_return([
36
+ load_diff(
37
+ 'spec/fixtures/dependencies/package.json',
38
+ 'dependencies/package.json'
39
+ )
40
+ ])
41
+
42
+ # act
43
+ subject.perform
44
+
45
+ expect(@dangerfile.violation_report[:errors])
46
+ .to eq([Violation.new(
47
+ 'Dangerous change! react-instantsearch was updated '\
48
+ 'from 5.3.2 to 5.7.0 without a corresponding '\
49
+ 'change to package.json!',
50
+ false,
51
+ 'yarn.lock',
52
+ 15_613,
53
+ type: :error
54
+ )])
55
+ end
56
+
57
+ it 'Errors when patch bump causes minor version changes' do
58
+ allow(File).to receive(:readlines).with('yarn.lock')
59
+ .and_return(
60
+ load_fixture('dependencies/yarn.lock_patch_bumps_minor.lock')
61
+ .split("\n")
62
+ )
63
+
64
+ allow(subject).to receive(:run_and_diff)
65
+ .with(/yarn list/)
66
+ .and_return(load_fixture('dependencies/yarn_patch_bumps_minor.diff'))
67
+ allow(@git).to receive(:diff)
68
+ .and_return(
69
+ [
70
+ load_diff(
71
+ 'spec/fixtures/dependencies/'\
72
+ 'package.json_patch_bumps_minor.json',
73
+ 'dependencies/package.json_patch_bumps_minor'
74
+ )
75
+ ]
76
+ )
77
+
78
+ # act
79
+ subject.perform
80
+
81
+ expect(@dangerfile.violation_report[:errors])
82
+ .to eq([Violation.new(
83
+ 'Dangerous change! lodash was updated '\
84
+ 'from 4.17.15 to 4.18.1 without a corresponding '\
85
+ 'change to package.json!',
86
+ false,
87
+ 'yarn.lock',
88
+ # make sure we pick out the right lodash! There's 3 of them.
89
+ 12_111,
90
+ type: :error
91
+ )])
92
+ end
93
+ end
94
+ end
95
+ end
@@ -17,7 +17,7 @@ module Danger
17
17
 
18
18
  describe 'all' do
19
19
  it 'runs all default and passes default options' do
20
- %i[rubocop_exceptions flay todos brakeman].each do |check|
20
+ %i[rubocop_exceptions flay todos brakeman dependencies].each do |check|
21
21
  expect(@my_plugin).to receive(check)
22
22
  .with({})
23
23
  end
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.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Watermark Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-10 00:00:00.000000000 Z
11
+ date: 2020-08-19 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
@@ -279,6 +293,8 @@ 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
297
+ - lib/wcc/dependencies/yarn_info.rb
282
298
  - lib/wcc/github.rb
283
299
  - lib/wcc/jshint.rb
284
300
  - lib/wcc/plugin.rb
@@ -290,6 +306,16 @@ files:
290
306
  - spec/fixtures/brakeman/b.tmp
291
307
  - spec/fixtures/brakeman/brakeman.diff
292
308
  - spec/fixtures/brakeman/brakeman.out
309
+ - spec/fixtures/dependencies/package.json
310
+ - spec/fixtures/dependencies/package.json.diff
311
+ - spec/fixtures/dependencies/package.json_patch_bumps_minor.diff
312
+ - spec/fixtures/dependencies/package.json_patch_bumps_minor.json
313
+ - spec/fixtures/dependencies/yarn.lock
314
+ - spec/fixtures/dependencies/yarn.lock_patch_bumps_minor.lock
315
+ - spec/fixtures/dependencies/yarn_minor_version.diff
316
+ - spec/fixtures/dependencies/yarn_minor_version.txt
317
+ - spec/fixtures/dependencies/yarn_old.txt
318
+ - spec/fixtures/dependencies/yarn_patch_bumps_minor.diff
293
319
  - spec/fixtures/exception_context.diff
294
320
  - spec/fixtures/exception_inline_disabled_rule.diff
295
321
  - spec/fixtures/exception_insert_context.diff
@@ -319,6 +345,7 @@ files:
319
345
  - spec/fixtures_helper.rb
320
346
  - spec/spec_helper.rb
321
347
  - spec/wcc/commit_lint_spec.rb
348
+ - spec/wcc/dependencies_spec.rb
322
349
  - spec/wcc/github_spec.rb
323
350
  - spec/wcc/jshint_spec.rb
324
351
  - spec/wcc/plugin_spec.rb
@@ -356,6 +383,16 @@ test_files:
356
383
  - spec/fixtures/brakeman/b.tmp
357
384
  - spec/fixtures/brakeman/brakeman.diff
358
385
  - spec/fixtures/brakeman/brakeman.out
386
+ - spec/fixtures/dependencies/package.json
387
+ - spec/fixtures/dependencies/package.json.diff
388
+ - spec/fixtures/dependencies/package.json_patch_bumps_minor.diff
389
+ - spec/fixtures/dependencies/package.json_patch_bumps_minor.json
390
+ - spec/fixtures/dependencies/yarn.lock
391
+ - spec/fixtures/dependencies/yarn.lock_patch_bumps_minor.lock
392
+ - spec/fixtures/dependencies/yarn_minor_version.diff
393
+ - spec/fixtures/dependencies/yarn_minor_version.txt
394
+ - spec/fixtures/dependencies/yarn_old.txt
395
+ - spec/fixtures/dependencies/yarn_patch_bumps_minor.diff
359
396
  - spec/fixtures/exception_context.diff
360
397
  - spec/fixtures/exception_inline_disabled_rule.diff
361
398
  - spec/fixtures/exception_insert_context.diff
@@ -385,6 +422,7 @@ test_files:
385
422
  - spec/fixtures_helper.rb
386
423
  - spec/spec_helper.rb
387
424
  - spec/wcc/commit_lint_spec.rb
425
+ - spec/wcc/dependencies_spec.rb
388
426
  - spec/wcc/github_spec.rb
389
427
  - spec/wcc/jshint_spec.rb
390
428
  - spec/wcc/plugin_spec.rb