Ruby runtime = recv.getRuntime(); ZipEntry entry = file_in_archive(filename); if (entry != null) { return entry.isDirectory() ? recv.getRuntime().getFalse() : recv.getRuntime().getTrue(); } JRubyFile file = file(filename); return runtime.newBoolean(file.exists() && file.isFile());
Ruby runtime = recv.getRuntime(); ZipEntry entry = file_in_archive(filename); if (entry != null) { return entry.isDirectory() ? recv.getRuntime().getFalse() : recv.getRuntime().getTrue(); } JRubyFile file = file(filename); return runtime.newBoolean(file.exists() && file.canRead());
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyFileTest.java File path: /jruby-1.4.0/src/org/jruby/RubyFileTest.java
Method name: RubyBoolean file_p(IRubyObject, IRubyObject) Method name: IRubyObject readable_p(IRubyObject, IRubyObject)
Number of AST nodes: 6 Number of AST nodes: 6
1
Ruby runtime = recv.getRuntime();
1
Ruby runtime = recv.getRuntime();
2
        ZipEntry entry = file_in_archive(filename);
2
        ZipEntry entry = file_in_archive(filename);
3
        if (entry != null) {
3
        if (entry != null) {
4
            return entry.isDirectory() ?
4
            return entry.isDirectory() ?
5
                recv.getRuntime().getFalse() :
5
                recv.getRuntime().getFalse() :
6
                recv.getRuntime().getTrue();
6
                recv.getRuntime().getTrue();
7
        }
7
        }
8
        JRubyFile file = file(filename);
8
        JRubyFile file = file(filename);
9
        return runtime.newBoolean(file.exists() && file.isFile());
9
        return runtime.newBoolean(file.exists() && file.canRead());
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.1
Clones locationClones are declared in the same class
Number of node comparisons20
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)1.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Ruby runtime = recv.getRuntime();
    1
    Ruby runtime = recv.getRuntime();
    2
    ZipEntry entry = file_in_archive(filename);
    2
    ZipEntry entry = file_in_archive(filename);
    3
    if (entry != null)
    3
    if (entry != null)
    4
    return entry.isDirectory() ? recv.getRuntime().getFalse() : recv.getRuntime().getTrue();
    4
    return entry.isDirectory() ? recv.getRuntime().getFalse() : recv.getRuntime().getTrue();
    5
    JRubyFile file = file(filename);
    5
    JRubyFile file = file(filename);
    6
    return runtime.newBoolean(file.exists() && file.isFile());
    6
    return runtime.newBoolean(file.exists() && file.isFile());
    6
    return runtime.newBoolean(file.exists() && file.canRead());
    Differences
    Expression1Expression2Difference
    isFilecanReadMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression file.isFile() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression file.canRead() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    return runtime.newBoolean(file.exists() && file.canRead());
    Precondition Violations (2)
    Row Violation
    1Expression file.isFile() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression file.canRead() cannot be parameterized, because it has dependencies to/from statements that will be extracted