int owner = -1; if (!arg1.isNil()) { owner = RubyNumeric.num2int(arg1); } int group = -1; if (!arg2.isNil()) { group = RubyNumeric.num2int(arg2); } if (!new File(path).exists()) { throw context.getRuntime().newErrnoENOENTError("No such file or directory - " + path); } return context.getRuntime().newFixnum(context.getRuntime().getPosix().lchown(path, owner, group));
int owner = -1; if (!arg1.isNil()) { owner = RubyNumeric.num2int(arg1); } int group = -1; if (!arg2.isNil()) { group = RubyNumeric.num2int(arg2); } if (!new File(path).exists()) { throw context.getRuntime().newErrnoENOENTError("No such file or directory - " + path); } return context.getRuntime().newFixnum(context.getRuntime().getPosix().chown(path, owner, group));
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyFile.java File path: /jruby-1.4.0/src/org/jruby/RubyFile.java
Method name: IRubyObject lchown(ThreadContext, IRubyObject, IRubyObject) Method name: IRubyObject chown(ThreadContext, IRubyObject, IRubyObject)
Number of AST nodes: 9 Number of AST nodes: 9
1
int owner = -1;
1
int owner = -1;
2
        if (!arg1.isNil()) {
2
        if (!arg1.isNil()) {
3
            owner = RubyNumeric.num2int(arg1);
3
            owner = RubyNumeric.num2int(arg1);
4
        }
4
        }
5
        int group = -1;
5
        int group = -1;
6
        if (!arg2.isNil()) {
6
        if (!arg2.isNil()) {
7
            group = RubyNumeric.num2int(arg2);
7
            group = RubyNumeric.num2int(arg2);
8
        }
8
        }
9
        if (!new File(path).exists()) {
9
        if (!new File(path).exists()) {
10
            throw context.getRuntime().newErrnoENOENTError("No such file or directory - " + path);
10
            throw context.getRuntime().newErrnoENOENTError("No such file or directory - " + path);
11
        }
11
        }
12
        return context.getRuntime().newFixnum(context.getRuntime().getPosix().lchown(path, owner, group));
12
        return context.getRuntime().newFixnum(context.getRuntime().getPosix().chown(path, owner, group));
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.9
Clones locationClones are declared in the same class
Number of node comparisons36
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)2.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    int owner = -1;
    1
    int owner = -1;
    2
    if (!arg1.isNil())
    2
    if (!arg1.isNil())
    3
    owner = RubyNumeric.num2int(arg1);
    3
    owner = RubyNumeric.num2int(arg1);
    4
    int group = -1;
    4
    int group = -1;
    5
    if (!arg2.isNil())
    5
    if (!arg2.isNil())
    6
    group = RubyNumeric.num2int(arg2);
    6
    group = RubyNumeric.num2int(arg2);
    7
    if (!new File(path).exists())
    7
    if (!new File(path).exists())
    8
    throw context.getRuntime().newErrnoENOENTError("No such file or directory - " + path);
    8
    throw context.getRuntime().newErrnoENOENTError("No such file or directory - " + path);
    9
    return context.getRuntime().newFixnum(context.getRuntime().getPosix().lchown(path, owner, group));
    9
    return context.getRuntime().newFixnum(context.getRuntime().getPosix().lchown(path, owner, group));
    9
    return context.getRuntime().newFixnum(context.getRuntime().getPosix().chown(path, owner, group));
    Differences
    Expression1Expression2Difference
    lchownchownMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression context.getRuntime().getPosix().lchown(path,owner,group) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression context.getRuntime().getPosix().chown(path,owner,group) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9
    return context.getRuntime().newFixnum(context.getRuntime().getPosix().chown(path, owner, group));
    Precondition Violations (2)
    Row Violation
    1Expression context.getRuntime().getPosix().lchown(path,owner,group) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression context.getRuntime().getPosix().chown(path,owner,group) cannot be parameterized, because it has dependencies to/from statements that will be extracted