Module CodeDuplication

Provides classes for detecting duplicate or similar code.

Import path

external.CodeDuplication

Imports

Predicates

duplicateScopes

Find pairs of scopes that are identical or almost identical

duplicateStatement

Holds if stmt1 and stmt2 are duplicate statements in function or toplevel sc1 and sc2, respectively, where scope1 and scope2 are not the same.

duplicateStatements

Holds if sc1 is a function or toplevel with total lines, and scope2 is a function or toplevel that has duplicate lines in common with scope1.

duplicate_extension

Holds if there is a sequence of DuplicateBlocks start1, ..., end1 and another sequence start2, ..., end2 such that each block extends the previous one and corresponding blocks have the same equivalence class, with start being the equivalence class of start1 and start2, and end the equivalence class of end1 and end2.

similarScopes

Find pairs of scopes that are similar

similar_extension

Holds if there is a sequence of SimilarBlocks start1, ..., end1 and another sequence start2, ..., end2 such that each block extends the previous one and corresponding blocks have the same equivalence class, with start being the equivalence class of start1 and start2, and end the equivalence class of end1 and end2.

whitelistedLineForDuplication

Holds if the line is acceptable as a duplicate. This is true for blocks of import statements.

Classes

Copy

A token block used for detection of duplicate and similar code.

DuplicateBlock

A block of duplicated code.

SimilarBlock

A block of similar code.