codemonitor 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +114 -3
- data/engines/custom/extractor.rb +37 -0
- data/exe/codemonitor +3 -1
- data/lib/codemonitor/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e6c5534fbc28c7134e0d88898112fd0eff5db4c92bb0ac86833bb4daff955d6
|
4
|
+
data.tar.gz: c9d7dc28df1e2d07e6b5377b320df7e947bcb72e13b6fa1dfe3981325d1fc9a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea0fe2d521164f1386c4d616a2d8a539265c575af18789184672578711207289b506f67b4ed13fa52768389f8df496561206ea7ca73cdb43793f2f31a66dcd6e
|
7
|
+
data.tar.gz: 22fcaa2bf3f0c58f565cf055c214ac993cc59b8ea45ff0523d5895060a7adf6cb475bb3db0ec90dbfd22dc8772241c0ee02f5338afb01b7626125f4811ab80c1
|
data/README.md
CHANGED
@@ -1,9 +1,120 @@
|
|
1
|
-
# CodeMonitor
|
1
|
+
# 🖥️ CodeMonitor
|
2
2
|
|
3
3
|
A engine to collect multiple metrics from your repository and push them to a
|
4
4
|
time series provider.
|
5
5
|
|
6
6
|
|
7
|
-
#
|
7
|
+
# Engines
|
8
8
|
|
9
|
-
|
9
|
+
## Git
|
10
|
+
|
11
|
+
Collect multiple metrics from the a Git repository.
|
12
|
+
|
13
|
+
**Requirements / Setup**:
|
14
|
+
|
15
|
+
You need a `.git` folder present in the current folder:
|
16
|
+
|
17
|
+
**Options**:
|
18
|
+
|
19
|
+
`CODEMONITOR_GIT_FILES_THRESHOLD`: Don't emit metrics about number of files, from those that are above of this threshold. (Default: `0`)
|
20
|
+
|
21
|
+
## Eslint
|
22
|
+
|
23
|
+
Collect multiple metrics from the a project with [Eslint](https://eslint.org/) configured.
|
24
|
+
|
25
|
+
**Requirements / Setup**:
|
26
|
+
|
27
|
+
You need a `.eslintrc.js` and a `eslint.output.json` file present in the current folder.
|
28
|
+
|
29
|
+
You can generate the `eslint.output.json` file with this example command:
|
30
|
+
|
31
|
+
```
|
32
|
+
eslint -f json -o eslint.output.json
|
33
|
+
```
|
34
|
+
**Options**:
|
35
|
+
|
36
|
+
`CODEMONITOR_ESLINT_THRESHOLD`: Don't emit metrics about eslint rules that are above of this threshold. (Default: `10`)
|
37
|
+
|
38
|
+
|
39
|
+
## Npm
|
40
|
+
|
41
|
+
Collect multiple metrics from the a NodeJS.
|
42
|
+
|
43
|
+
**Requirements / Setup**:
|
44
|
+
|
45
|
+
You need a `package.json` file present in the current folder.
|
46
|
+
|
47
|
+
## Packwerk
|
48
|
+
|
49
|
+
Collect multiple metrics from the a Ruby project with [Packwerk](https://github.com/Shopify/packwerk) configured.
|
50
|
+
|
51
|
+
**Requirements / Setup**:
|
52
|
+
|
53
|
+
You need a `deprecated_references.yml` files present in the current project.
|
54
|
+
|
55
|
+
## Rubocop
|
56
|
+
|
57
|
+
Collect multiple metrics from the a Ruby project with [Rubocop](https://github.com/rubocop/rubocop) configured.
|
58
|
+
|
59
|
+
**Requirements / Setup**:
|
60
|
+
|
61
|
+
You need a `.rubocop.yml` and a `rubocop.output.json` file present in the current folder.
|
62
|
+
|
63
|
+
You can generate the `rubocop.output.json` file with this example command:
|
64
|
+
|
65
|
+
```
|
66
|
+
bundle exec srb tc --metrics-prefix 'codemetrics' --metrics-file sorbet.output.json
|
67
|
+
```
|
68
|
+
|
69
|
+
**Options**:
|
70
|
+
|
71
|
+
`CODEMONITOR_RUBOCOP_THRESHOLD`: Don't emit metrics about rubocop cops that are above of this threshold. (Default: `50`)
|
72
|
+
|
73
|
+
|
74
|
+
## Semgrep
|
75
|
+
|
76
|
+
Collect multiple metrics from the a with [Semgrep](https://semgrep.dev/) configured.
|
77
|
+
|
78
|
+
**Requirements / Setup**:
|
79
|
+
|
80
|
+
You need a `.semgrep.yml` and a `semgrep.output.json` file present in the current folder.
|
81
|
+
|
82
|
+
You can generate the `semgrep.output.json` file with this example command:
|
83
|
+
|
84
|
+
```
|
85
|
+
semgrep --json -o semgrep.output.json
|
86
|
+
```
|
87
|
+
|
88
|
+
**Options**:
|
89
|
+
|
90
|
+
`CODEMONITOR_SEMGREP_THRESHOLD`: Don't emit metrics about rubocop cops that are above of this threshold. (Default: `50`)
|
91
|
+
|
92
|
+
## Sorbet
|
93
|
+
|
94
|
+
Collect multiple metrics from the a with [Sorbet](https://sorbet.org/) configured.
|
95
|
+
|
96
|
+
**Requirements / Setup**:
|
97
|
+
|
98
|
+
You need a `sorbet.output.json` file present in the current folder.
|
99
|
+
|
100
|
+
You can generate the `sorbet.output.json` file with this example command:
|
101
|
+
|
102
|
+
```
|
103
|
+
bundle exec srb tc --metrics-prefix 'codemetrics' --metrics-file sorbet.output.json
|
104
|
+
```
|
105
|
+
|
106
|
+
# Providers
|
107
|
+
|
108
|
+
## Console
|
109
|
+
|
110
|
+
TODO
|
111
|
+
|
112
|
+
## Datadog
|
113
|
+
|
114
|
+
TODO
|
115
|
+
|
116
|
+
# Contribute
|
117
|
+
|
118
|
+
This project started as a side project, so I'm sure that is full
|
119
|
+
of mistakes and areas to be improve. If you think you can tweak the code to
|
120
|
+
make it better, I'll really appreciate a pull request. ;)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Engines
|
4
|
+
module Custom
|
5
|
+
class Extractor
|
6
|
+
def call(provider)
|
7
|
+
return unless requirements?
|
8
|
+
|
9
|
+
provider.emit(metrics)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def requirements?
|
15
|
+
custom_files.length.positive?
|
16
|
+
end
|
17
|
+
|
18
|
+
def custom_files
|
19
|
+
Dir.glob('./.codemonitor/*.rb')
|
20
|
+
end
|
21
|
+
|
22
|
+
def metrics
|
23
|
+
custom_files.map do |file|
|
24
|
+
values = begin
|
25
|
+
eval File.read(file)
|
26
|
+
rescue SyntaxError => e
|
27
|
+
raise "Unable to execute the custom codemonitor script `#{file}` file"
|
28
|
+
end
|
29
|
+
|
30
|
+
raise "Malformed return value from `#{file}` file. It must be a hash of metrics" unless values.is_a?(Hash)
|
31
|
+
|
32
|
+
values
|
33
|
+
end.reduce({}, :merge)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/exe/codemonitor
CHANGED
@@ -12,6 +12,7 @@ require_relative '../engines/packwerk/extractor'
|
|
12
12
|
require_relative '../engines/rubocop/extractor'
|
13
13
|
require_relative '../engines/semgrep/extractor'
|
14
14
|
require_relative '../engines/sorbet/extractor'
|
15
|
+
require_relative '../engines/custom/extractor'
|
15
16
|
|
16
17
|
PROVIDERS = {
|
17
18
|
console: Providers::Console,
|
@@ -26,7 +27,8 @@ EXTRACTORS = {
|
|
26
27
|
packwerk: Engines::Packwerk::Extractor,
|
27
28
|
rubocop: Engines::Rubocop::Extractor,
|
28
29
|
semgrep: Engines::Semgrep::Extractor,
|
29
|
-
sorbet: Engines::Sorbet::Extractor
|
30
|
+
sorbet: Engines::Sorbet::Extractor,
|
31
|
+
custom: Engines::Custom::Extractor
|
30
32
|
}.freeze
|
31
33
|
|
32
34
|
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.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ferran Basora
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dogapi
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- bin/console
|
116
116
|
- bin/setup
|
117
117
|
- codemonitor.gemspec
|
118
|
+
- engines/custom/extractor.rb
|
118
119
|
- engines/debug/extractor.rb
|
119
120
|
- engines/eslint/extractor.rb
|
120
121
|
- engines/git/extractor.rb
|