diggit 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # encoding: utf-8
2
3
  #
3
4
  # This file is part of Diggit.
@@ -20,7 +21,7 @@
20
21
 
21
22
  # Manages options that are specific to a given source
22
23
  class SrcOpt < Diggit::Addon
23
- SOURCES_OPTIONS_FILE = 'sources_options'
24
+ SOURCES_OPTIONS_FILE = 'sources_options'.freeze
24
25
 
25
26
  def initialize(*args)
26
27
  super
@@ -0,0 +1,118 @@
1
+ # encoding: utf-8
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 2016 Jean-Rémy Falleri <jr.falleri@gmail.com>
19
+ # Copyright 2016 Floréal Morandat
20
+ # Copyright 2016 Benjamin Benni
21
+
22
+ require 'yaml'
23
+
24
+ class ConflictMerge < Diggit::Analysis
25
+ require_addons 'out'
26
+
27
+ DIFF3 = 'diff3'.freeze
28
+
29
+ def initialize(options)
30
+ super(options)
31
+ end
32
+
33
+ def run
34
+ walker = Rugged::Walker.new(repo)
35
+ walker.sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE)
36
+ walker.push(repo.head.name)
37
+ walker.each do |commit|
38
+ out_dir = out.out_path(source.id, commit.oid)
39
+ parents = commit.parents
40
+ next unless parents.size > 1
41
+ left = parents[0]
42
+ right = parents[1]
43
+ next if repo.merge_base(left, right).nil?
44
+ base = repo.lookup(repo.merge_base(left, right))
45
+ %w(m b l r).each { |p| FileUtils.mkdir_p(File.join(out_dir, p)) }
46
+ populate_merge_directory(out_dir, commit, base, left, right)
47
+ end
48
+ end
49
+
50
+ def populate_merge_directory(out_dir, commit, base, left, right)
51
+ commit.tree.walk(:preorder) do |r, e|
52
+ next if e[:type] == :tree
53
+ next if base.tree.get_entry_by_oid(e[:oid])
54
+ oids = find_oids(r, e[:name], base, left, right)
55
+ next if oids[:left].nil? || oids[:right].nil? # This would result in a trivial merge
56
+
57
+ fname = flatten_name(r + e[:name])
58
+ write(e[:oid], fname, out_dir, 'm')
59
+ if oids[:base].nil?
60
+ write_file("", fname, out_dir, 'b') # Create a fake file in base
61
+ else
62
+ write(oids[:base], fname, out_dir, 'b')
63
+ end
64
+ write(oids[:left], fname, out_dir, 'l')
65
+ write(oids[:right], fname, out_dir, 'r')
66
+
67
+ write_commit_log(out_dir, commit, base, left, right)
68
+
69
+ diff_file = File.join(out_dir, "#{fname}.diff3")
70
+ File.unlink diff_file unless system(
71
+ DIFF3,
72
+ "-m",
73
+ File.join(out_dir, 'l', fname),
74
+ File.join(out_dir, 'b', fname),
75
+ File.join(out_dir, 'r', fname),
76
+ out: diff_file
77
+ ) == false
78
+ end
79
+ end
80
+
81
+ def find_oids(root, name, base, left, right)
82
+ components = root == "" ? [] : root.split(File::SEPARATOR)
83
+ {
84
+ base: find_oid(base.tree, components, name),
85
+ left: find_oid(left.tree, components, name),
86
+ right: find_oid(right.tree, components, name)
87
+ }
88
+ end
89
+
90
+ def find_oid(tree, components, name)
91
+ components.each { |c| tree = repo.lookup(tree[c][:oid]) }
92
+ tree[name][:oid]
93
+ rescue
94
+ nil
95
+ end
96
+
97
+ def write(oid, name, *kind)
98
+ write_file repo.lookup(oid).content, name, *kind
99
+ end
100
+
101
+ def write_file(data, name, *kind)
102
+ File.write(File.join(kind, name), data)
103
+ end
104
+
105
+ def write_commit_log(out_dir, *commits)
106
+ File.open(File.join(out_dir, "commits.txt"), "w") do |file|
107
+ commits.each { |c| file.write("#{c.oid}\n") }
108
+ end
109
+ end
110
+
111
+ def flatten_name(name)
112
+ name.gsub(/_/, '__').gsub(%r{/}, '_')
113
+ end
114
+
115
+ def clean
116
+ out.clean
117
+ end
118
+ end
@@ -17,27 +17,169 @@
17
17
  #
18
18
  # Copyright 2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
19
19
 
20
- require 'jsonpath'
20
+ require 'nokogiri'
21
+ require 'oj'
21
22
 
22
23
  class Javadoc < Diggit::Analysis
24
+ require_addons 'out'
25
+
26
+ VALID_TYPES = %w(
27
+ root CompilationUnit TypeDeclaration FieldDeclaration MethodDeclaration SimpleName QualifiedName
28
+ QualifiedName SimpleType PrimitiveType ArrayType SingleVariableDeclaration VariableDeclarationFragment
29
+ Modifier Javadoc TagElement TextElement MarkerAnnotation MethodRef
30
+ ).freeze
31
+
23
32
  def initialize(options)
24
33
  super(options)
25
34
  end
26
35
 
27
36
  def run
28
- path_md = JsonPath.new("$..*[?(@.typeLabel == 'MethodDeclaration')]")
29
- files = Dir['**/*.java']
30
- files.each do |file|
31
- puts file
32
- json = `gumtree parse "#{file}"`
33
- md = path_md.on(json)
34
- md.each do |m|
35
- puts m
36
- exit
37
+ files = Dir["#{@source.folder}/src/main/java/**/*.java"]
38
+ puts "#{files.length} files to process"
39
+ db = {}
40
+
41
+ files.each do |f|
42
+ puts "processing #{f}"
43
+ xml = `gumtree parse -f XML "#{f}"`
44
+ doc = strip(Nokogiri::XML(xml))
45
+ db[f] = index_methods(doc)
46
+ end
47
+
48
+ Oj.to_file("#{out.out}/#{@source.id}.json", db)
49
+ end
50
+
51
+ def index_methods(doc)
52
+ res = {}
53
+
54
+ override_count = 0
55
+ override_inherit_count = 0
56
+
57
+ # Partie Metrics
58
+
59
+ data = {}
60
+ data["nb_class"] = count_classes(doc)
61
+ data["nb_method"] = count_methods(doc)
62
+ data["nb_class_commented"] = count_commented_classes(doc)
63
+ data["nb_method_commented"] = count_commented_methods(doc)
64
+
65
+ res["metrics"] = data
66
+
67
+ # Partie methodes
68
+ res["methods"] = []
69
+
70
+ doc.xpath("//MethodDeclaration").each do |m|
71
+ id = method_id(m)
72
+ javadoc = {}
73
+ javadoc['main'] = m.xpath("Javadoc/TagElement[not(@label)]/TextElement/@label").to_s
74
+ javadoc['params'] = {}
75
+
76
+ javadoc['override'] = false
77
+ javadoc['inheritDoc'] = false
78
+
79
+ m.xpath("MarkerAnnotation/SimpleName/@label").each do |k|
80
+ next unless k.to_s.casecmp("override")
81
+ javadoc['override'] = true
82
+ override_count += 1
83
+
84
+ if m.xpath("Javadoc/TagElement/TagElement[@label='@inheritDoc']").count > 0
85
+ javadoc['inheritDoc'] = true
86
+ override_inherit_count += 1
87
+ end
37
88
  end
89
+
90
+ javadoc["params"] = get_params(m)
91
+ javadoc["see"] = get_see(m)
92
+ javadoc["throws"] = get_throws(m)
93
+ javadoc["links"] = get_links(m)
94
+ javadoc['return'] = m.xpath("Javadoc/TagElement[@label='@return']/TextElement/@label").to_s
95
+
96
+ res["methods"] << [id, javadoc]
97
+ res["metrics"]["nb_method_override"] = override_count
98
+ res["metrics"]["nb_method_override_inheritdoc"] = override_inherit_count
38
99
  end
100
+
101
+ res
102
+ end
103
+
104
+ def method_id(m)
105
+ res = ""
106
+ modifiers = m.xpath("Modifier/@label")
107
+ res += "#{modifiers} " unless modifiers.empty?
108
+ res += "#{type(m)} #{m.at_xpath('SimpleName/@label')}("
109
+ params = m.xpath("SingleVariableDeclaration").map { |p| "#{type(p)} #{p.at_xpath('SimpleName/@label')}" }.join(',')
110
+ res += "#{params})"
111
+ res
112
+ end
113
+
114
+ def type(e)
115
+ return e.at_xpath('SimpleType/@label').to_s unless e.at_xpath('SimpleType').nil?
116
+ return e.at_xpath('PrimitiveType/@label').to_s unless e.at_xpath('PrimitiveType').nil?
117
+ return e.at_xpath('ArrayType/@label').to_s unless e.at_xpath('ArrayType').nil?
118
+ ""
119
+ end
120
+
121
+ def strip(doc)
122
+ active = []
123
+ doc.children.each do |c|
124
+ if VALID_TYPES.include?(c.name)
125
+ active << c
126
+ else
127
+ c.unlink
128
+ end
129
+ end
130
+ active.each { |a| strip(a) }
131
+ doc
132
+ end
133
+
134
+ def get_params(m)
135
+ data = {}
136
+ m.xpath("Javadoc/TagElement[@label='@param']").each do |p|
137
+ if data[p.at_xpath("SimpleName/@label").to_s].nil?
138
+ data[p.at_xpath("SimpleName/@label").to_s] = []
139
+ end
140
+
141
+ data[p.at_xpath("SimpleName/@label").to_s].push(p.xpath("TextElement/@label").to_s)
142
+ end
143
+ data
144
+ end
145
+
146
+ def get_links(m)
147
+ m.xpath("Javadoc/TagElement/TagElement[@label='@link']").map { |p| p.xpath('QualifiedName/@label').to_s }
148
+ end
149
+
150
+ def get_throws(m)
151
+ throws = {}
152
+ m.xpath("Javadoc/TagElement[@label='@throws']").each do |p|
153
+ throws[p.at_xpath("SimpleName/@label").to_s] = p.xpath("TextElement/@label").to_s
154
+ end
155
+ throws
156
+ end
157
+
158
+ def get_see(m)
159
+ m.xpath("Javadoc/TagElement[@label='@see']/MethodRef").map { |p| p.xpath('SimpleName/@label').to_s }
160
+ end
161
+
162
+ def count_classes(doc)
163
+ doc.xpath("//TypeDeclaration").count
164
+ end
165
+
166
+ def count_methods(doc)
167
+ doc.xpath("//MethodDeclaration").count
168
+ end
169
+
170
+ def count_commented_classes(doc)
171
+ doc.xpath("//TypeDeclaration/Javadoc").count
172
+ end
173
+
174
+ def count_commented_methods(doc)
175
+ doc.xpath("//MethodDeclaration/Javadoc").count
176
+ end
177
+
178
+ def class_comment(doc)
179
+ doc.xpath("//MethodDeclaration/Javadoc").to_s
39
180
  end
40
181
 
41
182
  def clean
183
+ out.clean
42
184
  end
43
185
  end
@@ -38,7 +38,7 @@ class Tex < Diggit::Analysis
38
38
  end
39
39
 
40
40
  def clean
41
- FileUtils.rm_rf(file)
41
+ out.clean
42
42
  end
43
43
 
44
44
  def file
@@ -0,0 +1,114 @@
1
+ # encoding: utf-8
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 2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
19
+
20
+ require 'spec_helper'
21
+ require 'fileutils'
22
+
23
+ RSpec.describe Diggit do
24
+ it "should init a dgit folder" do
25
+ out = `bin/dgit -f spec/dgit init`
26
+ expect(out).to match(/Diggit folder initialized/)
27
+ end
28
+
29
+ it "should display status" do
30
+ out = `bin/dgit -f spec/dgit status`
31
+ expect(out).to match(/Config/)
32
+ end
33
+
34
+ it "should add a source" do
35
+ `bin/dgit -f spec/dgit sources add "#{TEST_URL}"`
36
+ out = `bin/dgit -f spec/dgit sources list`
37
+ expect(out).to match(/#{TEST_URL_INFO1}/)
38
+ expect(out).to match(/new/)
39
+ end
40
+
41
+ it "should del a source" do
42
+ `bin/dgit -f spec/dgit sources add http://foo`
43
+ out = `bin/dgit -f spec/dgit sources list`
44
+ expect(out).to match(/foo/)
45
+ out = `bin/dgit -f spec/dgit sources del 1`
46
+ expect(out).to_not match(/foo/)
47
+ end
48
+
49
+ it "should perform clones" do
50
+ `bin/dgit -f spec/dgit clones perform`
51
+ out = `bin/dgit -f spec/dgit sources list`
52
+ expect(out).to match(/cloned/)
53
+ end
54
+
55
+ it "should add an analysis" do
56
+ `bin/dgit -f spec/dgit analyses add test_analysis`
57
+ out = `bin/dgit -f spec/dgit status`
58
+ expect(out).to match(/test_analysis/)
59
+ end
60
+
61
+ it "should perform the analyses" do
62
+ `bin/dgit -f spec/dgit analyses perform`
63
+ out = `bin/dgit -f spec/dgit sources info 0`
64
+ expect(out).to match(/test_analysis/)
65
+ expect(out).to match(/Performed/)
66
+ expect(out).to_not match(/Canceled/)
67
+ end
68
+
69
+ it "should handle analyses with errors" do
70
+ `bin/dgit -f spec/dgit analyses add test_analysis_with_error`
71
+ `bin/dgit -f spec/dgit analyses perform`
72
+ out = `bin/dgit -f spec/dgit sources info 0`
73
+ expect(out).to match(/test_analysis_with_error/)
74
+ expect(out).to match(/Canceled/)
75
+ expect(out).to match(/Error!/)
76
+ end
77
+
78
+ it "should add joins" do
79
+ `bin/dgit -f spec/dgit joins add test_join`
80
+ out = `bin/dgit -f spec/dgit status`
81
+ expect(out).to match(/test_join/)
82
+ expect(out).to_not match(/Performed joins/)
83
+ end
84
+
85
+ it "should perform joins" do
86
+ `bin/dgit -f spec/dgit joins perform`
87
+ out = `bin/dgit -f spec/dgit status`
88
+ expect(out).to match(/test_join/)
89
+ expect(out).to match(/Performed joins/)
90
+ end
91
+
92
+ it "should handle joins with errors" do
93
+ `bin/dgit -f spec/dgit joins add test_join_with_error`
94
+ `bin/dgit -f spec/dgit joins perform`
95
+ out = `bin/dgit -f spec/dgit status`
96
+ expect(out).to match(/test_join_with_error/)
97
+ expect(out).to match(/Canceled/)
98
+ expect(out).to match(/Error!/)
99
+ end
100
+
101
+ it "should clean joins" do
102
+ `bin/dgit -f spec/dgit joins perform -m clean`
103
+ out = `bin/dgit -f spec/dgit status`
104
+ expect(out).to_not match(/Canceled/)
105
+ expect(out).to_not match(/Performed/)
106
+ end
107
+
108
+ it "should clean anlyses" do
109
+ `bin/dgit -f spec/dgit analyses perform -m clean`
110
+ out = `bin/dgit -f spec/dgit sources info 0`
111
+ expect(out).to_not match(/Canceled/)
112
+ expect(out).to_not match(/Performed/)
113
+ end
114
+ end
@@ -9,19 +9,30 @@
9
9
  #
10
10
  # Diggit is distributed in the hope that it will be useful,
11
11
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
13
  # GNU Lesser General Public License for more details.
14
14
  #
15
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/>.
16
+ # along with Diggit. If not, see <http://www.gnu.org/licenses/>.
17
17
  #
18
18
  # Copyright 2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
19
19
 
20
20
  require 'spec_helper'
21
21
  require 'fileutils'
22
22
 
23
- FileUtils.rm_rf('spec/dgit/.dgit')
24
- FileUtils.rm_rf('spec/dgit/sources')
23
+ RSpec.configure do |config|
24
+ original_stderr = $stderr
25
+ original_stdout = $stdout
26
+ config.before(:all) do
27
+ # Redirect stderr and stdout
28
+ $stderr = File.open(File::NULL, "w")
29
+ $stdout = File.open(File::NULL, "w")
30
+ end
31
+ config.after(:all) do
32
+ $stderr = original_stderr
33
+ $stdout = original_stdout
34
+ end
35
+ end
25
36
 
26
37
  RSpec.describe Diggit::Dig do
27
38
  it "should refuse to be launched outside a dgit folder" do
@@ -69,6 +80,9 @@ RSpec.describe Diggit::Dig do
69
80
  it "should load a join" do
70
81
  join = Diggit::Dig.it.plugin_loader.load_plugin("test_join", :join)
71
82
  expect(join.to_s).to eq('TestJoin')
83
+ end
84
+
85
+ it "should load a join with addons" do
72
86
  join = Diggit::Dig.it.plugin_loader.load_plugin("test_join_with_addon", :join)
73
87
  expect(join.to_s).to eq('TestJoinWithAddon')
74
88
  join_instance = join.new({})
@@ -93,18 +107,34 @@ RSpec.describe Diggit::Dig do
93
107
  it "should store sources" do
94
108
  Diggit::Dig.it.journal.add_source(TEST_URL)
95
109
  Diggit::Dig.init("spec/dgit")
96
- expect(Diggit::Dig.it.journal.sources_by_ids(0)[0].url).to eq TEST_URL
110
+ expect(Diggit::Dig.it.journal.sources_by_ids.first.url).to eq TEST_URL_INFO1
111
+ expect(Diggit::Dig.it.journal.sources_by_ids.first.oid).to eq TEST_URL_INFO2
112
+ end
113
+
114
+ it "should delete sources" do
115
+ Diggit::Dig.it.journal.add_source('http://foo')
116
+ Diggit::Dig.init("spec/dgit")
117
+ expect(Diggit::Dig.it.journal.sources_by_ids.size).to eq 2
118
+ Diggit::Dig.it.journal.del_source(1)
119
+ Diggit::Dig.init("spec/dgit")
120
+ expect(Diggit::Dig.it.journal.sources_by_ids.size).to eq 1
97
121
  end
98
122
 
99
123
  it "should clone sources" do
100
124
  Diggit::Dig.it.clone
101
- expect(File.exist?("spec/dgit/sources/#{TEST_URL.id}/.git")).to be true
102
- expect(Diggit::Dig.it.journal.sources_by_ids(0)[0].url).to eq TEST_URL
103
- Diggit::Dig.it.journal.sources_by_ids(0)[0].entry.state = :new
125
+ expect(File.exist?("spec/dgit/sources/#{TEST_URL_INFO1.id}/.git")).to be true
126
+ expect(File.exist?("spec/dgit/sources/#{TEST_URL_INFO1.id}/test/src/foo/Bar.java")).to be false
127
+ src = Diggit::Dig.it.journal.sources_by_ids.first
128
+ expect(src.url).to eq TEST_URL_INFO1
129
+ expect(src.oid).to eq TEST_URL_INFO2
130
+ src.entry.state = :new
104
131
  Diggit::Dig.it.clone
105
- expect(Diggit::Dig.it.journal.sources_by_ids(0)[0].url).to eq TEST_URL
132
+ expect(src.url).to eq TEST_URL_INFO1
133
+ expect(src.oid).to eq TEST_URL_INFO2
106
134
  Diggit::Dig.init("spec/dgit")
107
- expect(Diggit::Dig.it.journal.sources_by_ids(0)[0].url).to eq TEST_URL
135
+ src = Diggit::Dig.it.journal.sources_by_ids.first
136
+ expect(src.url).to eq TEST_URL_INFO1
137
+ expect(src.oid).to eq TEST_URL_INFO2
108
138
  end
109
139
 
110
140
  it "should perform analyses in order" do
@@ -113,11 +143,11 @@ RSpec.describe Diggit::Dig do
113
143
  Diggit::Dig.it.config.add_analysis("test_analysis_with_addon")
114
144
  expect_any_instance_of(TestAnalysisWithAddon).to receive(:run)
115
145
  Diggit::Dig.it.analyze
116
- src = Diggit::Dig.it.journal.sources_by_ids(0)[0]
146
+ src = Diggit::Dig.it.journal.sources_by_ids.first
117
147
  expect(src.entry.has?("test_analysis", :performed)).to be true
118
148
  expect(src.entry.has?("test_analysis_with_addon", :performed)).to be true
119
149
  Diggit::Dig.init("spec/dgit")
120
- src = Diggit::Dig.it.journal.sources_by_ids(0)[0]
150
+ src = Diggit::Dig.it.journal.sources_by_ids.first
121
151
  expect(src.entry.has?("test_analysis", :performed)).to be true
122
152
  expect(src.entry.has?("test_analysis_with_addon", :performed)).to be true
123
153
  end
@@ -125,11 +155,11 @@ RSpec.describe Diggit::Dig do
125
155
  it "should handle analyses with error" do
126
156
  Diggit::Dig.it.config.add_analysis("test_analysis_with_error")
127
157
  Diggit::Dig.it.analyze
128
- src = Diggit::Dig.it.journal.sources_by_ids(0)[0]
158
+ src = Diggit::Dig.it.journal.sources_by_ids.first
129
159
  expect(src.entry.has?("test_analysis_with_error", :performed)).to be false
130
160
  expect(src.entry.has?("test_analysis_with_error", :canceled)).to be true
131
161
  expect(src.entry.error?).to be true
132
- expect(src.entry.canceled[0].error.message).to eq("Error!")
162
+ expect(src.entry.canceled.first.error.message).to eq("Error!")
133
163
  end
134
164
 
135
165
  it "should perform joins" do
@@ -148,7 +178,7 @@ RSpec.describe Diggit::Dig do
148
178
  expect(Diggit::Dig.it.journal.workspace.has?("test_join_with_error", :performed)).to be false
149
179
  expect(Diggit::Dig.it.journal.workspace.has?("test_join_with_error", :canceled)).to be true
150
180
  expect(Diggit::Dig.it.journal.workspace.error?).to be true
151
- expect(Diggit::Dig.it.journal.workspace.canceled[0].error.message).to eq("Error!")
181
+ expect(Diggit::Dig.it.journal.workspace.canceled.first.error.message).to eq("Error!")
152
182
  end
153
183
 
154
184
  it "should clean joins" do
@@ -173,7 +203,7 @@ RSpec.describe Diggit::Dig do
173
203
  expect_any_instance_of(TestAnalysis).to receive(:clean)
174
204
  expect_any_instance_of(TestAnalysisWithAddon).to receive(:clean)
175
205
  Diggit::Dig.it.analyze([], [], :clean)
176
- src = Diggit::Dig.it.journal.sources_by_ids(0)[0]
206
+ src = Diggit::Dig.it.journal.sources_by_ids.first
177
207
  expect(src.entry.has?("test_analysis")).to be false
178
208
  expect(src.entry.has?("test_analysis_with_addon")).to be false
179
209
  Diggit::Dig.it.config.del_all_analyses
@@ -182,7 +212,7 @@ RSpec.describe Diggit::Dig do
182
212
  it "should handle analyses with clean errors" do
183
213
  Diggit::Dig.it.config.add_analysis("test_analysis_with_clean_error")
184
214
  Diggit::Dig.it.analyze([], ["test_analysis_with_clean_error"])
185
- src = Diggit::Dig.it.journal.sources_by_ids(0)[0]
215
+ src = Diggit::Dig.it.journal.sources_by_ids.first
186
216
  expect(src.entry.has?("test_analysis_with_clean_error", :performed)).to be true
187
217
  Diggit::Dig.it.analyze([], [], :clean)
188
218
  expect(src.entry.has?("test_analysis_with_clean_error", :performed)).to be false