forked from bugsnag/bugsnag-cocoa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dangerfile
66 lines (53 loc) · 2.01 KB
/
Dangerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# vim: set ft=ruby
require 'json'
###
def parse_infer_results(path)
issue_count = 0
JSON.parse(File.read(path)).each do |result|
case result['severity']
when 'ERROR'
fail("[Infer] #{result['qualifier']}", file: result['file'], line: result['line'])
when 'WARNING'
warn("[Infer] #{result['qualifier']}", file: result['file'], line: result['line'])
end
issue_count += 1
end
markdown("**[Infer](https://fbinfer.com)**: No issues found :tada:") if issue_count == 0
end
###
def parse_oclint_results(path)
issue_count = 0
results = JSON.parse(File.read(path))
results['violation'].each do |violation|
file = violation['path'].sub("#{Dir.pwd}/", '')
case violation['priority']
when 1
fail("[OCLint] #{violation['rule']}: #{violation['message']}", file: file, line: violation['startLine'])
when 2, 3
warn("[OCLint] #{violation['rule']}: #{violation['message']}", file: file, line: violation['startLine'])
end
issue_count += 1
end
markdown("**[OCLint](http://oclint.org)**: No issues found :tada:") if issue_count == 0
end
###
def framework_size
def _(number) # Formats a number with thousands separated by ','
number.to_s.reverse.scan(/.{1,3}/).join(',').reverse
end
# The .size_after and .size_before files must be created prior to running this Dangerfile.
size_after = File.read('.size_after').to_i
size_before = File.read('.size_before').to_i
case true
when size_after == size_before
markdown("**`Bugsnag.framework`** binary size did not change - #{_(size_after)} bytes")
when size_after < size_before
markdown("**`Bugsnag.framework`** binary size decreased by #{_(size_before - size_after)} bytes from #{_(size_before)} to #{_(size_after)} :tada:")
when size_after > size_before
markdown("**`Bugsnag.framework`** binary size increased by #{_(size_after - size_before)} bytes from #{_(size_before)} to #{_(size_after)}")
end
end
###
parse_infer_results('infer-out/report.json')
parse_oclint_results('oclint.json')
framework_size()