rubycritic 4.4.0 → 4.4.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80cbe6c77393b0819c820cd22c3cc67a0f6a5824598e1f67dbb1f8a7097070d8
|
4
|
+
data.tar.gz: '08b6e201d99ad0537cc440f885a36c5f07cda146766a3009cb4616ce7209fc06'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1883ee9f5c4832b9fefcabed5f768d368e0b539d7cd7435813546c5a1db0b93856bc0705e525de902dd2d5cd500e6692854476c2b5a24dd23dc5a6a260c37877
|
7
|
+
data.tar.gz: ebdb193754eab2b5d9b94830bda9de53cec62eecc1c11a1a4d15bf50c3a7e7f7bfcd0147fafbd85565f9a28962669e39b097a1f5dce93af77242be699b5d132a
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
# master [(unreleased)](https://github.com/whitesmith/rubycritic/compare/v4.4.
|
1
|
+
# master [(unreleased)](https://github.com/whitesmith/rubycritic/compare/v4.4.1...master)
|
2
|
+
|
3
|
+
# v4.4.1 / 2020-02-20 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.4.0...v4.4.1)
|
4
|
+
|
5
|
+
* [CHANGE] Rewrite how churn is calculated to make it faster
|
2
6
|
|
3
7
|
# v4.4.0 / 2020-02-15 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.3.3...v4.4.0)
|
4
8
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'tty/which'
|
4
|
+
require 'rubycritic/source_control_systems/git/churn'
|
4
5
|
|
5
6
|
module RubyCritic
|
6
7
|
module SourceControlSystem
|
@@ -28,12 +29,16 @@ module RubyCritic
|
|
28
29
|
'Git'
|
29
30
|
end
|
30
31
|
|
32
|
+
def churn
|
33
|
+
@churn ||= Churn.new
|
34
|
+
end
|
35
|
+
|
31
36
|
def revisions_count(path)
|
32
|
-
|
37
|
+
churn.revisions_count(path)
|
33
38
|
end
|
34
39
|
|
35
40
|
def date_of_last_commit(path)
|
36
|
-
|
41
|
+
churn.date_of_last_commit(path)
|
37
42
|
end
|
38
43
|
|
39
44
|
def revision?
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyCritic
|
4
|
+
module SourceControlSystem
|
5
|
+
class Git < Base
|
6
|
+
Stats = Struct.new(:count, :date)
|
7
|
+
|
8
|
+
class Renames
|
9
|
+
def initialize
|
10
|
+
@data = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def renamed(from, to)
|
14
|
+
current = current(to)
|
15
|
+
@data[from] = current
|
16
|
+
end
|
17
|
+
|
18
|
+
def current(name)
|
19
|
+
@data.fetch(name, name)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Churn
|
24
|
+
def initialize
|
25
|
+
@renames = Renames.new
|
26
|
+
@date = nil
|
27
|
+
@stats = {}
|
28
|
+
|
29
|
+
call
|
30
|
+
end
|
31
|
+
|
32
|
+
def revisions_count(path)
|
33
|
+
stats(path).count
|
34
|
+
end
|
35
|
+
|
36
|
+
def date_of_last_commit(path)
|
37
|
+
stats(path).date
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def call
|
43
|
+
Git
|
44
|
+
.git("log --all --date=iso --follow --format='format:date:%x09%ad' --name-status .")
|
45
|
+
.split("\n")
|
46
|
+
.reject(&:empty?)
|
47
|
+
.each { |line| process_line(line) }
|
48
|
+
end
|
49
|
+
|
50
|
+
def process_line(line)
|
51
|
+
operation, *rest = line.split("\t")
|
52
|
+
|
53
|
+
case operation
|
54
|
+
when /^date:/
|
55
|
+
process_date(*rest)
|
56
|
+
when /^R/
|
57
|
+
process_rename(*rest)
|
58
|
+
else
|
59
|
+
process_file(*rest)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def process_date(date)
|
64
|
+
@date = date
|
65
|
+
end
|
66
|
+
|
67
|
+
def process_rename(from, to)
|
68
|
+
@renames.renamed(from, to)
|
69
|
+
process_file(to)
|
70
|
+
end
|
71
|
+
|
72
|
+
def process_file(filename)
|
73
|
+
record_commit(@renames.current(filename), @date)
|
74
|
+
end
|
75
|
+
|
76
|
+
def record_commit(filename, date)
|
77
|
+
stats = @stats[filename] ||= Stats.new(0, date)
|
78
|
+
stats.count += 1
|
79
|
+
end
|
80
|
+
|
81
|
+
def stats(path)
|
82
|
+
@stats.fetch(path, Stats.new(0))
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/rubycritic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubycritic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.4.
|
4
|
+
version: 4.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guilherme Simoes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: flay
|
@@ -496,6 +496,7 @@ files:
|
|
496
496
|
- lib/rubycritic/source_control_systems/base.rb
|
497
497
|
- lib/rubycritic/source_control_systems/double.rb
|
498
498
|
- lib/rubycritic/source_control_systems/git.rb
|
499
|
+
- lib/rubycritic/source_control_systems/git/churn.rb
|
499
500
|
- lib/rubycritic/source_control_systems/mercurial.rb
|
500
501
|
- lib/rubycritic/source_control_systems/perforce.rb
|
501
502
|
- lib/rubycritic/source_locator.rb
|