Ruby runtime = recv.getRuntime(); String nam = name.convertToString().toString(); try { Passwd pwd = runtime.getPosix().getpwnam(nam); if(pwd == null) { if (Platform.IS_WINDOWS) { // MRI behavior return runtime.getNil(); } throw runtime.newArgumentError("can't find user for " + nam); } return setupPasswd(recv.getRuntime(), pwd); } catch (Exception e) { if (runtime.getDebug().isTrue()) { runtime.getWarnings().warn(ID.NOT_IMPLEMENTED, "Etc.getpwnam is not supported by JRuby on this platform", e); } return runtime.getNil(); }
Ruby runtime = recv.getRuntime(); String nam = name.convertToString().toString(); try { Group grp = runtime.getPosix().getgrnam(nam); if(grp == null) { if (Platform.IS_WINDOWS) { // MRI behavior return runtime.getNil(); } throw runtime.newArgumentError("can't find group for " + nam); } return setupGroup(runtime, grp); } catch (Exception e) { if (runtime.getDebug().isTrue()) { runtime.getWarnings().warn(ID.NOT_IMPLEMENTED, "Etc.getgrnam is not supported by JRuby on this platform", e); } return runtime.getNil(); }
Clone fragments detected by clone detection tool
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
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.5
Clones locationClones are declared in the same class
Number of node comparisons21
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)1.3
    Clone typeType 2
    Mapped Statements
    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
    3
    try
    Differences
    Expression1Expression2Difference
    "Etc.getpwnam is not supported by JRuby on this platform""Etc.getgrnam is not supported by JRuby on this platform"LITERAL_VALUE_MISMATCH
    3
    try
                                                                                                
    4
    Group grp = runtime.getPosix().getgrnam(nam);
    Preondition Violations
    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
    4
    Group grp = runtime.getPosix().getgrnam(nam);
    4
    Passwd pwd = runtime.getPosix().getpwnam(nam);
    4
    Passwd pwd = runtime.getPosix().getpwnam(nam);
    Preondition Violations
    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
                                                                                                  
    5
    if (pwd == null)
    5
    if (pwd == null)
    5
    if (grp == null)
    Differences
    Expression1Expression2Difference
    pwdgrpVARIABLE_NAME_MISMATCH
    org.jruby.ext.posix.Passwdorg.jruby.ext.posix.GroupVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jruby.ext.posix.Passwd of variable pwd does not match with type org.jruby.ext.posix.Group of variable grp
    • Make classes org.jruby.ext.posix.Passwd and org.jruby.ext.posix.Group extend a common superclass
    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 user for " + nam);
    8
    throw runtime.newArgumentError("can't find group for " + nam);
    Differences
    Expression1Expression2Difference
    "can't find user for ""can't find group for "LITERAL_VALUE_MISMATCH
    8
    throw runtime.newArgumentError("can't find group for " + nam);
                                                                        
    9
    return setupGroup(runtime, grp);
    9
    return setupPasswd(recv.getRuntime(), pwd);
    9
    return setupPasswd(recv.getRuntime(), pwd);
    Preondition Violations
    Unmatched return setupPasswd(recv.getRuntime(),pwd);
                                                                                              
    Precondition Violations (5)
    Row Violation
    1Unmatched 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
    2Unmatched 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
    3Type org.jruby.ext.posix.Passwd of variable pwd does not match with type org.jruby.ext.posix.Group of variable grp
    4Unmatched return setupPasswd(recv.getRuntime(),pwd);
    5Clone fragment #1 returns variables runtime, nam , while Clone fragment #2 returns variables runtime, nam