ArgsFileData data = ArgsFileData.getDataFrom(recv); Ruby runtime = context.getRuntime(); if (!data.next_argv(context)) { return runtime.is1_9() ? runtime.newEmptyArray() : runtime.getNil(); } if (!(data.currentFile instanceof RubyIO)) { return data.currentFile.callMethod(context, "to_a", args); } RubyArray ary = runtime.newArray(); IRubyObject line; while(!(line = argf_getline(context, recv, args)).isNil()) { ary.append(line); } return ary;
ArgsFileData data = ArgsFileData.getDataFrom(recv); Ruby runtime = context.getRuntime(); if (!data.next_argv(context)) { return runtime.is1_9() ? runtime.newEmptyArray() : runtime.getNil(); } if (!(data.currentFile instanceof RubyIO)) { return data.currentFile.callMethod(context, "readlines", args); } RubyArray ary = runtime.newArray(); IRubyObject line; while(!(line = argf_getline(context, recv, args)).isNil()) { ary.append(line); } return ary;
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyArgsFile.java File path: /jruby-1.4.0/src/org/jruby/RubyArgsFile.java
Method name: IRubyObject to_a(ThreadContext, IRubyObject, IRubyObject[]) Method name: IRubyObject readlines(ThreadContext, IRubyObject, IRubyObject[])
Number of AST nodes: 11 Number of AST nodes: 11
1
ArgsFileData data = ArgsFileData.getDataFrom(recv);
1
ArgsFileData data = ArgsFileData.getDataFrom(recv);
2
        Ruby runtime = context.getRuntime();
2
        Ruby runtime = context.getRuntime();
3
        
3
        
4
        if (!data.next_argv(context)) {
4
        if (!data.next_argv(context)) {
5
            return runtime.is1_9() ? runtime.newEmptyArray() : runtime.getNil();
5
            return runtime.is1_9() ? runtime.newEmptyArray() : runtime.getNil();
6
        }
6
        }
7
        if (!(data.currentFile instanceof RubyIO)) {
7
        if (!(data.currentFile instanceof RubyIO)) {
8
            return data.currentFile.callMethod(context, "to_a", args);
8
            return data.currentFile.callMethod(context, "readlines", args);
9
        }
9
        }
10
        
10
        
11
        RubyArray ary = runtime.newArray();
11
        RubyArray ary = runtime.newArray();
12
        IRubyObject line;
12
        IRubyObject line;
13
        while(!(line = argf_getline(context, recv, args)).isNil()) {
13
        while(!(line = argf_getline(context, recv, args)).isNil()) {
14
            ary.append(line);
14
            ary.append(line);
15
        }
15
        }
16
        return ary;
16
        return ary;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.7
Clones locationClones are declared in the same class
Number of node comparisons52
  1. {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)4.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    ArgsFileData data = ArgsFileData.getDataFrom(recv);
    1
    ArgsFileData data = ArgsFileData.getDataFrom(recv);
    2
    Ruby runtime = context.getRuntime();
    2
    Ruby runtime = context.getRuntime();
    3
    if (!data.next_argv(context))
    3
    if (!data.next_argv(context))
    4
    return runtime.is1_9() ? runtime.newEmptyArray() : runtime.getNil();
    4
    return runtime.is1_9() ? runtime.newEmptyArray() : runtime.getNil();
    5
    if (!(data.currentFile instanceof RubyIO))
    5
    if (!(data.currentFile instanceof RubyIO))
    6
    return data.currentFile.callMethod(context, "to_a", args);
    6
    return data.currentFile.callMethod(context, "to_a", args);
    6
    return data.currentFile.callMethod(context, "readlines", args);
    Differences
    Expression1Expression2Difference
    "to_a""readlines"LITERAL_VALUE_MISMATCH
    6
    return data.currentFile.callMethod(context, "readlines", args);
    7
    RubyArray ary = runtime.newArray();
    7
    RubyArray ary = runtime.newArray();
    8
    IRubyObject line;
    8
    IRubyObject line;
    9
    while (!(line = argf_getline(context, recv, args)).isNil())
    9
    while (!(line = argf_getline(context, recv, args)).isNil())
    10
    ary.append(line);
    10
    ary.append(line);
    11
    return ary;
    11
    return ary;
    Precondition Violations (0)
    Row Violation