zubat 0.0.2 → 0.0.3

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
  SHA256:
3
- metadata.gz: d9c150c481f0b0f1bc38b7cf18e533355f558952b9e9bf3ba0023fae00358468
4
- data.tar.gz: afd7fb850269de77370ae157b3d2826989382a4bc0f6d620f1179d892832953c
3
+ metadata.gz: baa42361d5aa2f8268e3d5be1e21cc2e0ae7e6b1ce839b43fe9b410f8678e92c
4
+ data.tar.gz: da15e758d143aa4ae0521d2281577e33cbd08dccd209de20e116068846bc715c
5
5
  SHA512:
6
- metadata.gz: f46258854224c3b0ef37cb94d4d7aaefffc1121d4614508db3957bc20ad01615f0625372a55d6e55144719f685df85b975d322e706f379aaab0d67642cbfe879
7
- data.tar.gz: b5c489850eb1fc83ab6bcfd7795a26a234f0bb4cefa09f662e3d3232c55e7b726002b4d176ac39d72076499cf11552cb05f90cf4b23d8c2738784fc2dfc60492
6
+ metadata.gz: 824f35f0dbaa6fa6ddb9cb37bf47f2f8d3221c393beae470465a979fa6773a807c07a305dfd737e81c53935c7f6cb6f7daba525c1204243803d8d36096656625
7
+ data.tar.gz: abd8a26623ed6a4d60bec503551463de0c9cbb7e551b57e6c69702d37280f616fd2158cecfe78906252de3db40ccc6b0f2d8aeeb28154a25e67ea78e061c7033
@@ -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
- next unless commit.exists?(file:)
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
- stat[file] = FlogWrapper.new.examine(code).then do |examined|
43
- { average: examined.average, total_score: examined.total_score }
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 = GitRepo.guess
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
@@ -26,5 +26,9 @@ module Zubat
26
26
  def show(file:)
27
27
  GitCommandWrapper.new.show(sha: @sha, file:)
28
28
  end
29
+
30
+ def diff(file:)
31
+ GitCommandWrapper.new.diff(sha: @sha, file:)
32
+ end
29
33
  end
30
34
  end
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zubat
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
@@ -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
- <div id="select_of_code_smell_scores_trend"></div>
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
- if (siteUrl) {
326
- const url = siteUrl + '/commit/' + value.commit_sha;
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
- open(url, '_blank');
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.2
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-02 00:00:00.000000000 Z
11
+ date: 2023-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: flog