diggit 3.0.3 → 3.0.5

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/bin/dgit +2 -0
  4. data/lib/dgit.rb +2 -0
  5. data/lib/dgit/core.rb +22 -8
  6. data/lib/dgit/entries.rb +9 -6
  7. data/lib/dgit/log.rb +2 -0
  8. data/lib/dgit/plugins.rb +8 -3
  9. data/lib/dgit/version.rb +3 -1
  10. data/plugins/addon/db.rb +4 -2
  11. data/plugins/addon/out.rb +4 -2
  12. data/plugins/addon/r.rb +2 -0
  13. data/plugins/addon/src_opt.rb +3 -1
  14. data/plugins/analysis/cloc.rb +3 -0
  15. data/plugins/analysis/cloc_per_file.rb +3 -0
  16. data/plugins/analysis/conflict_merge.rb +7 -1
  17. data/plugins/analysis/diff_extractor.rb +79 -0
  18. data/plugins/analysis/git_graph.rb +61 -0
  19. data/plugins/analysis/javadoc.rb +24 -17
  20. data/plugins/analysis/words.rb +2 -0
  21. data/plugins/analysis/yard_dup.rb +6 -2
  22. data/spec/cli_spec.rb +2 -0
  23. data/spec/core_spec.rb +2 -0
  24. data/spec/dgit/plugins/addon/test_addon.rb +2 -0
  25. data/spec/dgit/plugins/analysis/duplicate_analysis.rb +2 -0
  26. data/spec/dgit/plugins/analysis/my_module/duplicate_analysis.rb +2 -0
  27. data/spec/dgit/plugins/analysis/my_module/other_analysis.rb +2 -0
  28. data/spec/dgit/plugins/analysis/test_analysis.rb +2 -0
  29. data/spec/dgit/plugins/analysis/test_analysis_with_addon.rb +2 -0
  30. data/spec/dgit/plugins/analysis/test_analysis_with_clean_error.rb +2 -0
  31. data/spec/dgit/plugins/analysis/test_analysis_with_error.rb +2 -0
  32. data/spec/dgit/plugins/analysis/test_analysis_with_sources_options.rb +2 -0
  33. data/spec/dgit/plugins/join/test_join.rb +2 -0
  34. data/spec/dgit/plugins/join/test_join_with_addon.rb +2 -0
  35. data/spec/dgit/plugins/join/test_join_with_clean_error.rb +2 -0
  36. data/spec/dgit/plugins/join/test_join_with_error.rb +2 -0
  37. data/spec/spec_helper.rb +5 -3
  38. metadata +10 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c85e3eadbde6b35542b116a284a6c1b1bba40f0e92dc902c407deb3098d26c02
4
- data.tar.gz: c941389bb90f76bc46ac997a574220dea844034692f080134b73db31f9e0feea
3
+ metadata.gz: 81fec8c5e4a7863093a7567a1a8f9264f6c64103dc2b4cbe91627fd17336af72
4
+ data.tar.gz: 99bb44395681d891bdfaf95e20091c5c5a1de5a27f686fc980b531d6ebf51a19
5
5
  SHA512:
6
- metadata.gz: a411fab663670f3662124714fb17eb40b8e5f5d715b6919ccafa1f257884f791c756ed03923ef01aaad67c3718c924e6efd79ee462ca38ab9d0bf3b36ec50d90
7
- data.tar.gz: 50845221483a94d5a8527f532e9a951f28e991ad7497ff4ddf83e7b6002f933bb36e534daf0e1ed5ab54b654f9963817b123650c14212baf5501a08faddb180e
6
+ metadata.gz: 0ab104838efaf730b13437caaa57be9ccee935b2525fbdad726d609d9952c4b3c0db9d5ab993d0dff7e4b0045e0439b7531d60fe10ca589fc11fb86f65bb9195
7
+ data.tar.gz: 9db2fb9809038b59cc3f4493d10dbf9d8962f2710b294ede584c1bfb5cbf511751e115653a0126b5cff4601e8baedb475a723c6948eaaa6d1fbf6e30776bd6a3
@@ -1,5 +1,14 @@
1
1
  # Changelog of Diggit
2
2
 
3
+ ### Version 3.0.5
4
+ * Dummy version to fix travis errors
5
+
6
+ ### Version 3.0.4
7
+ * New graph analysis
8
+ * New diff extractor analysis
9
+ * Updated dependencies
10
+ * Upgrade min ruby version to 2.4
11
+
3
12
  ### Version 3.0.3
4
13
  * New yard analysis
5
14
  * Add code of conduct
data/bin/dgit CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  #
3
5
  # This file is part of Diggit.
4
6
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -41,6 +43,7 @@ class String
41
43
  # @return [String]
42
44
  def camel_case
43
45
  return self if self !~ /_/ && self =~ /[A-Z]+.*/
46
+
44
47
  split('_').map(&:capitalize).join
45
48
  end
46
49
 
@@ -62,7 +65,7 @@ end
62
65
 
63
66
  module Diggit
64
67
  class Source
65
- DEFAULT_BRANCH = "origin/master".freeze
68
+ DEFAULT_BRANCH = "origin/master"
66
69
 
67
70
  attr_reader :url, :repository, :entry, :oid
68
71
 
@@ -76,6 +79,7 @@ module Diggit
76
79
 
77
80
  def full_url
78
81
  return @url if @oid.eql?(DEFAULT_BRANCH)
82
+
79
83
  "#{@url}|#{@oid}"
80
84
  end
81
85
 
@@ -100,6 +104,7 @@ module Diggit
100
104
 
101
105
  def load_repository
102
106
  raise "Source not cloned #{url}." if @entry.new?
107
+
103
108
  @repository = Rugged::Repository.new(folder)
104
109
  @repository.checkout(@oid, { strategy: :force })
105
110
  end
@@ -123,10 +128,12 @@ module Diggit
123
128
 
124
129
  def sources_by_ids(*ids)
125
130
  return sources if ids.empty?
131
+
126
132
  source_array = sources
127
133
  result = []
128
134
  ids.each do |id|
129
135
  raise "No such source index #{id}." if id >= source_array.length
136
+
130
137
  result << source_array[id]
131
138
  end
132
139
  result
@@ -184,6 +191,7 @@ module Diggit
184
191
 
185
192
  def get_analyses(*names)
186
193
  return analyses if names.empty?
194
+
187
195
  analyses.select { |a| names.include?(a.simple_name) }
188
196
  end
189
197
 
@@ -208,6 +216,7 @@ module Diggit
208
216
 
209
217
  def get_joins(*names)
210
218
  return joins if names.empty?
219
+
211
220
  joins.select { |j| joins.include?(j.simple_name) }
212
221
  end
213
222
 
@@ -237,6 +246,7 @@ module Diggit
237
246
  plugin = search_plugin(name, type)
238
247
  raise "Plugin #{name} not found." unless plugin
239
248
  return plugin.new(Dig.it.options) if instance
249
+
240
250
  plugin
241
251
  end
242
252
 
@@ -261,6 +271,7 @@ module Diggit
261
271
  plugins = ObjectSpace.each_object(Class).select { |c| c < base_class && c.simple_name == name }
262
272
 
263
273
  raise "No plugin #{name} of kind #{type} found." if plugins.empty?
274
+
264
275
  warn "Ambiguous plugin name: several plugins of kind #{type} named #{name} were found." if plugins.size > 1
265
276
 
266
277
  @plugins[name] = plugins[0]
@@ -301,11 +312,11 @@ module Diggit
301
312
  # @!attribute [r] plugin_loader
302
313
  # @return [PluginLoader] utility classes to load plugins.
303
314
  class Dig
304
- DGIT_FOLDER = ".dgit".freeze
305
- DGIT_SOURCES = "sources".freeze
306
- DGIT_CONFIG = "config".freeze
307
- DGIT_OPTIONS = "options".freeze
308
- DGIT_JOURNAL = "journal".freeze
315
+ DGIT_FOLDER = ".dgit"
316
+ DGIT_SOURCES = "sources"
317
+ DGIT_CONFIG = "config"
318
+ DGIT_OPTIONS = "options"
319
+ DGIT_JOURNAL = "journal"
309
320
 
310
321
  private_constant :DGIT_SOURCES, :DGIT_CONFIG, :DGIT_OPTIONS, :DGIT_JOURNAL
311
322
 
@@ -317,6 +328,7 @@ module Diggit
317
328
  # @return [Dig] the instance.
318
329
  def self.it
319
330
  raise "Diggit has not been initialized." if @diggit.nil?
331
+
320
332
  @diggit
321
333
  end
322
334
 
@@ -348,6 +360,7 @@ module Diggit
348
360
  end
349
361
  FileUtils.mkdir(File.expand_path('sources', folder)) unless File.exist?(File.expand_path('sources', folder))
350
362
  return if File.exist?(File.expand_path("plugins", folder))
363
+
351
364
  FileUtils.mkdir_p(File.expand_path("plugins", folder))
352
365
  FileUtils.mkdir_p(File.expand_path("plugins/analysis", folder))
353
366
  FileUtils.mkdir_p(File.expand_path("plugins/addon", folder))
@@ -373,6 +386,7 @@ module Diggit
373
386
  # @return [Dig] a diggit object.
374
387
  def initialize(folder)
375
388
  raise "Folder #{folder} is not a diggit folder." unless File.exist?(File.expand_path(DGIT_FOLDER, folder))
389
+
376
390
  @plugin_loader = PluginLoader.instance
377
391
  @folder = folder
378
392
  end
@@ -471,11 +485,11 @@ module Diggit
471
485
  private
472
486
 
473
487
  def clean_mode?(mode)
474
- mode == :rerun || mode == :clean
488
+ %i[rerun clean].include?(mode)
475
489
  end
476
490
 
477
491
  def run_mode?(mode)
478
- mode == :rerun || mode == :run
492
+ %i[rerun run].include?(mode)
479
493
  end
480
494
 
481
495
  def clean(runnable, placeholder)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -24,10 +26,10 @@ module Diggit
24
26
  attr_reader :error
25
27
 
26
28
  # Set the error of the entry.
27
- # @param e [Exception, nil] the error, to indicate an absence of error, pass +nil+.
29
+ # @param err [Exception, nil] the error, to indicate an absence of error, pass +nil+.
28
30
  # @return [void]
29
- def error=(e)
30
- @error = e.nil? ? nil : ErrorEntry.new(e)
31
+ def error=(err)
32
+ @error = err.nil? ? nil : ErrorEntry.new(err)
31
33
  end
32
34
  end
33
35
 
@@ -57,9 +59,9 @@ module Diggit
57
59
  # @return [Boolean]
58
60
  def has?(runnable_or_string, state = :all)
59
61
  name = retrieve_name(runnable_or_string)
60
- return @performed.count { |e| e.name == name } > 0 if state == :performed
61
- return @canceled.count { |e| e.name == name } > 0 if state == :canceled
62
- return (@performed + @canceled).count { |e| e.name == name } > 0 if state == :all
62
+ return @performed.count { |e| e.name == name }.positive? if state == :performed
63
+ return @canceled.count { |e| e.name == name }.positive? if state == :canceled
64
+ return (@performed + @canceled).count { |e| e.name == name }.positive? if state == :all
63
65
  end
64
66
 
65
67
  # Remove a runnable from all the entries.
@@ -75,6 +77,7 @@ module Diggit
75
77
 
76
78
  def retrieve_name(runnable_or_string)
77
79
  return runnable_or_string if runnable_or_string.is_a? String
80
+
78
81
  runnable_or_string.name
79
82
  end
80
83
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -43,12 +45,13 @@ module Diggit
43
45
  end
44
46
 
45
47
  # Returns the value of a plugin option
46
- # @param ns [Symbol] the name of the option's namespace
48
+ # @param namespace [Symbol] the name of the option's namespace
47
49
  # @param opt [Symbol] the name of the option
48
50
  # @param default [Object] the default value
49
51
  # @return [Object]
50
- def read_option(ns, opt, default)
51
- return @options[ns][opt] if @options.key?(ns) && @options[ns].key?(opt)
52
+ def read_option(namespace, opt, default)
53
+ return @options[namespace][opt] if @options.key?(namespace) && @options[namespace].key?(opt)
54
+
52
55
  default
53
56
  end
54
57
  end
@@ -102,6 +105,7 @@ module Diggit
102
105
  def self.required_addons
103
106
  base_addons = superclass < Runnable ? superclass.required_addons : []
104
107
  return base_addons if @required_addons.nil?
108
+
105
109
  base_addons + @required_addons
106
110
  end
107
111
  end
@@ -149,6 +153,7 @@ module Diggit
149
153
 
150
154
  def self.required_analyses
151
155
  return [] if @required_analyses.nil?
156
+
152
157
  @required_analyses
153
158
  end
154
159
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -16,5 +18,5 @@
16
18
  # Copyright 2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
17
19
 
18
20
  module Diggit
19
- VERSION = '3.0.3'.freeze
21
+ VERSION = '3.0.5'
20
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -22,8 +24,8 @@ require 'mongo'
22
24
  # @!attribute [r] client
23
25
  # @return [Mongo::Client] the mongodb client object.
24
26
  class Db < Diggit::Addon
25
- DEFAULT_SERVER = '127.0.0.1:27017'.freeze
26
- DEFAULT_DB = 'diggit'.freeze
27
+ DEFAULT_SERVER = '127.0.0.1:27017'
28
+ DEFAULT_DB = 'diggit'
27
29
 
28
30
  attr_reader :client
29
31
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -25,8 +27,8 @@
25
27
  class Out < Diggit::Addon
26
28
  attr_reader :out, :tmp
27
29
 
28
- DEFAULT_OUT = 'out'.freeze
29
- DEFAULT_TMP = 'tmp'.freeze
30
+ DEFAULT_OUT = 'out'
31
+ DEFAULT_TMP = 'tmp'
30
32
 
31
33
  def initialize(*args)
32
34
  super
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -26,7 +28,7 @@
26
28
  # }
27
29
  # ```
28
30
  class SrcOpt < Diggit::Addon
29
- SOURCES_OPTIONS_FILE = 'sources_options'.freeze
31
+ SOURCES_OPTIONS_FILE = 'sources_options'
30
32
 
31
33
  def initialize(*args)
32
34
  super
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -32,6 +34,7 @@ class Cloc < Diggit::Analysis
32
34
  repo.checkout(c.oid, { strategy: %i[force remove_untracked] })
33
35
  cloc = `cloc #{@source.folder} --progress-rate=0 --quiet --yaml`
34
36
  next if cloc.empty?
37
+
35
38
  yaml = YAML.safe_load(cloc.lines[2..-1].join)
36
39
  yaml.delete('header')
37
40
  output = { source: @source.url, commit: c.oid, cloc: yaml }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -26,6 +28,7 @@ class ClocPerFile < Diggit::Analysis
26
28
  folder = File.expand_path(@source.folder)
27
29
  cloc = `cloc #{folder} --progress-rate=0 --quiet --by-file --yaml --script-lang=Python,python`
28
30
  return if cloc.empty?
31
+
29
32
  yaml = YAML.safe_load(cloc.lines[2..-1].join)
30
33
  yaml.delete('header')
31
34
  yaml.delete('SUM')
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -25,7 +27,7 @@ require 'yaml'
25
27
  class ConflictMerge < Diggit::Analysis
26
28
  require_addons 'out'
27
29
 
28
- DIFF3 = 'diff3'.freeze
30
+ DIFF3 = 'diff3'
29
31
 
30
32
  def initialize(options)
31
33
  super(options)
@@ -39,10 +41,12 @@ class ConflictMerge < Diggit::Analysis
39
41
  out_dir = out.out_path_for_analysis(self, commit.oid)
40
42
  parents = commit.parents
41
43
  next unless parents.size > 1
44
+
42
45
  left = parents[0]
43
46
  right = parents[1]
44
47
  base_oid = repo.merge_base(left, right)
45
48
  next if base_oid.nil?
49
+
46
50
  base = repo.lookup(base_oid)
47
51
  %w[m b l r].each { |p| FileUtils.mkdir_p(File.join(out_dir, p)) }
48
52
  populate_merge_directory(out_dir, commit, base, left, right)
@@ -52,6 +56,7 @@ class ConflictMerge < Diggit::Analysis
52
56
  def populate_merge_directory(out_dir, commit, base, left, right)
53
57
  commit.tree.walk_blobs(:preorder) do |r, e|
54
58
  next if base.tree.get_entry_by_oid(e[:oid])
59
+
55
60
  oids = find_oids(r, e[:name], base, left, right)
56
61
  next if oids[:left].nil? || oids[:right].nil? # This would result in a trivial merge
57
62
 
@@ -92,6 +97,7 @@ class ConflictMerge < Diggit::Analysis
92
97
  def find_oid(tree, components, name)
93
98
  components.each { |c| tree = repo.lookup(tree[c][:oid]) unless tree.nil? || tree[c].nil? }
94
99
  return nil if tree.nil? || tree[name].nil?
100
+
95
101
  tree[name][:oid]
96
102
  end
97
103
 
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is part of Diggit.
4
+ #
5
+ # Diggit is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Diggit is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Diggit. If not, see <http://www.gnu.org/licenses/>.
17
+ #
18
+ # Copyright 2019 Jean-Rémy Falleri <jr.falleri@gmail.com>
19
+
20
+ require 'yaml'
21
+
22
+ # List all diffs from a repository.
23
+ class DiffExtractor < Diggit::Analysis
24
+ require_addons 'out'
25
+
26
+ ALLOWED_EXTENSIONS = ['.java', '.rb', '.js'].freeze
27
+
28
+ def initialize(options)
29
+ super(options)
30
+ end
31
+
32
+ def run
33
+ walker = Rugged::Walker.new(repo)
34
+ walker.sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE)
35
+ walker.push(repo.head.name)
36
+ walker.each do |commit|
37
+ out_dir = out.out_path_for_analysis(self, commit.oid)
38
+ parents = commit.parents
39
+ next unless parents.size == 1
40
+
41
+ parent = parents[0]
42
+ populate_diff_directory(out_dir, commit, parent)
43
+ end
44
+ end
45
+
46
+ def populate_diff_directory(out_dir, commit, parent)
47
+ directories_created = false
48
+ diff = parent.diff(commit)
49
+ diff.each_delta do |delta_entry|
50
+ next unless delta_entry.status == :modified
51
+ next unless ALLOWED_EXTENSIONS.include?(File.extname(delta_entry.new_file[:path]))
52
+
53
+ unless directories_created
54
+ FileUtils.mkdir_p(File.join(out_dir, 'src'))
55
+ FileUtils.mkdir_p(File.join(out_dir, 'dst'))
56
+ directories_created = true
57
+ end
58
+ flat_name = flatten_name(delta_entry.new_file[:path])
59
+ write(delta_entry.new_file[:oid], flat_name, File.join(out_dir, 'src'))
60
+ write(delta_entry.old_file[:oid], flat_name, File.join(out_dir, 'dst'))
61
+ end
62
+ end
63
+
64
+ def write(oid, name, out_dir)
65
+ write_file repo.lookup(oid).content, name, out_dir
66
+ end
67
+
68
+ def write_file(data, name, out_dir)
69
+ File.write(File.join(out_dir, name), data)
70
+ end
71
+
72
+ def flatten_name(name)
73
+ name.gsub(/_/, '__').gsub(%r{/}, '_')
74
+ end
75
+
76
+ def clean
77
+ out.clean_analysis(self)
78
+ end
79
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is part of Diggit.
4
+ #
5
+ # Diggit is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU Lesser General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # Diggit is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public License
16
+ # along with Diggit. If not, see <http://www.gnu.org/licenses/>.
17
+ #
18
+ # Copyright 2018 Jean-Rémy Falleri <jr.falleri@gmail.com>
19
+
20
+ class GitGraph < Diggit::Analysis
21
+ require_addons 'out'
22
+
23
+ def initialize(options)
24
+ super(options)
25
+ end
26
+
27
+ def run
28
+ FileUtils.mkdir_p(out.out_path_for_analysis(self))
29
+ file = out.out_path_for_analysis(self, "graph.dot")
30
+ File.open(file, 'w') do |f|
31
+ f.puts "digraph repository {"
32
+ f.puts "\tnode [shape=rect, color=lightblue2, style=filled];"
33
+ append_dot_nodes(f)
34
+ append_dot_links(f)
35
+ f.puts "}"
36
+ end
37
+ end
38
+
39
+ def append_dot_nodes(file)
40
+ init_walker.each do |commit|
41
+ file.puts "\tc_#{commit.oid} [label=\"#{commit.oid.to_s[0..6]}\"];"
42
+ end
43
+ end
44
+
45
+ def append_dot_links(file)
46
+ init_walker.each do |commit|
47
+ commit.parents.each { |parent| file.puts "\tc_#{commit.oid} -> c_#{parent.oid};" }
48
+ end
49
+ end
50
+
51
+ def init_walker
52
+ walker = Rugged::Walker.new(repo)
53
+ walker.sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE)
54
+ walker.push(repo.head.name)
55
+ walker
56
+ end
57
+
58
+ def clean
59
+ out.clean_analysis(self)
60
+ end
61
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -77,10 +79,11 @@ class Javadoc < Diggit::Analysis
77
79
 
78
80
  m.xpath("MarkerAnnotation/SimpleName/@label").each do |k|
79
81
  next unless k.to_s.casecmp("override")
82
+
80
83
  javadoc['override'] = true
81
84
  override_count += 1
82
85
 
83
- if m.xpath("Javadoc/TagElement/TagElement[@label='@inheritDoc']").count > 0
86
+ if m.xpath("Javadoc/TagElement/TagElement[@label='@inheritDoc']").count.positive?
84
87
  javadoc['inheritDoc'] = true
85
88
  override_inherit_count += 1
86
89
  end
@@ -100,20 +103,24 @@ class Javadoc < Diggit::Analysis
100
103
  res
101
104
  end
102
105
 
103
- def method_id(m)
106
+ def method_id(method)
104
107
  res = ""
105
- modifiers = m.xpath("Modifier/@label")
108
+ modifiers = method.xpath("Modifier/@label")
106
109
  res += "#{modifiers} " unless modifiers.empty?
107
- res += "#{type(m)} #{m.at_xpath('SimpleName/@label')}("
108
- params = m.xpath("SingleVariableDeclaration").map { |p| "#{type(p)} #{p.at_xpath('SimpleName/@label')}" }.join(',')
110
+ res += "#{type(method)} #{method.at_xpath('SimpleName/@label')}("
111
+ param_list = method.xpath("SingleVariableDeclaration").map do |p|
112
+ "#{type(p)} #{p.at_xpath('SimpleName/@label')}"
113
+ end
114
+ params = param_list.join(',')
109
115
  res += "#{params})"
110
116
  res
111
117
  end
112
118
 
113
- def type(e)
114
- return e.at_xpath('SimpleType/@label').to_s unless e.at_xpath('SimpleType').nil?
115
- return e.at_xpath('PrimitiveType/@label').to_s unless e.at_xpath('PrimitiveType').nil?
116
- return e.at_xpath('ArrayType/@label').to_s unless e.at_xpath('ArrayType').nil?
119
+ def type(element)
120
+ return element.at_xpath('SimpleType/@label').to_s unless element.at_xpath('SimpleType').nil?
121
+ return element.at_xpath('PrimitiveType/@label').to_s unless element.at_xpath('PrimitiveType').nil?
122
+ return element.at_xpath('ArrayType/@label').to_s unless element.at_xpath('ArrayType').nil?
123
+
117
124
  ""
118
125
  end
119
126
 
@@ -130,9 +137,9 @@ class Javadoc < Diggit::Analysis
130
137
  doc
131
138
  end
132
139
 
133
- def get_params(m)
140
+ def get_params(method)
134
141
  data = {}
135
- m.xpath("Javadoc/TagElement[@label='@param']").each do |p|
142
+ method.xpath("Javadoc/TagElement[@label='@param']").each do |p|
136
143
  data[p.at_xpath("SimpleName/@label").to_s] = [] if data[p.at_xpath("SimpleName/@label").to_s].nil?
137
144
 
138
145
  data[p.at_xpath("SimpleName/@label").to_s].push(p.xpath("TextElement/@label").to_s)
@@ -140,20 +147,20 @@ class Javadoc < Diggit::Analysis
140
147
  data
141
148
  end
142
149
 
143
- def get_links(m)
144
- m.xpath("Javadoc/TagElement/TagElement[@label='@link']").map { |p| p.xpath('QualifiedName/@label').to_s }
150
+ def get_links(method)
151
+ method.xpath("Javadoc/TagElement/TagElement[@label='@link']").map { |p| p.xpath('QualifiedName/@label').to_s }
145
152
  end
146
153
 
147
- def get_throws(m)
154
+ def get_throws(method)
148
155
  throws = {}
149
- m.xpath("Javadoc/TagElement[@label='@throws']").each do |p|
156
+ method.xpath("Javadoc/TagElement[@label='@throws']").each do |p|
150
157
  throws[p.at_xpath("SimpleName/@label").to_s] = p.xpath("TextElement/@label").to_s
151
158
  end
152
159
  throws
153
160
  end
154
161
 
155
- def get_see(m)
156
- m.xpath("Javadoc/TagElement[@label='@see']/MethodRef").map { |p| p.xpath('SimpleName/@label').to_s }
162
+ def get_see(method)
163
+ method.xpath("Javadoc/TagElement[@label='@see']/MethodRef").map { |p| p.xpath('SimpleName/@label').to_s }
157
164
  end
158
165
 
159
166
  def count_classes(doc)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -41,6 +43,7 @@ class YardDup < Diggit::Analysis
41
43
  insert_to_map("@main #{obj.docstring}", doc_hash, obj) unless obj.docstring.empty?
42
44
  obj.tags.each do |tag|
43
45
  next if tag.nil?
46
+
44
47
  tag_tokens = []
45
48
  tag_tokens << "@#{tag.tag_name}" unless tag.tag_name.nil?
46
49
  tag_tokens << tag.types.join(',') unless tag.types.nil? || tag.types.empty?
@@ -54,8 +57,8 @@ class YardDup < Diggit::Analysis
54
57
  write_near_miss(File.join(out_dir, "near-miss.txt"), doc_hash)
55
58
  end
56
59
 
57
- def similarity(s1, s2)
58
- d_norm = Levenshtein.distance(s1, s2).to_f / [s1.size.to_f, s2.size.to_f].max
60
+ def similarity(left, right)
61
+ d_norm = Levenshtein.distance(left, right).to_f / [left.size.to_f, right.size.to_f].max
59
62
  1 - d_norm
60
63
  end
61
64
 
@@ -98,6 +101,7 @@ class YardDup < Diggit::Analysis
98
101
  def write_near_miss(file, doc_hash)
99
102
  keys = doc_hash.each_key.to_a
100
103
  return if keys.size < 2
104
+
101
105
  File.open(file, 'w') do |f|
102
106
  (0..(keys.size - 2)).each do |i|
103
107
  key1 = keys[i]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file is part of Diggit.
2
4
  #
3
5
  # Diggit is free software: you can redistribute it and/or modify
@@ -20,9 +22,9 @@ Coveralls.wear!
20
22
 
21
23
  require_relative('../lib/dgit')
22
24
 
23
- TEST_URL = 'https://github.com/jrfaller/test-git.git|0a8267929977bf800ababb6ae1bf3b0ed08827a4'.freeze
24
- TEST_URL_INFO1 = 'https://github.com/jrfaller/test-git.git'.freeze
25
- TEST_URL_INFO2 = '0a8267929977bf800ababb6ae1bf3b0ed08827a4'.freeze
25
+ TEST_URL = 'https://github.com/jrfaller/test-git.git|0a8267929977bf800ababb6ae1bf3b0ed08827a4'
26
+ TEST_URL_INFO1 = 'https://github.com/jrfaller/test-git.git'
27
+ TEST_URL_INFO2 = '0a8267929977bf800ababb6ae1bf3b0ed08827a4'
26
28
 
27
29
  RSpec.configure do |config|
28
30
  config.before(:all) do
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.3
4
+ version: 3.0.5
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-02-13 00:00:00.000000000 Z
14
+ date: 2019-11-12 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: formatador
@@ -109,14 +109,14 @@ dependencies:
109
109
  requirements:
110
110
  - - "~>"
111
111
  - !ruby/object:Gem::Version
112
- version: '11'
112
+ version: '13'
113
113
  type: :development
114
114
  prerelease: false
115
115
  version_requirements: !ruby/object:Gem::Requirement
116
116
  requirements:
117
117
  - - "~>"
118
118
  - !ruby/object:Gem::Version
119
- version: '11'
119
+ version: '13'
120
120
  - !ruby/object:Gem::Dependency
121
121
  name: redcarpet
122
122
  requirement: !ruby/object:Gem::Requirement
@@ -174,7 +174,7 @@ dependencies:
174
174
  version: '0'
175
175
  - - ">="
176
176
  - !ruby/object:Gem::Version
177
- version: 0.9.11
177
+ version: 0.9.20
178
178
  type: :development
179
179
  prerelease: false
180
180
  version_requirements: !ruby/object:Gem::Requirement
@@ -184,7 +184,7 @@ dependencies:
184
184
  version: '0'
185
185
  - - ">="
186
186
  - !ruby/object:Gem::Version
187
- version: 0.9.11
187
+ version: 0.9.20
188
188
  description: Diggit is an agile tool that allows you to analyze git repositories.
189
189
  email: jr.falleri@gmail.com
190
190
  executables:
@@ -209,6 +209,8 @@ files:
209
209
  - plugins/analysis/cloc.rb
210
210
  - plugins/analysis/cloc_per_file.rb
211
211
  - plugins/analysis/conflict_merge.rb
212
+ - plugins/analysis/diff_extractor.rb
213
+ - plugins/analysis/git_graph.rb
212
214
  - plugins/analysis/javadoc.rb
213
215
  - plugins/analysis/words.rb
214
216
  - plugins/analysis/yard_dup.rb
@@ -240,15 +242,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
240
242
  requirements:
241
243
  - - "~>"
242
244
  - !ruby/object:Gem::Version
243
- version: '2.2'
245
+ version: '2.4'
244
246
  required_rubygems_version: !ruby/object:Gem::Requirement
245
247
  requirements:
246
248
  - - ">="
247
249
  - !ruby/object:Gem::Version
248
250
  version: '0'
249
251
  requirements: []
250
- rubyforge_project:
251
- rubygems_version: 2.7.5
252
+ rubygems_version: 3.0.3
252
253
  signing_key:
253
254
  specification_version: 4
254
255
  summary: A Git repository analysis tool.