zubat 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zubat/analizer.rb +14 -5
- data/lib/zubat/cli/app.rb +4 -1
- data/lib/zubat/commit.rb +4 -0
- data/lib/zubat/generator.rb +2 -1
- data/lib/zubat/git_command_wrapper.rb +15 -0
- data/lib/zubat/version.rb +1 -1
- data/templates/chart.html.erb +23 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: baa42361d5aa2f8268e3d5be1e21cc2e0ae7e6b1ce839b43fe9b410f8678e92c
|
4
|
+
data.tar.gz: da15e758d143aa4ae0521d2281577e33cbd08dccd209de20e116068846bc715c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 824f35f0dbaa6fa6ddb9cb37bf47f2f8d3221c393beae470465a979fa6773a807c07a305dfd737e81c53935c7f6cb6f7daba525c1204243803d8d36096656625
|
7
|
+
data.tar.gz: abd8a26623ed6a4d60bec503551463de0c9cbb7e551b57e6c69702d37280f616fd2158cecfe78906252de3db40ccc6b0f2d8aeeb28154a25e67ea78e061c7033
|
data/lib/zubat/analizer.rb
CHANGED
@@ -24,6 +24,10 @@ module Zubat
|
|
24
24
|
stat.fetch(file).fetch(:smells).fetch(label, 0)
|
25
25
|
end
|
26
26
|
|
27
|
+
def diff(file)
|
28
|
+
stat.fetch(file, {}).fetch(:diff, nil)
|
29
|
+
end
|
30
|
+
|
27
31
|
def each(*, **, &block)
|
28
32
|
stat.each(*, **, &block)
|
29
33
|
end
|
@@ -33,21 +37,26 @@ module Zubat
|
|
33
37
|
stat = {}
|
34
38
|
|
35
39
|
files.each do |file|
|
36
|
-
|
40
|
+
diff = commit.diff(file:)
|
41
|
+
|
42
|
+
next if diff.empty?
|
43
|
+
|
44
|
+
stat[file] = {}
|
45
|
+
|
46
|
+
stat[file].merge!(diff:)
|
37
47
|
|
38
48
|
code = commit.show(file:)
|
39
49
|
|
40
50
|
next unless RubyCode.new(code:).valid?
|
41
51
|
|
42
|
-
|
43
|
-
|
52
|
+
FlogWrapper.new.examine(code).then do |examined|
|
53
|
+
stat[file][:average] = examined.average
|
54
|
+
stat[file][:total_score] = examined.average
|
44
55
|
end
|
45
56
|
|
46
57
|
stat[file][:smells] = ReekWrapper.new.examine(code).map(&:smell_type).tally
|
47
58
|
end
|
48
59
|
|
49
|
-
# return if smells.empty? && stat.empty?
|
50
|
-
|
51
60
|
stat = Stat.new(stat:)
|
52
61
|
|
53
62
|
AnalizedResult.new(label: "#{commit.time.iso8601} (#{commit.sha})",
|
data/lib/zubat/cli/app.rb
CHANGED
@@ -28,6 +28,7 @@ module Zubat
|
|
28
28
|
URL_FORMATS = [
|
29
29
|
%r[https://(.+)/(.+)/(.+).git],
|
30
30
|
%r[git@(.+):(.+)/(.+).git],
|
31
|
+
%r[ssh://(.+)/(.+)/(.+)],
|
31
32
|
]
|
32
33
|
|
33
34
|
def self.guess
|
@@ -79,9 +80,11 @@ module Zubat
|
|
79
80
|
|
80
81
|
files = argv.files
|
81
82
|
|
82
|
-
repo =
|
83
|
+
repo = nil
|
83
84
|
|
84
85
|
results = Dir.chdir(argv.root || Dir.pwd) do
|
86
|
+
repo = GitRepo.guess
|
87
|
+
|
85
88
|
commits = Zubat::Commit.find(files:)
|
86
89
|
|
87
90
|
Progress
|
data/lib/zubat/commit.rb
CHANGED
data/lib/zubat/generator.rb
CHANGED
@@ -36,9 +36,10 @@ module Zubat
|
|
36
36
|
dataset[:data] << {
|
37
37
|
label: xlabel,
|
38
38
|
commit_sha: result.commit.sha,
|
39
|
+
commit_diff: result.stat.diff(ylabel),
|
39
40
|
complexity_total: result.stat.complexity_total(ylabel),
|
40
41
|
complexity_average: result.stat.complexity_average(ylabel),
|
41
|
-
smells_scores: result.stat.smell_scores(ylabel).map { |type, value| { type:, value: } }
|
42
|
+
smells_scores: result.stat.smell_scores(ylabel).map { |type, value| { type:, value: } },
|
42
43
|
}
|
43
44
|
end
|
44
45
|
end
|
@@ -36,6 +36,17 @@ module Zubat
|
|
36
36
|
end
|
37
37
|
SCRIPT
|
38
38
|
end
|
39
|
+
|
40
|
+
def diff(sha:, file:) # rubocop:disable Lint/UnusedMethodArgument
|
41
|
+
<<~SCRIPT
|
42
|
+
diff --git a/hello_world.rb b/hello_world.rb
|
43
|
+
class HelloWorld
|
44
|
+
def show
|
45
|
+
+ puts "Hello World"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
SCRIPT
|
49
|
+
end
|
39
50
|
end
|
40
51
|
|
41
52
|
Log = Data.define(:sha, :time)
|
@@ -73,5 +84,9 @@ module Zubat
|
|
73
84
|
def show(sha:, file:)
|
74
85
|
`git show #{sha}:#{file}`
|
75
86
|
end
|
87
|
+
|
88
|
+
def diff(sha:, file:)
|
89
|
+
`git show #{sha} -- #{file}`
|
90
|
+
end
|
76
91
|
end
|
77
92
|
end
|
data/lib/zubat/version.rb
CHANGED
data/templates/chart.html.erb
CHANGED
@@ -4,6 +4,10 @@
|
|
4
4
|
<meta name="robots" content="noindex,nofollow">
|
5
5
|
<meta charset="UTF-8">
|
6
6
|
|
7
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css" integrity="sha512-hasIneQUHlh06VNBe7f6ZcHmeRTLIaQWFd43YriJ0UND19bvYRauxthDg8E4eVNPm9bRUhr5JGeqH7FRFXQu5g==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
8
|
+
|
9
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js" integrity="sha512-D9gUyxqja7hBtkWpPWGt9wfbfaMGVt9gnyCvYa+jojwwPHLCzUm5i8rpk7vD7wNee9bA35eYIjobYPaQuKS1MQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
10
|
+
|
7
11
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/purecss@3.0.0/build/pure-min.css" integrity="sha384-X38yfunGUhNzHpBaEBsWLO+A0HDYOQi8ufWDkZ0k9e0eXz/tH3II7uKZ9msv++Ls" crossorigin="anonymous">
|
8
12
|
|
9
13
|
<style>
|
@@ -253,6 +257,12 @@
|
|
253
257
|
left: 200px;
|
254
258
|
}
|
255
259
|
}
|
260
|
+
|
261
|
+
#diffArea {
|
262
|
+
max-height: 400px;
|
263
|
+
overflow: auto;
|
264
|
+
}
|
265
|
+
|
256
266
|
</style>
|
257
267
|
<title>zubat</title>
|
258
268
|
</head>
|
@@ -284,23 +294,17 @@
|
|
284
294
|
</div>
|
285
295
|
|
286
296
|
<div class="content">
|
297
|
+
<p><pre id="diffArea"></pre></p>
|
298
|
+
|
287
299
|
<h2 id="complexity_total" class="content-subhead">Complexity Total</h2>
|
288
|
-
<p>
|
289
|
-
<canvas id="chart_of_code_complexity_total_trend" width="400" height="300"></canvas>
|
290
|
-
</p>
|
300
|
+
<p><canvas id="chart_of_code_complexity_total_trend" width="400" height="200"></canvas></p>
|
291
301
|
|
292
302
|
<h2 id="complexity_average" class="content-subhead">Complexity Average <small>- Complexity score per methods</small></h2>
|
293
|
-
<p>
|
294
|
-
<canvas id="chart_of_code_complexity_average_trend" width="400" height="300"></canvas>
|
295
|
-
</p>
|
303
|
+
<p><canvas id="chart_of_code_complexity_average_trend" width="400" height="200"></canvas></p>
|
296
304
|
|
297
305
|
<h2 id="code_smells" class="content-subhead">Code smells</h2>
|
298
|
-
<p>
|
299
|
-
|
300
|
-
</p>
|
301
|
-
<p>
|
302
|
-
<canvas id="chart_of_code_smell_scores_trend" width="400" height="300"></canvas>
|
303
|
-
</p>
|
306
|
+
<p><div id="select_of_code_smell_scores_trend"></div></p>
|
307
|
+
<p><canvas id="chart_of_code_smell_scores_trend" width="400" height="200"></canvas></p>
|
304
308
|
</div>
|
305
309
|
</div>
|
306
310
|
</div>
|
@@ -322,11 +326,14 @@
|
|
322
326
|
const label = chart.data.labels[point.index];
|
323
327
|
const value = chart.data.datasets[point.datasetIndex].data[point.index];
|
324
328
|
|
325
|
-
|
326
|
-
|
329
|
+
const code = document.createElement('code');
|
330
|
+
code.classList.add('language-diff');
|
331
|
+
code.textContent = value.commit_diff;
|
332
|
+
hljs.highlightBlock(code);
|
327
333
|
|
328
|
-
|
329
|
-
|
334
|
+
const diffArea = document.getElementById('diffArea');
|
335
|
+
diffArea.innerHTML = '';
|
336
|
+
diffArea.appendChild(code);
|
330
337
|
};
|
331
338
|
};
|
332
339
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zubat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mizokami
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: flog
|