Skip to content
a tool for code clone detection
Branch: master
Clone or download

Latest commit

Latest commit 28d787e Oct 11, 2018


Type Name Latest commit message Commit time
Failed to load latest commit information.
_output_example README: add output example May 20, 2015
job rewrite imports May 20, 2015
printer printer: fix HTML escaping Oct 11, 2018
suffixtree Make the output deterministic Sep 20, 2016
syntax rewrite imports May 20, 2015
.travis.yml .travis.yml: Run tests on Go 1.9 too Nov 18, 2017
LICENSE add LICENSE May 20, 2015 README: fix typos May 3, 2016
main.go printer: Change FileReader interface to ReadFile func type Nov 19, 2017

dupl Build Status

dupl is a tool written in Go for finding code clones. So far it can find clones only in the Go source files. The method uses suffix tree for serialized ASTs. It ignores values of AST nodes. It just operates with their types (e.g. if a == 13 {} and if x == 100 {} are considered the same provided it exceeds the minimal token sequence size).

Due to the used method dupl can report so called "false positives" on the output. These are the ones we do not consider clones (whether they are too small, or the values of the matched tokens are completely different).


go get -u


Usage of dupl:
  dupl [flags] [paths]

  If the given path is a file, dupl will use it regardless of
  the file extension. If it is a directory it will recursively
  search for *.go files in that directory.

  If no path is given dupl will recursively search for *.go
  files in the current directory.

        read file names from stdin one at each line
        output the results as HTML, including duplicate code fragments
        plumbing (easy-to-parse) output for consumption by scripts or tools
  -t, -threshold size
        minimum token sequence size as a clone (default 15)
        check files in vendor directory
  -v, -verbose
        explain what is being done

  dupl -t 100
        Search clones in the current directory of size at least
        100 tokens.
  dupl $(find app/ -name '*_test.go')
        Search for clones in tests in the app directory.
  find app/ -name '*_test.go' |dupl -files
        The same as above.


The reduced output of this command with the following parameters for the Docker source code looks like this.

$ dupl -t 200 -html >docker.html
You can’t perform that action at this time.