danger-xcprofiler 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58787f96f3db5f505748ca1532c89bc7686fc084
4
- data.tar.gz: fbe9fd4ef7f9e6e970b2a4ac2e86af6ae8639967
3
+ metadata.gz: d53c2adc425beb4ac13b96c331b14aae3778cc8f
4
+ data.tar.gz: c2b35bcfbafdb557ff76b38e5a11b6037c3540c9
5
5
  SHA512:
6
- metadata.gz: 17e3d2e656fac5bb7ae49c74ac8a51427f71abf96a4cee082c7e1515c40dab02aa284d37bcd6ab85949e652d19d2b8803af09b109f72b2608b7411e0cb2328d3
7
- data.tar.gz: ee1878fb82f7845d4540d3661d199e62f1735b25d0f730e291a2ead922f7f7846e41769777b6e5b9b3f2ef4b9d6710a752b2caac3ac94ad8feed195042279e0b
6
+ metadata.gz: c520d168973faa82f5cfb25988dcbb390c6ecb68b91fff925d49f92a00252aaf53bde9504c8f95858d1df72a2dc018ad57f2b0e0d9ed7c44c315e9feabab00b8
7
+ data.tar.gz: 1b0470efd3c6da2002ab7d4362c52df4a555067aa34665b83b6fedda9ead81d02923cd9c5427947f782616de930b6039a65a833aec52dfb25de7306947e79584
data/.rubocop.yml CHANGED
@@ -1,3 +1,6 @@
1
+ Metrics/ModuleLength:
2
+ Max: 120
3
+
1
4
  Metrics/MethodLength:
2
5
  Enabled: false
3
6
 
@@ -11,4 +14,5 @@ Metrics/BlockLength:
11
14
  Style/Documentation:
12
15
  Enabled: false
13
16
 
14
-
17
+ Metrics/AbcSize:
18
+ Max: 25
data/.travis.yml CHANGED
@@ -4,7 +4,6 @@ cache:
4
4
  - bundle
5
5
 
6
6
  rvm:
7
- - 2.0
8
7
  - 2.1.3
9
8
  - 2.3.1
10
9
 
@@ -12,13 +12,21 @@ module Danger
12
12
  end
13
13
 
14
14
  def report!(executions)
15
+ if @inline_mode
16
+ inline_report(executions)
17
+ else
18
+ markdown_report(executions)
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def inline_report(executions)
15
25
  executions.each do |execution|
16
26
  options = {}
17
- if @inline_mode
18
- options[:file] = relative_path(execution.path)
19
- options[:line] = execution.line
20
- end
21
- message = message(execution)
27
+ options[:file] = relative_path(execution.path)
28
+ options[:line] = execution.line
29
+ message = "`#{execution.method_name}` takes #{execution.time} ms to build"
22
30
 
23
31
  if execution.time >= @thresholds[:fail]
24
32
  @dangerfile.fail(message, options)
@@ -28,17 +36,38 @@ module Danger
28
36
  end
29
37
  end
30
38
 
31
- private
39
+ def markdown_report(executions)
40
+ warning_executions = executions.select do |e|
41
+ e.time >= @thresholds[:warn] && e.time < @thresholds[:fail]
42
+ end
43
+ error_executions = executions.select do |e|
44
+ e.time >= @thresholds[:fail]
45
+ end
46
+
47
+ return if warning_executions.empty? && error_executions.empty?
32
48
 
33
- def message(execution)
34
- message = "`#{execution.method_name}` takes #{execution.time} ms to build"
35
- return message if @inline_mode
36
- "[#{execution.filename}] #{message}"
49
+ message = "### Xcprofiler found issues\n\n"
50
+ message << markdown_issues(warning_executions, 'Warnings') unless warning_executions.empty?
51
+ message << markdown_issues(error_executions, 'Errors') unless error_executions.empty?
52
+ @dangerfile.markdown(message, {})
37
53
  end
38
54
 
39
55
  def relative_path(path)
40
56
  working_dir = Pathname.new(@working_dir)
41
57
  Pathname.new(path).relative_path_from(working_dir).to_s
42
58
  end
59
+
60
+ def markdown_issues(executions, heading)
61
+ message = "#### #{heading}\n\n"
62
+
63
+ message << "| File | Line | Method Name | Build Time (ms) |\n"
64
+ message << "| ---- | ---- | ----------- | --------------- |\n"
65
+
66
+ executions.each do |e|
67
+ message << "| #{e.filename} | #{e.line} | #{e.method_name} | #{e.time} |\n"
68
+ end
69
+
70
+ message
71
+ end
43
72
  end
44
73
  end
@@ -1,3 +1,3 @@
1
1
  module DangerXcprofiler
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
@@ -24,6 +24,7 @@ module Danger
24
24
  @xcprofiler.working_dir = ''
25
25
  allow(@dangerfile).to receive(:warn)
26
26
  allow(@dangerfile).to receive(:fail)
27
+ allow(@dangerfile).to receive(:markdown)
27
28
  allow(Xcprofiler::Profiler).to receive(:by_product_name).with(product_name).and_return(profiler)
28
29
  allow(derived_data).to receive(:flag_enabled?).and_return(true)
29
30
  allow(derived_data).to receive(:executions).and_return([execution0, execution1])
@@ -92,18 +93,26 @@ module Danger
92
93
  context 'with slow execution' do
93
94
  let(:time0) { 49.9 }
94
95
  let(:time1) { 50 }
96
+ message = "### Xcprofiler found issues\n\n"
97
+ message << "#### Warnings\n\n"
98
+ message << "| File | Line | Method Name | Build Time (ms) |\n"
99
+ message << "| ---- | ---- | ----------- | --------------- |\n"
100
+ message << "| Source.swift | 20 | doSomething() | 50.0 |\n"
95
101
  it 'asserts warning' do
96
102
  @xcprofiler.report(product_name)
97
- expect(@dangerfile).to have_received(:warn)
98
- .with('[Source.swift] `doSomething()` takes 50.0 ms to build', {})
103
+ expect(@dangerfile).to have_received(:markdown).with(message, {})
99
104
  end
100
105
  end
101
106
 
102
107
  context 'with very slow execution' do
108
+ message = "### Xcprofiler found issues\n\n"
109
+ message << "#### Errors\n\n"
110
+ message << "| File | Line | Method Name | Build Time (ms) |\n"
111
+ message << "| ---- | ---- | ----------- | --------------- |\n"
112
+ message << "| Source.swift | 20 | doSomething() | 100.0 |\n"
103
113
  it 'asserts failure' do
104
114
  @xcprofiler.report(product_name)
105
- expect(@dangerfile).to have_received(:fail)
106
- .with('[Source.swift] `doSomething()` takes 100.0 ms to build', {})
115
+ expect(@dangerfile).to have_received(:markdown).with(message, {})
107
116
  end
108
117
  end
109
118
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-xcprofiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - giginet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-11 00:00:00.000000000 Z
11
+ date: 2017-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcprofiler