File path: /jruby-1.4.0/src/org/jruby/RubyEtc.java | File path: /jruby-1.4.0/src/org/jruby/RubyEtc.java | |||
Method name: IRubyObject group(IRubyObject, Block)
|
Method name: IRubyObject passwd(IRubyObject, Block)
|
|||
Number of AST nodes: 15 | Number of AST nodes: 15 | |||
1 | Ruby runtime = recv.getRuntime();↵ | 1 | Ruby runtime = recv.getRuntime();↵ | |
2 | POSIX posix = runtime.getPosix();↵ | 2 | POSIX posix = runtime.getPosix();↵ | |
3 | try {↵ | 3 | try {↵ | |
4 | // try to read grent to fail fast↵ | 4 | // call getpwent to fail early if unsupported↵ | |
5 | posix.getgrent();↵ | 5 | posix.getpwent();↵ | |
6 | if(block.isGiven()) {↵ | 6 | if(block.isGiven()) {↵ | |
7 | ThreadContext context = runtime.getCurrentContext();↵ | 7 | ThreadContext context = runtime.getCurrentContext();↵ | |
8 | posix.setgrent();↵ | 8 | posix.setpwent();↵ | |
9 | Group gr;↵ | 9 | Passwd pw;↵ | |
10 | while((gr = posix.getgrent()) != null) {↵ | 10 | while((pw = posix.getpwent()) != null) {↵ | |
11 | block.yield(context, setupGroup(runtime, gr));↵ | 11 | block.yield(context, setupPasswd(runtime, pw));↵ | |
12 | }↵ | 12 | }↵ | |
13 | posix.endgrent();↵ | 13 | posix.endpwent();↵ | |
14 | }↵ | 14 | }↵ | |
15 | Group gr = posix.getgrent();↵ | 15 | Passwd pw = posix.getpwent();↵ | |
16 | if (gr != null) {↵ | 16 | if (pw != null) {↵ | |
17 | return setupGroup(runtime, gr);↵ | 17 | return setupPasswd(runtime, pw);↵ | |
18 | } else {↵ | 18 | } else {↵ | |
19 | return runtime.getNil();↵ | 19 | return runtime.getNil();↵ | |
20 | }↵ | 20 | }↵ | |
21 | } catch (Exception e) {↵ | 21 | } catch (Exception e) {↵ | |
22 | if (runtime.getDebug().isTrue()) {↵ | 22 | if (runtime.getDebug().isTrue()) {↵ | |
23 | runtime.getWarnings().warn(ID.NOT_IMPLEMENTED, "Etc.group is not supported by JRuby on this platform", e);↵ | 23 | runtime.getWarnings().warn(ID.NOT_IMPLEMENTED, "Etc.passwd is not supported by JRuby on this platform", e);↵ | |
24 | }↵ | 24 | }↵ | |
25 | return runtime.getNil();↵ | 25 | return runtime.getNil();↵ | |
26 | } | 26 |
| |
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) | 2.7 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 51 |
Number of mapped statements | 10 |
Number of unmapped statements in the first code fragment | 5 |
Number of unmapped statements in the second code fragment | 5 |
Time elapsed for statement mapping (ms) | 6.4 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Ruby runtime = recv.getRuntime(); | 1 | Ruby runtime = recv.getRuntime(); | |||||||||||||||
2 | POSIX posix = runtime.getPosix(); | 2 | POSIX posix = runtime.getPosix(); | |||||||||||||||
3 | try |
| 3 | try | ||||||||||||||
| 4 | posix.getpwent(); | ||||||||||||||||
4 | posix.getgrent(); | | ||||||||||||||||
5 | if (block.isGiven()) | 5 | if (block.isGiven()) | |||||||||||||||
6 | ThreadContext context = runtime.getCurrentContext(); | 6 | ThreadContext context = runtime.getCurrentContext(); | |||||||||||||||
7 | posix.setgrent(); |
| 7 | posix.setpwent(); | ||||||||||||||
| 8 | Passwd pw; | ||||||||||||||||
8 | Group gr; | | ||||||||||||||||
9 | while ((gr = posix.getgrent()) != null) |
| 9 | while ((pw = posix.getpwent()) != null) | ||||||||||||||
|
| 10 | block.yield(context, setupPasswd(runtime, pw)); | |||||||||||||||
10 | block.yield(context, setupGroup(runtime, gr)); |
| | |||||||||||||||
11 | posix.endgrent(); |
| 11 | posix.endpwent(); | ||||||||||||||
|
| 12 | Passwd pw = posix.getpwent(); | |||||||||||||||
12 | Group gr = posix.getgrent(); |
| | |||||||||||||||
13 | if (gr != null) |
| 13 | if (pw != null) | ||||||||||||||
| 14 | return setupPasswd(runtime, pw); | ||||||||||||||||
14 | return setupGroup(runtime, gr); | | ||||||||||||||||
else | else | |||||||||||||||||
15 | return runtime.getNil(); | 15 | return runtime.getNil(); |
Row | Violation |
---|---|
1 | Expression posix.setgrent() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression posix.setpwent() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Type org.jruby.ext.posix.Group of variable gr does not match with type org.jruby.ext.posix.Passwd of variable pw |
4 | Unmatched statement block.yield(context,setupPasswd(runtime,pw)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
5 | Unmatched statement block.yield(context,setupGroup(runtime,gr)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
6 | Expression posix.endgrent() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression posix.endpwent() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
8 | Unmatched statement Passwd pw=posix.getpwent(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
9 | Unmatched statement Group gr=posix.getgrent(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
10 | Type org.jruby.ext.posix.Group of variable gr does not match with type org.jruby.ext.posix.Passwd of variable pw |
11 | Clone fragment #1 returns variables posix, runtime, context, gr , while Clone fragment #2 returns variables posix, runtime, context, pw |