File path: /jruby-1.4.0/src/org/jruby/RubyRange.java | File path: /jruby-1.4.0/src/org/jruby/RubyRange.java | |||
Method name: IRubyObject each19(ThreadContext, Block)
|
Method name: IRubyObject each(ThreadContext, Block)
|
|||
Number of AST nodes: 11 | Number of AST nodes: 11 | |||
1 | Ruby runtime = context.getRuntime();↵ | 1 | final Ruby runtime = context.getRuntime();↵ | |
2 | if (!block.isGiven()) return enumeratorize(runtime, this, "each");↵ | 2 | if (!block.isGiven()) return enumeratorize(runtime, this, "each");↵ | |
3 | if (begin instanceof RubyFixnum && end instanceof RubyFixnum) {↵ | 3 | if (begin instanceof RubyFixnum && end instanceof RubyFixnum) {↵ | |
4 | fixnumEach(context, runtime, block);↵ | 4 | fixnumEach(context, runtime, block);↵ | |
5 | } else if (begin instanceof RubyString) {↵ | 5 | } else if (begin instanceof RubyString) {↵ | |
6 | ((RubyString) begin).uptoCommon19(context, end, isExclusive, block);↵ | 6 | ((RubyString) begin).uptoCommon18(context, end, isExclusive, block);↵ | |
7 | } else {↵ | 7 | } else {↵ | |
8 | if (!begin.respondsTo("succ")) throw getRuntime().newTypeError(↵ | 8 | if (!begin.respondsTo("succ")) throw getRuntime().newTypeError(↵ | |
9 | "can't iterate from " + begin.getMetaClass().getName());↵ | 9 | "can't iterate from " + begin.getMetaClass().getName());↵ | |
10 | rangeEach(context, new RangeCallBack() {↵ | 10 | rangeEach(context, new RangeCallBack() {↵ | |
11 | @Override↵ | 11 | @Override↵ | |
12 | void call(ThreadContext context, IRubyObject arg) {↵ | 12 | void call(ThreadContext context, IRubyObject arg) {↵ | |
13 | block.yield(context, arg);↵ | 13 | block.yield(context, arg);↵ | |
14 | }↵ | 14 | }↵ | |
15 | });↵ | 15 | });↵ | |
16 | }↵ | 16 | }↵ | |
17 | return this; | 17 |
| |
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) | 0.5 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 44 |
Number of mapped statements | 10 |
Number of unmapped statements in the first code fragment | 1 |
Number of unmapped statements in the second code fragment | 1 |
Time elapsed for statement mapping (ms) | 2.9 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | final Ruby runtime = context.getRuntime(); | ||||||||||||||
1 | Ruby runtime = context.getRuntime(); | | ||||||||||||||
2 | if (!block.isGiven()) | 2 | if (!block.isGiven()) | |||||||||||||
3 | return enumeratorize(runtime, this, "each"); | 3 | return enumeratorize(runtime, this, "each"); | |||||||||||||
4 | if (begin instanceof RubyFixnum && end instanceof RubyFixnum) | 4 | if (begin instanceof RubyFixnum && end instanceof RubyFixnum) | |||||||||||||
5 | fixnumEach(context, runtime, block); | 5 | fixnumEach(context, runtime, block); | |||||||||||||
6 | else if (begin instanceof RubyString) | 6 | else if (begin instanceof RubyString) | |||||||||||||
7 | ((RubyString)begin).uptoCommon19(context, end, isExclusive, block); |
| 7 | ((RubyString)begin).uptoCommon18(context, end, isExclusive, block); | ||||||||||||
else | else | |||||||||||||||
8 | if (!begin.respondsTo("succ")) | 8 | if (!begin.respondsTo("succ")) | |||||||||||||
9 | throw getRuntime().newTypeError("can't iterate from " + begin.getMetaClass().getName()); | 9 | throw getRuntime().newTypeError("can't iterate from " + begin.getMetaClass().getName()); | |||||||||||||
10 | rangeEach(context, new RangeCallBack() {...}); | 10 | rangeEach(context, new RangeCallBack() {...}); | |||||||||||||
11 | return this; | 11 | return this; |
Row | Violation |
---|---|
1 | Expression ((RubyString)begin).uptoCommon19(context,end,isExclusive,block) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression ((RubyString)begin).uptoCommon18(context,end,isExclusive,block) cannot be parameterized, because it has dependencies to/from statements that will be extracted |