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 getpwnam(IRubyObject, IRubyObject)
|
Method name: IRubyObject getgrnam(IRubyObject, IRubyObject)
|
|||
Number of AST nodes: 9 | Number of AST nodes: 9 | |||
1 | Ruby runtime = recv.getRuntime();↵ | 1 | Ruby runtime = recv.getRuntime();↵ | |
2 | String nam = name.convertToString().toString();↵ | 2 | String nam = name.convertToString().toString();↵ | |
3 | try {↵ | 3 | try {↵ | |
4 | Passwd pwd = runtime.getPosix().getpwnam(nam);↵ | 4 | Group grp = runtime.getPosix().getgrnam(nam);↵ | |
5 | if(pwd == null) {↵ | 5 | if(grp == null) {↵ | |
6 | if (Platform.IS_WINDOWS) { // MRI behavior↵ | 6 | if (Platform.IS_WINDOWS) { // MRI behavior↵ | |
7 | return runtime.getNil();↵ | 7 | return runtime.getNil();↵ | |
8 | }↵ | 8 | }↵ | |
9 | throw runtime.newArgumentError("can't find user for " + nam);↵ | 9 | throw runtime.newArgumentError("can't find group for " + nam);↵ | |
10 | }↵ | 10 | }↵ | |
11 | return setupPasswd(recv.getRuntime(), pwd);↵ | 11 | return setupGroup(runtime, grp);↵ | |
12 | } catch (Exception e) {↵ | 12 | } catch (Exception e) {↵ | |
13 | if (runtime.getDebug().isTrue()) {↵ | 13 | if (runtime.getDebug().isTrue()) {↵ | |
14 | runtime.getWarnings().warn(ID.NOT_IMPLEMENTED, "Etc.getpwnam is not supported by JRuby on this platform", e);↵ | 14 | runtime.getWarnings().warn(ID.NOT_IMPLEMENTED, "Etc.getgrnam is not supported by JRuby on this platform", e);↵ | |
15 | }↵ | 15 | }↵ | |
16 | return runtime.getNil();↵ | 16 | return runtime.getNil();↵ | |
17 | } | 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 | 21 |
Number of mapped statements | 7 |
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) | 1.3 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Ruby runtime = recv.getRuntime(); | 1 | Ruby runtime = recv.getRuntime(); | |||||||||||||||
2 | String nam = name.convertToString().toString(); | 2 | String nam = name.convertToString().toString(); | |||||||||||||||
3 | try |
| 3 | try | ||||||||||||||
|
| 4 | Group grp = runtime.getPosix().getgrnam(nam); | |||||||||||||||
4 | Passwd pwd = runtime.getPosix().getpwnam(nam); |
| | |||||||||||||||
5 | if (pwd == null) |
| 5 | if (grp == null) | ||||||||||||||
6 | if (Platform.IS_WINDOWS) | 6 | if (Platform.IS_WINDOWS) | |||||||||||||||
7 | return runtime.getNil(); | 7 | return runtime.getNil(); | |||||||||||||||
8 | throw runtime.newArgumentError("can't find user for " + nam); |
| 8 | throw runtime.newArgumentError("can't find group for " + nam); | ||||||||||||||
| 9 | return setupGroup(runtime, grp); | ||||||||||||||||
9 | return setupPasswd(recv.getRuntime(), pwd); |
| |
Row | Violation |
---|---|
1 | Unmatched statement Group grp=runtime.getPosix().getgrnam(nam); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement Passwd pwd=runtime.getPosix().getpwnam(nam); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Type org.jruby.ext.posix.Passwd of variable pwd does not match with type org.jruby.ext.posix.Group of variable grp |
4 | Unmatched return setupPasswd(recv.getRuntime(),pwd); |
5 | Clone fragment #1 returns variables runtime, nam , while Clone fragment #2 returns variables runtime, nam |