codestats-metrics-reporter 0.1.12 → 0.1.13
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bb214d6a8a78f4c7139dd5516993f773857b677
|
4
|
+
data.tar.gz: ff3218028fcd4787d4c94dc508f42fe36d3be902
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34e752fb00081daf2dc05e1415700a37794cb2b0f769c18812ea50b6ce41cc0c5167c2255d20a2efaed67c39d65ee6738612e84391279d675567876dbafb15c7
|
7
|
+
data.tar.gz: c8f5db9ce8bfb915c501cabbbd8bc1de70eda0b97a535d2fc97d068acbb1b095a97a94181ec77aab31b6bd1751d5f2f935e3a21df14f067ee039f6fd597503ab
|
data/config/default.yml
CHANGED
@@ -18,17 +18,27 @@ metrics:
|
|
18
18
|
enabled: false
|
19
19
|
minimum: 70
|
20
20
|
slather:
|
21
|
-
name: 'Slather'
|
21
|
+
name: 'Code Coverage (Slather)'
|
22
22
|
enabled: false
|
23
23
|
minimum: 70
|
24
24
|
upload_report: true
|
25
|
-
report_dir: '
|
25
|
+
report_dir: 'slather-output'
|
26
|
+
uploader_key: <%= ENV['CODE_STATS_S3_KEY'] %>
|
27
|
+
uploader_secret: <%= ENV['CODE_STATS_S3_SECRET_KEY'] %>
|
28
|
+
uploader_region: <%= ENV['CODE_STATS_S3_REGION'] %>
|
29
|
+
uploader_bucket: <%= ENV['CODE_STATS_S3_BUCKET'] %>
|
30
|
+
swiftlint:
|
31
|
+
name: 'Code Quality (Swiftlint)'
|
32
|
+
enabled: false
|
33
|
+
minimum: 70
|
34
|
+
upload_report: true
|
35
|
+
report_dir: 'swiftlint-output'
|
26
36
|
uploader_key: <%= ENV['CODE_STATS_S3_KEY'] %>
|
27
37
|
uploader_secret: <%= ENV['CODE_STATS_S3_SECRET_KEY'] %>
|
28
38
|
uploader_region: <%= ENV['CODE_STATS_S3_REGION'] %>
|
29
39
|
uploader_bucket: <%= ENV['CODE_STATS_S3_BUCKET'] %>
|
30
40
|
tailor:
|
31
|
-
name: 'Code Quality'
|
41
|
+
name: 'Code Quality (Tailor)'
|
32
42
|
enabled: false
|
33
43
|
minimum: 70
|
34
44
|
upload_report: true
|
@@ -6,6 +6,7 @@ require 'code_stats/metrics/reporter/cli'
|
|
6
6
|
require 'code_stats/metrics/reporter/rubycritic'
|
7
7
|
require 'code_stats/metrics/reporter/simplecov'
|
8
8
|
require 'code_stats/metrics/reporter/slather'
|
9
|
+
require 'code_stats/metrics/reporter/swiftlint'
|
9
10
|
require 'code_stats/metrics/reporter/tailor'
|
10
11
|
require 'code_stats/metrics/reporter/karma_coverage'
|
11
12
|
require 'code_stats/metrics/reporter/escomplex'
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 's3_uploader'
|
2
|
+
require 'pathname'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module CodeStats
|
6
|
+
module Metrics
|
7
|
+
module Reporter
|
8
|
+
class Swiftlint
|
9
|
+
class << self
|
10
|
+
def generate_data(metric, config_store)
|
11
|
+
@config_store = config_store
|
12
|
+
@metric = metric
|
13
|
+
{
|
14
|
+
metric_name: metric.data['name'],
|
15
|
+
value: parse_quality,
|
16
|
+
minimum: metric.data['minimum'],
|
17
|
+
url: url
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def parse_quality
|
24
|
+
upload_report
|
25
|
+
code_quality
|
26
|
+
end
|
27
|
+
|
28
|
+
def code_quality
|
29
|
+
base_dir = Pathname.new(@metric.data['report_dir'])
|
30
|
+
html = File.read(base_dir.join('index.html'))
|
31
|
+
|
32
|
+
total_warnings = Oga.parse_html(html).xpath('html/body/table[2]/tbody/tr[2]/td[2]').text.to_i
|
33
|
+
total_errors = Oga.parse_html(html).xpath('html/body/table[2]/tbody/tr[3]/td[2]').text.to_i
|
34
|
+
|
35
|
+
total = 100
|
36
|
+
total -= total_errors * 100 # In case there are errors, code quality MUST be 0.
|
37
|
+
total -= total_warnings * 2 # Each warning substracts 2 from max.
|
38
|
+
[0, total].max
|
39
|
+
end
|
40
|
+
|
41
|
+
# Uploading methods
|
42
|
+
|
43
|
+
def upload_report
|
44
|
+
build_uploader.upload(File.realpath(@metric.data['report_dir']).to_s, bucket) if upload_report?
|
45
|
+
end
|
46
|
+
|
47
|
+
def build_uploader
|
48
|
+
S3Uploader::Uploader.new(s3_key: @metric.data['uploader_key'],
|
49
|
+
s3_secret: @metric.data['uploader_secret'],
|
50
|
+
destination_dir: "swiftlint/#{project}/#{id}",
|
51
|
+
region: @metric.data['uploader_region'])
|
52
|
+
end
|
53
|
+
|
54
|
+
def upload_report?
|
55
|
+
@metric.data['upload_report']
|
56
|
+
end
|
57
|
+
|
58
|
+
def url
|
59
|
+
"https://s3.amazonaws.com/#{bucket}/swiftlint/#{project}/#{id}/index.html"
|
60
|
+
end
|
61
|
+
|
62
|
+
def project
|
63
|
+
Ci.data(@config_store.ci)[:repository_name]
|
64
|
+
end
|
65
|
+
|
66
|
+
def id
|
67
|
+
Ci.data(@config_store.ci)[:branch] || Ci.data(@config_store.ci)[:pull_request]
|
68
|
+
end
|
69
|
+
|
70
|
+
def bucket
|
71
|
+
@metric.data['uploader_bucket']
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codestats-metrics-reporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esteban Pintos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- lib/code_stats/metrics/reporter/rubycritic.rb
|
160
160
|
- lib/code_stats/metrics/reporter/simplecov.rb
|
161
161
|
- lib/code_stats/metrics/reporter/slather.rb
|
162
|
+
- lib/code_stats/metrics/reporter/swiftlint.rb
|
162
163
|
- lib/code_stats/metrics/reporter/tailor.rb
|
163
164
|
- lib/code_stats/metrics/reporter/version.rb
|
164
165
|
homepage: https://github.com/Wolox/codestats-metrics-reporter
|