diggit 3.0.2 → 3.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/dgit/core.rb +6 -1
- data/lib/dgit/version.rb +1 -1
- data/plugins/analysis/yard_dup.rb +119 -0
- 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: c85e3eadbde6b35542b116a284a6c1b1bba40f0e92dc902c407deb3098d26c02
|
4
|
+
data.tar.gz: c941389bb90f76bc46ac997a574220dea844034692f080134b73db31f9e0feea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a411fab663670f3662124714fb17eb40b8e5f5d715b6919ccafa1f257884f791c756ed03923ef01aaad67c3718c924e6efd79ee462ca38ab9d0bf3b36ec50d90
|
7
|
+
data.tar.gz: 50845221483a94d5a8527f532e9a951f28e991ad7497ff4ddf83e7b6002f933bb36e534daf0e1ed5ab54b654f9963817b123650c14212baf5501a08faddb180e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog of Diggit
|
2
2
|
|
3
|
+
### Version 3.0.3
|
4
|
+
* New yard analysis
|
5
|
+
* Add code of conduct
|
6
|
+
* Fix bug with oid being erased in .dgit/sources
|
7
|
+
|
3
8
|
### Version 3.0.2
|
4
9
|
* Added version command
|
5
10
|
* `out` plugin is now able to furnish and clean folder dedicated for an analysis bound to a source
|
data/lib/dgit/core.rb
CHANGED
@@ -74,6 +74,11 @@ module Diggit
|
|
74
74
|
@repository = nil
|
75
75
|
end
|
76
76
|
|
77
|
+
def full_url
|
78
|
+
return @url if @oid.eql?(DEFAULT_BRANCH)
|
79
|
+
"#{@url}|#{@oid}"
|
80
|
+
end
|
81
|
+
|
77
82
|
def id
|
78
83
|
@url.id
|
79
84
|
end
|
@@ -386,7 +391,7 @@ module Diggit
|
|
386
391
|
# Save the journal to `.dgit/journal`
|
387
392
|
# @return [void]
|
388
393
|
def save_journal
|
389
|
-
File.open(config_path(DGIT_SOURCES), "w") { |f| @journal.sources.each { |source| f.puts(source.
|
394
|
+
File.open(config_path(DGIT_SOURCES), "w") { |f| @journal.sources.each { |source| f.puts(source.full_url) } }
|
390
395
|
Oj.to_file(config_path(DGIT_JOURNAL), @journal)
|
391
396
|
end
|
392
397
|
|
data/lib/dgit/version.rb
CHANGED
@@ -0,0 +1,119 @@
|
|
1
|
+
# This file is part of Diggit.
|
2
|
+
#
|
3
|
+
# Diggit is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# Diggit is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public License
|
14
|
+
# along with Diggit. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
#
|
16
|
+
# Copyright 2018 Jean-Rémy Falleri <jr.falleri@gmail.com>
|
17
|
+
|
18
|
+
require 'yaml'
|
19
|
+
require 'yard'
|
20
|
+
require 'levenshtein'
|
21
|
+
require 'gruff'
|
22
|
+
|
23
|
+
# List all yardoc duplications
|
24
|
+
class YardDup < Diggit::Analysis
|
25
|
+
require_addons 'out'
|
26
|
+
|
27
|
+
def initialize(options)
|
28
|
+
super(options)
|
29
|
+
end
|
30
|
+
|
31
|
+
def run
|
32
|
+
Log.info "processing yardoc of #{@source.id}"
|
33
|
+
out_dir = out.out_path_for_analysis(self)
|
34
|
+
FileUtils.mkdir_p(out_dir)
|
35
|
+
doc_hash = {}
|
36
|
+
YARD::Registry.clear
|
37
|
+
YARD::Registry.load(Dir["#{source.folder}/**/*.rb"], true)
|
38
|
+
objects = YARD::Registry.all(:method)
|
39
|
+
Log.info "processing #{objects.size} documented methods"
|
40
|
+
objects.each do |obj|
|
41
|
+
insert_to_map("@main #{obj.docstring}", doc_hash, obj) unless obj.docstring.empty?
|
42
|
+
obj.tags.each do |tag|
|
43
|
+
next if tag.nil?
|
44
|
+
tag_tokens = []
|
45
|
+
tag_tokens << "@#{tag.tag_name}" unless tag.tag_name.nil?
|
46
|
+
tag_tokens << tag.types.join(',') unless tag.types.nil? || tag.types.empty?
|
47
|
+
tag_tokens << tag.text unless tag.text.nil?
|
48
|
+
insert_to_map(tag_tokens.join(' '), doc_hash, obj)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
write_duplications(File.join(out_dir, "duplications.txt"), doc_hash)
|
52
|
+
puts_duplicated_methods(doc_hash)
|
53
|
+
plot_duplications(File.join(out_dir, "duplications.png"), doc_hash)
|
54
|
+
write_near_miss(File.join(out_dir, "near-miss.txt"), doc_hash)
|
55
|
+
end
|
56
|
+
|
57
|
+
def similarity(s1, s2)
|
58
|
+
d_norm = Levenshtein.distance(s1, s2).to_f / [s1.size.to_f, s2.size.to_f].max
|
59
|
+
1 - d_norm
|
60
|
+
end
|
61
|
+
|
62
|
+
def puts_duplicated_methods(doc_hash)
|
63
|
+
obj_hash = {}
|
64
|
+
doc_hash.each_value do |value|
|
65
|
+
value.each { |obj| obj_hash[obj] = true } if value.size > 2
|
66
|
+
end
|
67
|
+
Log.info "#{obj_hash.each_key.to_a.size} method involved in duplications"
|
68
|
+
end
|
69
|
+
|
70
|
+
def write_duplications(file, doc_hash)
|
71
|
+
File.open(file, 'w') do |f|
|
72
|
+
doc_hash.each { |key, value| f.write "#{key} (#{value.size}) #{value}\n" if value.size > 1 }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def plot_duplications(file, doc_hash)
|
77
|
+
dup_hash = {}
|
78
|
+
doc_hash.each_value do |value|
|
79
|
+
dup_hash[value.size] = if dup_hash.key?(value.size)
|
80
|
+
dup_hash[value.size] + 1
|
81
|
+
else
|
82
|
+
1
|
83
|
+
end
|
84
|
+
end
|
85
|
+
g = Gruff::Bar.new
|
86
|
+
g.hide_legend = true
|
87
|
+
dup_numbers = 2..dup_hash.each_key.to_a.max
|
88
|
+
dup_numbers.each do |dup|
|
89
|
+
if dup_hash.key?(dup)
|
90
|
+
g.data(dup, dup_hash[dup])
|
91
|
+
else
|
92
|
+
g.data(dup, 0)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
g.write(file)
|
96
|
+
end
|
97
|
+
|
98
|
+
def write_near_miss(file, doc_hash)
|
99
|
+
keys = doc_hash.each_key.to_a
|
100
|
+
return if keys.size < 2
|
101
|
+
File.open(file, 'w') do |f|
|
102
|
+
(0..(keys.size - 2)).each do |i|
|
103
|
+
key1 = keys[i]
|
104
|
+
key2 = keys[i + 1]
|
105
|
+
sim = similarity(key1, key2)
|
106
|
+
f.write "(#{sim}) #{key1} || #{key2}\n" if sim > 0.8
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def insert_to_map(key, hash, obj)
|
112
|
+
hash[key] = [] unless hash.key?(key)
|
113
|
+
hash[key] << "#{obj.file} #{obj.path}"
|
114
|
+
end
|
115
|
+
|
116
|
+
def clean
|
117
|
+
out.clean_analysis(self)
|
118
|
+
end
|
119
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diggit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Rémy Falleri
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2018-
|
14
|
+
date: 2018-02-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: formatador
|
@@ -211,6 +211,7 @@ files:
|
|
211
211
|
- plugins/analysis/conflict_merge.rb
|
212
212
|
- plugins/analysis/javadoc.rb
|
213
213
|
- plugins/analysis/words.rb
|
214
|
+
- plugins/analysis/yard_dup.rb
|
214
215
|
- spec/cli_spec.rb
|
215
216
|
- spec/core_spec.rb
|
216
217
|
- spec/dgit/plugins/addon/test_addon.rb
|
@@ -247,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
248
|
version: '0'
|
248
249
|
requirements: []
|
249
250
|
rubyforge_project:
|
250
|
-
rubygems_version: 2.7.
|
251
|
+
rubygems_version: 2.7.5
|
251
252
|
signing_key:
|
252
253
|
specification_version: 4
|
253
254
|
summary: A Git repository analysis tool.
|