File path: /sql12/plugins/syntax/src/net/sourceforge/squirrel_sql/plugins/syntax/oster/OsterTextControl.java | File path: /sql12/plugins/syntax/src/net/sourceforge/squirrel_sql/plugins/syntax/oster/DocReader.java | |||
Method name: int read(char[], int, int)
|
Method name: int read(char[], int, int)
|
|||
Number of AST nodes: 13 | Number of AST nodes: 13 | |||
1 | if (position < document.getLength())↵ | 1 | if (position < document.getLength()) ↵ | |
2 | {↵ | 2 | { ↵ | |
3 | int length = len;↵ | 3 | int length = len; ↵ | |
4 | if (position + length >= document.getLength())↵ | 4 | if (position + length >= document.getLength()) ↵ | |
5 | {↵ | 5 | ↵ | |
6 | ↵ | 6 | {↵ | |
7 | length = document.getLength() - (int) position;↵ | 7 | length = document.getLength() - (int) position; ↵ | |
8 | }↵ | 8 | } ↵ | |
9 | if (off + length >= cbuf.length)↵ | 9 | if (off + length >= cbuf.length) ↵ | |
10 | {↵ | 10 | { ↵ | |
11 | length = cbuf.length - off;↵ | 11 | length = cbuf.length - off; ↵ | |
12 | }↵ | 12 | } ↵ | |
13 | try↵ | 13 | try ↵ | |
14 | {↵ | 14 | { ↵ | |
15 | String s = document.getText((int) position, length);↵ | 15 | String s = document.getText((int) position, length); ↵ | |
16 | position += length;↵ | 16 | position += length; ↵ | |
17 | for (int i = 0; i < length; i++)↵ | 17 | for (int i = 0; i < length; i++) ↵ | |
18 | {↵ | 18 | { ↵ | |
19 | // The Ostermiller SQLLexer crashes with an ArrayIndexOutOfBoundsException↵ | |||
20 | // if the char is greater then 255. So we prevent the char from being greater.↵ | |||
21 | // This is surely not a proper Unicode treatment but it doesn't seem↵ | |||
22 | // to do no harm and it keeps the SQLLexer working.↵ | |||
23 | cbuf[off + i] = (char)((s.charAt(i)) % 256);↵ | 19 | cbuf[off + i] = s.charAt(i); ↵ | |
24 | }↵ | 20 | ↵ | |
25 | ↵ | 21 | }↵ | |
26 | return length;↵ | 22 | return length; ↵ | |
27 | }↵ | 23 | ↵ | |
28 | ↵ | 24 | }↵ | |
29 | catch (BadLocationException x)↵ | 25 | catch (BadLocationException x) ↵ | |
30 | {↵ | 26 | { ↵ | |
31 | return -1;↵ | 27 | return -1; ↵ | |
32 | }↵ | 28 | } ↵ | |
33 | }↵ | 29 | ↵ | |
34 | ↵ | 30 | }↵ | |
35 | else↵ | 31 | else ↵ | |
36 | {↵ | 32 | { ↵ | |
37 | return -1;↵ | 33 | return -1; ↵ | |
38 | } | 34 |
| |
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.1 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 39 |
Number of mapped statements | 13 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 9.3 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | if (position < document.getLength()) | 1 | if (position < document.getLength()) | |||||||||||||
2 | int length = len; | 2 | int length = len; | |||||||||||||
3 | if (position + length >= document.getLength()) | 3 | if (position + length >= document.getLength()) | |||||||||||||
4 | length = document.getLength() - (int)position; | 4 | length = document.getLength() - (int)position; | |||||||||||||
5 | if (off + length >= cbuf.length) | 5 | if (off + length >= cbuf.length) | |||||||||||||
6 | length = cbuf.length - off; | 6 | length = cbuf.length - off; | |||||||||||||
7 | try | 7 | try | |||||||||||||
8 | String s = document.getText((int)position, length); | 8 | String s = document.getText((int)position, length); | |||||||||||||
9 | position += length; | 9 | position += length; | |||||||||||||
10 | for (int i = 0; i < length; i++) | 10 | for (int i = 0; i < length; i++) | |||||||||||||
11 | cbuf[off + i] = (char)((s.charAt(i)) % 256); |
| 11 | cbuf[off + i] = s.charAt(i); | ||||||||||||
12 | return length; | 12 | return length; | |||||||||||||
else | else | |||||||||||||||
13 | return -1; | 13 | return -1; |
Row | Violation |
---|---|
1 | Expression (char)((s.charAt(i)) % 256) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression s.charAt(i) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Not all possible execution flows end in a return statement |