Ruby runtime = recv.getRuntime(); try { Group gr = runtime.getPosix().getgrent(); if (gr != null) { return setupGroup(recv.getRuntime(), gr); } else { return runtime.getNil(); } } catch (Exception e) { if (runtime.getDebug().isTrue()) { runtime.getWarnings().warn(ID.NOT_IMPLEMENTED, "Etc.getgrent is not supported by JRuby on this platform", e); } return runtime.getNil(); }
Ruby runtime = recv.getRuntime(); try { Passwd passwd = runtime.getPosix().getpwent(); if (passwd != null) { return setupPasswd(runtime, passwd); } else { return runtime.getNil(); } } catch (Exception e) { if (runtime.getDebug().isTrue()) { runtime.getWarnings().warn(ID.NOT_IMPLEMENTED, "Etc.getpwent 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 getgrent(IRubyObject) Method name: IRubyObject getpwent(IRubyObject)
Number of AST nodes: 6 Number of AST nodes: 6
1
Ruby runtime = recv.getRuntime();
1
Ruby runtime = recv.getRuntime();
2
        try {
2
        try {
3
            Group gr = runtime.getPosix().getgrent();
3
            Passwd passwd = runtime.getPosix().getpwent();
4
            if (gr != null) {
4
            if (passwd != null) {
5
                return setupGroup(recv.getRuntime(), gr);
5
                return setupPasswd(runtime, passwd);
6
            } else {
6
            } else {
7
                return runtime.getNil();
7
                return runtime.getNil();
8
            }
8
            }
9
        } catch (Exception e) {
9
        } catch (Exception e) {
10
            if (runtime.getDebug().isTrue()) {
10
            if (runtime.getDebug().isTrue()) {
11
                runtime.getWarnings().warn(ID.NOT_IMPLEMENTED, "Etc.getgrent is not supported by JRuby on this platform", e);
11
                runtime.getWarnings().warn(ID.NOT_IMPLEMENTED, "Etc.getpwent is not supported by JRuby on this platform", e);
12
            }
12
            }
13
            return runtime.getNil();
13
            return runtime.getNil();
14
        }
14
        }
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 comparisons14
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    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.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Ruby runtime = recv.getRuntime();
    1
    Ruby runtime = recv.getRuntime();
    2
    try
    2
    try
    2
    try
    Differences
    Expression1Expression2Difference
    "Etc.getgrent is not supported by JRuby on this platform""Etc.getpwent is not supported by JRuby on this platform"LITERAL_VALUE_MISMATCH
    2
    try
                                                                                                  
    3
    Passwd passwd = runtime.getPosix().getpwent();
    Preondition Violations
    Unmatched statement Passwd passwd=runtime.getPosix().getpwent(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    Passwd passwd = runtime.getPosix().getpwent();
    3
    Group gr = runtime.getPosix().getgrent();
    3
    Group gr = runtime.getPosix().getgrent();
    Preondition Violations
    Unmatched statement Group gr=runtime.getPosix().getgrent(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                        
    4
    if (gr != null)
    4
    if (gr != null)
    4
    if (passwd != null)
    Differences
    Expression1Expression2Difference
    grpasswdVARIABLE_NAME_MISMATCH
    org.jruby.ext.posix.Grouporg.jruby.ext.posix.PasswdVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jruby.ext.posix.Group of variable gr does not match with type org.jruby.ext.posix.Passwd of variable passwd
    • Make classes org.jruby.ext.posix.Group and org.jruby.ext.posix.Passwd extend a common superclass
    4
    if (passwd != null)
                                                                                
    5
    return setupPasswd(runtime, passwd);
    5
    return setupGroup(recv.getRuntime(), gr);
    5
    return setupGroup(recv.getRuntime(), gr);
    Preondition Violations
    Unmatched return setupGroup(recv.getRuntime(),gr);
                                                                                          
    else
    else
    6
    return runtime.getNil();
    6
    return runtime.getNil();
    Precondition Violations (4)
    Row Violation
    1Unmatched statement Passwd passwd=runtime.getPosix().getpwent(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement Group gr=runtime.getPosix().getgrent(); 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.Group of variable gr does not match with type org.jruby.ext.posix.Passwd of variable passwd
    4Unmatched return setupGroup(recv.getRuntime(),gr);