• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

_output_example/H03-May-2022-

job/H11-Oct-2018-

printer/H11-Oct-2018-

suffixtree/H11-Oct-2018-

syntax/H11-Oct-2018-

.travis.ymlH A D11-Oct-201841

LICENSEH A D11-Oct-20181.1 KiB

README.mdH A D11-Oct-20182 KiB

main.goH A D11-Oct-20184.5 KiB

README.md

1# dupl [![Build Status](https://travis-ci.org/mibk/dupl.png)](https://travis-ci.org/mibk/dupl)
2
3**dupl** is a tool written in Go for finding code clones. So far it can find clones only
4in the Go source files. The method uses suffix tree for serialized ASTs. It ignores values
5of AST nodes. It just operates with their types (e.g. `if a == 13 {}` and `if x == 100 {}` are
6considered the same provided it exceeds the minimal token sequence size).
7
8Due to the used method dupl can report so called "false positives" on the output. These are
9the ones we do not consider clones (whether they are too small, or the values of the matched
10tokens are completely different).
11
12## Installation
13
14```bash
15go get -u github.com/mibk/dupl
16```
17
18## Usage
19
20```
21Usage of dupl:
22  dupl [flags] [paths]
23
24Paths:
25  If the given path is a file, dupl will use it regardless of
26  the file extension. If it is a directory it will recursively
27  search for *.go files in that directory.
28
29  If no path is given dupl will recursively search for *.go
30  files in the current directory.
31
32Flags:
33  -files
34        read file names from stdin one at each line
35  -html
36        output the results as HTML, including duplicate code fragments
37  -plumbing
38        plumbing (easy-to-parse) output for consumption by scripts or tools
39  -t, -threshold size
40        minimum token sequence size as a clone (default 15)
41  -vendor
42        check files in vendor directory
43  -v, -verbose
44        explain what is being done
45
46Examples:
47  dupl -t 100
48        Search clones in the current directory of size at least
49        100 tokens.
50  dupl $(find app/ -name '*_test.go')
51        Search for clones in tests in the app directory.
52  find app/ -name '*_test.go' |dupl -files
53        The same as above.
54```
55
56## Example
57
58The reduced output of this command with the following parameters for the [Docker](https://www.docker.com) source code
59looks like [this](http://htmlpreview.github.io/?https://github.com/mibk/dupl/blob/master/_output_example/docker.html).
60
61```bash
62$ dupl -t 200 -html >docker.html
63```
64