File path: /jruby-1.4.0/src/org/jruby/RubyEnumerable.java | File path: /jruby-1.4.0/src/org/jruby/RubyEnumerable.java | |||
Method name: IRubyObject max(ThreadContext, IRubyObject, Block)
|
Method name: IRubyObject min(ThreadContext, IRubyObject, Block)
|
|||
Number of AST nodes: 7 | Number of AST nodes: 7 | |||
1 | final Ruby runtime = context.getRuntime();↵ | 1 | final Ruby runtime = context.getRuntime();↵ | |
2 | final IRubyObject result[] = new IRubyObject[] { null };↵ | 2 | final IRubyObject result[] = new IRubyObject[] { null };↵ | |
3 | final ThreadContext localContext = context;↵ | 3 | final ThreadContext localContext = context;↵ | |
4 | if (block.isGiven()) {↵ | 4 | if (block.isGiven()) {↵ | |
5 | callEach(runtime, context, self, new BlockCallback() {↵ | 5 | callEach(runtime, context, self, new BlockCallback() {↵ | |
6 | public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {↵ | 6 | public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {↵ | |
7 | IRubyObject larg = checkArgs(runtime, largs);↵ | 7 | IRubyObject larg = checkArgs(runtime, largs);↵ | |
8 | checkContext(localContext, ctx, "max{}");↵ | 8 | checkContext(localContext, ctx, "min{}");↵ | |
9 | if (result[0] == null || RubyComparable.cmpint(ctx, block.yield(ctx, ↵ | 9 | if (result[0] == null || RubyComparable.cmpint(ctx, block.yield(ctx, ↵ | |
10 | runtime.newArray(larg, result[0]), null, null, true), larg, result[0]) > 0) {↵ | 10 | runtime.newArray(larg, result[0])), larg, result[0]) < 0) {↵ | |
11 | result[0] = larg;↵ | 11 | result[0] = larg;↵ | |
12 | }↵ | 12 | }↵ | |
13 | return runtime.getNil();↵ | 13 | return runtime.getNil();↵ | |
14 | }↵ | 14 | }↵ | |
15 | });↵ | 15 | });↵ | |
16 | } else {↵ | 16 | } else {↵ | |
17 | callEach(runtime, context, self, new BlockCallback() {↵ | 17 | callEach(runtime, context, self, new BlockCallback() {↵ | |
18 | public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {↵ | 18 | public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {↵ | |
19 | IRubyObject larg = checkArgs(runtime, largs);↵ | 19 | IRubyObject larg = checkArgs(runtime, largs);↵ | |
20 | synchronized (result) {↵ | 20 | synchronized (result) {↵ | |
21 | if (result[0] == null || RubyComparable.cmpint(ctx, larg.callMethod(ctx, "<=>", result[0]), larg, result[0]) > 0) {↵ | 21 | if (result[0] == null || RubyComparable.cmpint(ctx, larg.callMethod(ctx, "<=>", result[0]), larg, result[0]) < 0) {↵ | |
22 | result[0] = larg;↵ | 22 | result[0] = larg;↵ | |
23 | }↵ | 23 | }↵ | |
24 | }↵ | 24 | }↵ | |
25 | return runtime.getNil();↵ | 25 | return runtime.getNil();↵ | |
26 | }↵ | 26 | }↵ | |
27 | });↵ | 27 | });↵ | |
28 | }↵ | 28 | }↵ | |
29 | return result[0] == null ? runtime.getNil() : result[0]; | 29 |
| |
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.3 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 25 |
Number of mapped statements | 5 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 2 |
Time elapsed for statement mapping (ms) | 36.8 |
Clone type | Type 2 |
ID | Statement | ID | Statement | ||||
---|---|---|---|---|---|---|---|
1 | final Ruby runtime = context.getRuntime(); | 1 | final Ruby runtime = context.getRuntime(); | ||||
2 | final IRubyObject result[] = new IRubyObject[] {null}; | 2 | final IRubyObject result[] = new IRubyObject[] {null}; | ||||
3 | final ThreadContext localContext = context; | 3 | final ThreadContext localContext = context; | ||||
4 | if (block.isGiven()) | 4 | if (block.isGiven()) | ||||
|
| 5 | callEach(runtime, context, self, new BlockCallback() {...}); | ||||
5 | callEach(runtime, context, self, new BlockCallback() {...}); |
| | ||||
else | | ||||||
|
| 6 | callEach(runtime, context, self, new BlockCallback() {...}); | ||||
6 | callEach(runtime, context, self, new BlockCallback() {...}); |
| | ||||
7 | return result[0] == null ? runtime.getNil() : result[0]; | 7 | return result[0] == null ? runtime.getNil() : result[0]; |
Row | Violation |
---|---|
1 | Unmatched statement callEach(runtime,context,self,new BlockCallback(){ public IRubyObject call( ThreadContext ctx, IRubyObject[] largs, Block blk){ IRubyObject larg=checkArgs(runtime,largs); checkContext(localContext,ctx,"min{}"); if (result[0] == null || RubyComparable.cmpint(ctx,block.yield(ctx,runtime.newArray(larg,result[0])),larg,result[0]) < 0) { result[0]=larg; } return runtime.getNil(); } } ); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement callEach(runtime,context,self,new BlockCallback(){ public IRubyObject call( ThreadContext ctx, IRubyObject[] largs, Block blk){ IRubyObject larg=checkArgs(runtime,largs); checkContext(localContext,ctx,"max{}"); if (result[0] == null || RubyComparable.cmpint(ctx,block.yield(ctx,runtime.newArray(larg,result[0]),null,null,true),larg,result[0]) > 0) { result[0]=larg; } return runtime.getNil(); } } ); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement callEach(runtime,context,self,new BlockCallback(){ public IRubyObject call( ThreadContext ctx, IRubyObject[] largs, Block blk){ IRubyObject larg=checkArgs(runtime,largs); synchronized (result) { if (result[0] == null || RubyComparable.cmpint(ctx,larg.callMethod(ctx,"<=>",result[0]),larg,result[0]) < 0) { result[0]=larg; } } return runtime.getNil(); } } ); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
4 | Unmatched statement callEach(runtime,context,self,new BlockCallback(){ public IRubyObject call( ThreadContext ctx, IRubyObject[] largs, Block blk){ IRubyObject larg=checkArgs(runtime,largs); synchronized (result) { if (result[0] == null || RubyComparable.cmpint(ctx,larg.callMethod(ctx,"<=>",result[0]),larg,result[0]) > 0) { result[0]=larg; } } return runtime.getNil(); } } ); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
5 | Clone fragment #1 returns variables runtime, result, localContext , while Clone fragment #2 returns variables runtime, result, localContext |