Ruby runtime = context.getRuntime(); int count = 0; RubyInteger mode = args[0].convertToInteger(); for (int i = 1; i < args.length; i++) { RubyString filename = get_path(context, args[i]); if (!RubyFileTest.exist_p(filename, filename).isTrue()) { throw runtime.newErrnoENOENTError("No such file or directory - " + filename); } boolean result = 0 == runtime.getPosix().lchmod(filename.getUnicodeValue(), (int)mode.getLongValue()); if (result) { count++; } } return runtime.newFixnum(count);
Ruby runtime = context.getRuntime(); int count = 0; RubyInteger mode = args[0].convertToInteger(); for (int i = 1; i < args.length; i++) { RubyString filename = get_path(context, args[i]); if (!RubyFileTest.exist_p(filename, filename).isTrue()) { throw runtime.newErrnoENOENTError("No such file or directory - " + filename); } boolean result = 0 == runtime.getPosix().chmod(filename.getUnicodeValue(), (int)mode.getLongValue()); if (result) { count++; } } return runtime.newFixnum(count);
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 lchmod(ThreadContext, IRubyObject, IRubyObject[]) Method name: IRubyObject chmod(ThreadContext, IRubyObject, IRubyObject[])
Number of AST nodes: 11 Number of AST nodes: 11
1
Ruby runtime = context.getRuntime();
1
Ruby runtime = context.getRuntime();
2
        
2
        
3
        int count = 0;
3
        int count = 0;
4
        RubyInteger mode = args[0].convertToInteger();
4
        RubyInteger mode = args[0].convertToInteger();
5
        for (int i = 1; i < args.length; i++) {
5
        for (int i = 1; i < args.length; i++) {
6
            RubyString filename = get_path(context, args[i]);
6
            RubyString filename = get_path(context, args[i]);
7
            
7
            
8
            if (!RubyFileTest.exist_p(filename, filename).isTrue()) {
8
            if (!RubyFileTest.exist_p(filename, filename).isTrue()) {
9
                throw runtime.newErrnoENOENTError("No such file or directory - " + filename);
9
                throw runtime.newErrnoENOENTError("No such file or directory - " + filename);
10
            }
10
            }
11
            
11
            
12
            boolean result = 0 == runtime.getPosix().lchmod(filename.getUnicodeValue(), (int)mode.getLongValue());
12
            boolean result = 0 == runtime.getPosix().chmod(filename.getUnicodeValue(), (int)mode.getLongValue());
13
            if (result) {
13
            if (result) {
14
                count++;
14
                count++;
15
            }
15
            }
16
        }
16
        }
17
        
17
        
18
        return runtime.newFixnum(count);
18
        return runtime.newFixnum(count);
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.4
Clones locationClones are declared in the same class
Number of node comparisons38
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements11
    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.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Ruby runtime = context.getRuntime();
    1
    Ruby runtime = context.getRuntime();
    2
    int count = 0;
    2
    int count = 0;
    3
    RubyInteger mode = args[0].convertToInteger();
    3
    RubyInteger mode = args[0].convertToInteger();
    4
    for (int i = 1; i < args.length; i++)
    4
    for (int i = 1; i < args.length; i++)
    5
    RubyString filename = get_path(context, args[i]);
    5
    RubyString filename = get_path(context, args[i]);
    6
    if (!RubyFileTest.exist_p(filename, filename).isTrue())
    6
    if (!RubyFileTest.exist_p(filename, filename).isTrue())
    7
    throw runtime.newErrnoENOENTError("No such file or directory - " + filename);
    7
    throw runtime.newErrnoENOENTError("No such file or directory - " + filename);
    8
    boolean result = 0 == runtime.getPosix().lchmod(filename.getUnicodeValue(), (int)mode.getLongValue());
    8
    boolean result = 0 == runtime.getPosix().lchmod(filename.getUnicodeValue(), (int)mode.getLongValue());
    8
    boolean result = 0 == runtime.getPosix().chmod(filename.getUnicodeValue(), (int)mode.getLongValue());
    Differences
    Expression1Expression2Difference
    lchmodchmodMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression runtime.getPosix().lchmod(filename.getUnicodeValue(),(int)mode.getLongValue()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression runtime.getPosix().chmod(filename.getUnicodeValue(),(int)mode.getLongValue()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8
    boolean result = 0 == runtime.getPosix().chmod(filename.getUnicodeValue(), (int)mode.getLongValue());
    9
    if (result)
    9
    if (result)
    10
    count++;
    10
    count++;
    11
    return runtime.newFixnum(count);
    11
    return runtime.newFixnum(count);
    Precondition Violations (2)
    Row Violation
    1Expression runtime.getPosix().lchmod(filename.getUnicodeValue(),(int)mode.getLongValue()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression runtime.getPosix().chmod(filename.getUnicodeValue(),(int)mode.getLongValue()) cannot be parameterized, because it has dependencies to/from statements that will be extracted