File path: /apache-ant-1.7.0/src/org/apache/tools/ant/filters/LineContainsRegExp.java | File path: /apache-ant-1.7.0/src/org/apache/tools/ant/filters/LineContains.java | |||
Method name: int read()
|
Method name: int read()
|
|||
Number of AST nodes: 21 | Number of AST nodes: 20 | |||
1 | if (!getInitialized()) {↵ | 1 | if (!getInitialized()) {↵ | |
2 | initialize();↵ | 2 | initialize();↵ | |
3 | setInitialized(true);↵ | 3 | setInitialized(true);↵ | |
4 | }↵ | 4 | }↵ | |
5 | int ch = -1;↵ | 5 | int ch = -1;↵ | |
6 | if (line != null) {↵ | 6 | if (line != null) {↵ | |
7 | ch = line.charAt(0);↵ | 7 | ch = line.charAt(0);↵ | |
8 | if (line.length() == 1) {↵ | 8 | if (line.length() == 1) {↵ | |
9 | line = null;↵ | 9 | line = null;↵ | |
10 | } else {↵ | 10 | } else {↵ | |
11 | line = line.substring(1);↵ | 11 | line = line.substring(1);↵ | |
12 | }↵ | 12 | }↵ | |
13 | } else {↵ | 13 | } else {↵ | |
14 | final int regexpsSize = regexps.size();↵ | 14 | final int containsSize = contains.size();↵ | |
15 | for (line = readLine(); line != null; line = readLine()) {↵ | 15 | for (line = readLine(); line != null; line = readLine()) {↵ | |
16 | boolean matches = true;↵ | 16 | boolean matches = true;↵ | |
17 | for (int i = 0; matches && i < regexpsSize; i++) {↵ | 17 | for (int i = 0; matches && i < containsSize; i++) {↵ | |
18 | RegularExpression regexp↵ | 18 | ↵ | |
19 | = (RegularExpression) regexps.elementAt(i);↵ | |||
20 | Regexp re = regexp.getRegexp(getProject());↵ | |||
21 | matches = re.matches(line)↵ | 19 | String containsStr = (String) contains.elementAt(i);↵ | |
22 | ;↵ | 20 | matches = line.indexOf(containsStr) >= 0;↵ | |
23 | }↵ | 21 | }↵ | |
24 | if (matches ^ isNegated()) {↵ | 22 | if (matches ^ isNegated()) {↵ | |
25 | break;↵ | 23 | break;↵ | |
26 | }↵ | 24 | }↵ | |
27 | }↵ | 25 | }↵ | |
28 | if (line != null) {↵ | 26 | if (line != null) {↵ | |
29 | return read();↵ | 27 | return read();↵ | |
30 | }↵ | 28 | }↵ | |
31 | }↵ | 29 | }↵ | |
32 | return ch; | 30 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 1.5 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 77 |
Number of mapped statements | 19 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 7.8 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | if (!getInitialized()) | 1 | if (!getInitialized()) | ||||||||||||||
2 | initialize(); | 2 | initialize(); | ||||||||||||||
3 | setInitialized(true); | 3 | setInitialized(true); | ||||||||||||||
4 | int ch = -1; | 4 | int ch = -1; | ||||||||||||||
5 | if (line != null) | 5 | if (line != null) | ||||||||||||||
6 | ch = line.charAt(0); | 6 | ch = line.charAt(0); | ||||||||||||||
7 | if (line.length() == 1) | 7 | if (line.length() == 1) | ||||||||||||||
8 | line = null; | 8 | line = null; | ||||||||||||||
else | else | ||||||||||||||||
9 | line = line.substring(1); | 9 | line = line.substring(1); | ||||||||||||||
else | else | ||||||||||||||||
10 | final int regexpsSize = regexps.size(); |
| 10 | final int containsSize = contains.size(); | |||||||||||||
11 | for (line = readLine(); line != null; line = readLine()) | 11 | for (line = readLine(); line != null; line = readLine()) | ||||||||||||||
12 | boolean matches = true; | 12 | boolean matches = true; | ||||||||||||||
13 | for (int i = 0; matches && i < regexpsSize; i++) |
| 13 | for (int i = 0; matches && i < containsSize; i++) | |||||||||||||
|
| 14 | String containsStr = (String)contains.elementAt(i); | ||||||||||||||
14 | RegularExpression regexp = (RegularExpression)regexps.elementAt(i); |
| | ||||||||||||||
15 | Regexp re = regexp.getRegexp(getProject()); |
| | ||||||||||||||
16 | matches = re.matches(line); |
| 15 | matches = line.indexOf(containsStr) >= 0; | |||||||||||||
17 | if (matches ^ isNegated()) | 16 | if (matches ^ isNegated()) | ||||||||||||||
18 | break; | 17 | break; | ||||||||||||||
19 | if (line != null) | 18 | if (line != null) | ||||||||||||||
20 | return read(); | 19 | return read(); | ||||||||||||||
21 | return ch; | 20 | return ch; |
Row | Violation |
---|---|
1 | Unmatched statement String containsStr=(String)contains.elementAt(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement RegularExpression regexp=(RegularExpression)regexps.elementAt(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement Regexp re=regexp.getRegexp(getProject()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
4 | Expression re.matches(line) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression line.indexOf(containsStr) >= 0 cannot be parameterized, because it has dependencies to/from statements that will be extracted |