codemonitor 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/engines/jest-json-summary/extractor.rb +64 -0
- data/engines/npm/extractor.rb +53 -11
- data/engines/scc/extractor.rb +1 -1
- data/exe/codemonitor +3 -1
- data/lib/codemonitor/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f85a1e1dbcae9d0bd26c461505a12449283dbf2029ee34ba59b36a2277e00321
|
4
|
+
data.tar.gz: 2cc548a6646d98cbeab3b72ce2dff06fd0d40175bf599fec2db5e12659aec7c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7af9d278c2c2fcbba028ecb161cf7ee49b374ef701aee25bbb2ccfc3fe714a2fcf54d05c18a43653dee3e3d7263904668b38fa74569c8168c22a87be4bd6b4e2
|
7
|
+
data.tar.gz: f928807e202db2c1b60b3cec7e5df66abd44b04c8c4ddc165a201476c8e04a36ac3f3bd036abc5e3eb54aac66299bc99ac8827aae822d4587d00a1d22a6ff96d
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
codemonitor (0.
|
4
|
+
codemonitor (0.5.0)
|
5
5
|
dogapi (~> 1.45)
|
6
6
|
octokit (~> 4.0)
|
7
7
|
|
@@ -15,7 +15,7 @@ GEM
|
|
15
15
|
diff-lcs (1.3)
|
16
16
|
dogapi (1.45.0)
|
17
17
|
multi_json
|
18
|
-
faraday (1.
|
18
|
+
faraday (1.10.0)
|
19
19
|
faraday-em_http (~> 1.0)
|
20
20
|
faraday-em_synchrony (~> 1.0)
|
21
21
|
faraday-excon (~> 1.1)
|
@@ -50,7 +50,7 @@ GEM
|
|
50
50
|
pry (0.13.1)
|
51
51
|
coderay (~> 1.1)
|
52
52
|
method_source (~> 1.0)
|
53
|
-
public_suffix (4.0.
|
53
|
+
public_suffix (4.0.7)
|
54
54
|
rainbow (3.0.0)
|
55
55
|
rake (13.0.3)
|
56
56
|
regexp_parser (2.1.1)
|
@@ -98,4 +98,4 @@ DEPENDENCIES
|
|
98
98
|
rubocop (~> 0.80)
|
99
99
|
|
100
100
|
BUNDLED WITH
|
101
|
-
2.
|
101
|
+
2.3.12
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Engines
|
6
|
+
module JestJsonSummary
|
7
|
+
class Extractor
|
8
|
+
METRICS = %i[].freeze
|
9
|
+
|
10
|
+
def initialize; end
|
11
|
+
|
12
|
+
def call(provider)
|
13
|
+
metrics = METRICS.map do |metric|
|
14
|
+
[metric, send(metric)]
|
15
|
+
end.to_h
|
16
|
+
|
17
|
+
metrics
|
18
|
+
.merge!(total_lines)
|
19
|
+
.merge!(total_statements)
|
20
|
+
.merge!(total_functions)
|
21
|
+
.merge!(total_branches)
|
22
|
+
.merge!(total_branches_true)
|
23
|
+
|
24
|
+
provider.emit(metrics)
|
25
|
+
end
|
26
|
+
|
27
|
+
def requirements?
|
28
|
+
File.exist?('jest_json_summary.output.json')
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def json_summary
|
34
|
+
@json_summary ||= JSON.parse(File.read('jest_json_summary.output.json'))
|
35
|
+
end
|
36
|
+
|
37
|
+
def total_lines
|
38
|
+
flatten('lines')
|
39
|
+
end
|
40
|
+
|
41
|
+
def total_statements
|
42
|
+
flatten('statements')
|
43
|
+
end
|
44
|
+
|
45
|
+
def total_functions
|
46
|
+
flatten('functions')
|
47
|
+
end
|
48
|
+
|
49
|
+
def total_branches
|
50
|
+
flatten('branches')
|
51
|
+
end
|
52
|
+
|
53
|
+
def total_branches_true
|
54
|
+
flatten('branchesTrue', 'branches_true')
|
55
|
+
end
|
56
|
+
|
57
|
+
def flatten(member, rename = nil)
|
58
|
+
json_summary['total'][member].map do |key, value|
|
59
|
+
["jest_json_summary_#{rename || member}_#{key}", value.to_i]
|
60
|
+
end.to_h
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/engines/npm/extractor.rb
CHANGED
@@ -8,13 +8,21 @@ module Engines
|
|
8
8
|
module Npm
|
9
9
|
class Extractor
|
10
10
|
METRICS = %i[
|
11
|
-
|
11
|
+
npm_number_of_prod_dependencies
|
12
12
|
npm_number_of_dev_dependencies
|
13
13
|
npm_number_of_scripts
|
14
|
-
|
14
|
+
npm_number_of_computed_prod_dependencies
|
15
|
+
npm_number_of_computed_dev_dependencies
|
16
|
+
npm_number_of_computed_optional_dependencies
|
17
|
+
npm_number_of_computed_peer_dependencies
|
18
|
+
npm_number_of_computed_peer_optional_dependencies
|
19
|
+
npm_number_of_computed_total_dependencies
|
20
|
+
npm_number_of_vulnerable_dependencies_info
|
15
21
|
npm_number_of_vulnerable_dependencies_low
|
16
22
|
npm_number_of_vulnerable_dependencies_moderate
|
17
23
|
npm_number_of_vulnerable_dependencies_high
|
24
|
+
npm_number_of_vulnerable_dependencies_critical
|
25
|
+
npm_number_of_vulnerable_dependencies_total
|
18
26
|
].freeze
|
19
27
|
|
20
28
|
def call(provider)
|
@@ -26,25 +34,25 @@ module Engines
|
|
26
34
|
end
|
27
35
|
|
28
36
|
def requirements?
|
29
|
-
File.exist?('package.json')
|
37
|
+
File.exist?('package.json') && File.exist?('package-lock.json')
|
30
38
|
end
|
31
39
|
|
32
40
|
private
|
33
41
|
|
34
|
-
def
|
35
|
-
npm_package['dependencies']
|
42
|
+
def npm_number_of_prod_dependencies
|
43
|
+
npm_package['dependencies']&.keys&.length
|
36
44
|
end
|
37
45
|
|
38
46
|
def npm_number_of_dev_dependencies
|
39
|
-
npm_package['devDependencies']
|
47
|
+
npm_package['devDependencies']&.keys&.length
|
40
48
|
end
|
41
49
|
|
42
50
|
def npm_number_of_scripts
|
43
51
|
npm_package['scripts'].keys.length
|
44
52
|
end
|
45
53
|
|
46
|
-
def
|
47
|
-
|
54
|
+
def npm_number_of_vulnerable_dependencies_info
|
55
|
+
npm_audit_by_severity['info']
|
48
56
|
end
|
49
57
|
|
50
58
|
def npm_number_of_vulnerable_dependencies_low
|
@@ -59,6 +67,38 @@ module Engines
|
|
59
67
|
npm_audit_by_severity['high']
|
60
68
|
end
|
61
69
|
|
70
|
+
def npm_number_of_vulnerable_dependencies_critical
|
71
|
+
npm_audit_by_severity['critical']
|
72
|
+
end
|
73
|
+
|
74
|
+
def npm_number_of_vulnerable_dependencies_total
|
75
|
+
npm_audit_by_severity['total']
|
76
|
+
end
|
77
|
+
|
78
|
+
def npm_number_of_computed_prod_dependencies
|
79
|
+
npm_audit_by_dependencies['prod']
|
80
|
+
end
|
81
|
+
|
82
|
+
def npm_number_of_computed_dev_dependencies
|
83
|
+
npm_audit_by_dependencies['dev']
|
84
|
+
end
|
85
|
+
|
86
|
+
def npm_number_of_computed_optional_dependencies
|
87
|
+
npm_audit_by_dependencies['optional']
|
88
|
+
end
|
89
|
+
|
90
|
+
def npm_number_of_computed_peer_dependencies
|
91
|
+
npm_audit_by_dependencies['peer']
|
92
|
+
end
|
93
|
+
|
94
|
+
def npm_number_of_computed_peer_optional_dependencies
|
95
|
+
npm_audit_by_dependencies['peerOptional']
|
96
|
+
end
|
97
|
+
|
98
|
+
def npm_number_of_computed_total_dependencies
|
99
|
+
npm_audit_by_dependencies['total']
|
100
|
+
end
|
101
|
+
|
62
102
|
def npm_package
|
63
103
|
@npm_package ||= JSON.parse(File.read('package.json'))
|
64
104
|
end
|
@@ -67,10 +107,12 @@ module Engines
|
|
67
107
|
@npm_audit ||= JSON.parse(Shell.run('npm audit --json'))
|
68
108
|
end
|
69
109
|
|
110
|
+
def npm_audit_by_dependencies
|
111
|
+
npm_audit['metadata']['dependencies']
|
112
|
+
end
|
113
|
+
|
70
114
|
def npm_audit_by_severity
|
71
|
-
npm_audit['
|
72
|
-
.map { |_key, value| value['severity'] }
|
73
|
-
.each_with_object(Hash.new(0)) { |e, total| total[e] += 1; }
|
115
|
+
npm_audit['metadata']['vulnerabilities']
|
74
116
|
end
|
75
117
|
end
|
76
118
|
end
|
data/engines/scc/extractor.rb
CHANGED
@@ -6,7 +6,7 @@ module Engines
|
|
6
6
|
module Scc
|
7
7
|
class Extractor
|
8
8
|
METRICS = %i[].freeze
|
9
|
-
FIELDS = %w[Bytes Lines Code Comment Blank Complexity Count WeightedComplexity]
|
9
|
+
FIELDS = %w[Bytes Lines Code Comment Blank Complexity Count WeightedComplexity].freeze
|
10
10
|
|
11
11
|
def initialize; end
|
12
12
|
|
data/exe/codemonitor
CHANGED
@@ -15,6 +15,7 @@ require_relative '../engines/semgrep/extractor'
|
|
15
15
|
require_relative '../engines/sorbet/extractor'
|
16
16
|
require_relative '../engines/scc/extractor'
|
17
17
|
require_relative '../engines/custom/extractor'
|
18
|
+
require_relative '../engines/jest-json-summary/extractor'
|
18
19
|
|
19
20
|
PROVIDERS = {
|
20
21
|
console: Providers::Console,
|
@@ -32,7 +33,8 @@ EXTRACTORS = {
|
|
32
33
|
semgrep: Engines::Semgrep::Extractor,
|
33
34
|
sorbet: Engines::Sorbet::Extractor,
|
34
35
|
scc: Engines::Scc::Extractor,
|
35
|
-
custom: Engines::Custom::Extractor
|
36
|
+
custom: Engines::Custom::Extractor,
|
37
|
+
jest_json_summary: Engines::JestJsonSummary::Extractor
|
36
38
|
}.freeze
|
37
39
|
|
38
40
|
config_provider = ENV['CODEMONITOR_PROVIDER'] || 'console'
|
data/lib/codemonitor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codemonitor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ferran Basora
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dogapi
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- engines/eslint/extractor.rb
|
135
135
|
- engines/git/extractor.rb
|
136
136
|
- engines/github/extractor.rb
|
137
|
+
- engines/jest-json-summary/extractor.rb
|
137
138
|
- engines/npm/extractor.rb
|
138
139
|
- engines/packwerk/extractor.rb
|
139
140
|
- engines/rubocop/extractor.rb
|
@@ -167,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
168
|
- !ruby/object:Gem::Version
|
168
169
|
version: '0'
|
169
170
|
requirements: []
|
170
|
-
rubygems_version: 3.
|
171
|
+
rubygems_version: 3.1.2
|
171
172
|
signing_key:
|
172
173
|
specification_version: 4
|
173
174
|
summary: Collect many metrics your code is generating
|