-
Notifications
You must be signed in to change notification settings - Fork 6
/
CodeShovel-error.html
87 lines (82 loc) · 5.72 KB
/
CodeShovel-error.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="lib/github-markdown.css">
<style>
.markdown-body {
box-sizing: border-box;
min-width: 200px;
max-width: 980px;
margin: 0 auto;
padding: 45px;
}
@media (max-width: 767px) {
.markdown-body {
padding: 15px;
}
}
</style>
<article class="markdown-body">
<h1><a id="user-content-steps-to-reproduce-the-incorrect-behaviour-of-codeshovel" class="anchor" aria-hidden="true" href="#steps-to-reproduce-the-incorrect-behaviour-of-codeshovel"><span aria-hidden="true" class="octicon octicon-link"></span></a>Steps to reproduce the incorrect behaviour of CodeShovel</h1>
<p><strong>You first need to run the docker container using the provided image file. See <code>README.md</code>.</strong></p>
<p>The error is occurred while extracting the history of the method <code>equals</code> in <code>src/main/java/org/apache/commons/lang3/StringUtils.java</code>:</p>
<div class="highlight highlight-source-java"><pre> <span class="pl-k">public</span> <span class="pl-k">static</span> <span class="pl-smi">boolean</span> <span class="pl-s1">equals</span>(<span class="pl-smi">CharSequence</span> <span class="pl-s1">cs1</span>, <span class="pl-smi">CharSequence</span> <span class="pl-s1">cs2</span>) { <span class="pl-c">// 781</span>
<span class="pl-k">return</span> <span class="pl-s1">cs1</span> == <span class="pl-c1">null</span> ? <span class="pl-s1">cs2</span> == <span class="pl-c1">null</span> : <span class="pl-s1">cs1</span>.<span class="pl-en">equals</span>(<span class="pl-s1">cs2</span>); <span class="pl-c">// 782</span>
} <span class="pl-c">// 783</span></pre></div>
<p>To reproduce the error, first check out the buggy version of Lang-14b to <code>/tmp/Lang-14b</code>.</p>
<div class="highlight highlight-source-shell"><pre><span class="pl-c"><span class="pl-c">#</span> in a bash session of the container</span>
defects4j checkout -p Lang -v 14b -w /tmp/Lang-14b
<span class="pl-c1">cd</span> /tmp/Lang-14b
git reset --hard c8afaa3e869cc8c25577641553e0d0b5bdac78b5</pre></div>
<p>If you use <code>git log</code> to retrieve the method histories:</p>
<div class="highlight highlight-source-shell"><pre>git log -L781,783:src/main/java/org/apache/commons/lang3/StringUtils.java</pre></div>
<p>it returns three commits:</p>
<ul>
<li>cf2e48a05c250feb636dd337dae1ffb7a1d9d411</li>
<li>f349629500ff5a85683dff0a807ff8e9b5b88809</li>
<li>d23b22c78078ee7468e797e80188ae9508c0eee0</li>
</ul>
<p>Now, let us run <code>CodeShovel</code> to retrieve the histories:</p>
<div class="highlight highlight-source-shell"><pre>java -Xmx2g -jar /root/workspace/tools/codeshovel-1.0.0-SNAPSHOT.jar -repopath /tmp/Lang-14b -filepath src/main/java/org/apache/commons/lang3/StringUtils.java -methodname equals -startline 781 -outfile output.json</pre></div>
<p>The output then is as follows:</p>
<pre lang="txt"><code>#########################################################################
STARTING ANALYSIS FOR FILE src/main/java/org/apache/commons/lang3/StringUtils.java
-------------------------------------------------------------------------
STARTING ANALYSIS FOR METHOD equals
====================================================
Running Analysis
Commit: HEAD
Method: equals
Lines: 781-783
====================================================
CodeShovel Change History:
fec5e47638aeb2860a604daa0f424a91dbd9a166:Yintroduced(fec5e4:equals:752)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%% RESULT %%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"fec5e47638aeb2860a604daa0f424a91dbd9a166": "Yintroduced",
FINISHED ANALYSIS FOR METHOD equals
RESULT FILE WRITTEN TO output.json
-------------------------------------------------------------------------
FINISHED ANALYSIS FOR FILE src/main/java/org/apache/commons/lang3/StringUtils.java
#########################################################################
Total duration: 11373
</code></pre>
<p>The retrieved commit <code>fec5e47</code> is actually not related to the target method:</p>
<div class="highlight highlight-source-diff"><pre><span class="pl-c1">diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java</span>
index 73aabe4..1ecf255 100644
<span class="pl-md">--- a/src/main/java/org/apache/commons/lang3/StringUtils.java</span>
<span class="pl-mi1">+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java</span>
<span class="pl-mdr">@@ -6491,14 +6491,4 @@</span> public class StringUtils {
}
}
<span class="pl-md"><span class="pl-md">-</span> static boolean regionMatchesSequence(CharSequence cs, boolean ignoreCase, int thisStart, </span>
<span class="pl-md"><span class="pl-md">-</span> CharSequence substring, int start, int length)</span>
<span class="pl-md"><span class="pl-md">-</span> {</span>
<span class="pl-md"><span class="pl-md">-</span> if (cs instanceof String) {</span>
<span class="pl-md"><span class="pl-md">-</span> return ((String) cs).regionMatches(ignoreCase, thisStart, substring, start, length);</span>
<span class="pl-md"><span class="pl-md">-</span> } else {</span>
<span class="pl-md"><span class="pl-md">-</span> // TODO: Implement rather than convert to String</span>
<span class="pl-md"><span class="pl-md">-</span> return cs.toString().regionMatches(ignoreCase, thisStart, substring, start, length);</span>
<span class="pl-md"><span class="pl-md">-</span> }</span>
<span class="pl-md"><span class="pl-md">-</span></span>
}</pre></div>
</article>