You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have Docker, the way to run Duplo is to use this command:
83
85
@@ -88,34 +90,52 @@ If you have Docker, the way to run Duplo is to use this command:
88
90
89
91
This pulls the latest image and runs duplo. Note that you'll have to pipe the filenames into this command. A complete commandline sample will be shown below.
90
92
91
-
### 1.4.2. Pre-built binaries
93
+
### 4.2. Pre-built binaries
92
94
93
95
Duplo is also available as a pre-built binary for (alpine) linux and macos. Grab the executable from the [releases](https://github.com/dlidstrom/Duplo/releases) page.
94
96
95
97
You can of course build from source as well, and you'll have to do so to get a binary for Windows.
96
98
97
-
## 1.5. Usage
99
+
## 5. Usage
98
100
99
101
Duplo works with a list of files. You can either specify a file that contains the list of files, or you can pass them using `stdin`.
100
102
101
103
Run `duplo --help` on the command line to see the detailed options.
102
104
103
-
### 1.5.1. Passing files using `stdin`
105
+
### 5.1. Passing files using `stdin`
106
+
107
+
In each of the following commands, `duplo` will write the duplicated blocks into `out.txt` in addition to the information written to stdout.
Let's break this down. `find . -type f \( -iname "*.cpp" -o -iname "*.h" \)` is a syntax to look recursively in the current directory (the `.` part) for files (the `-type f` part) matching `*.cpp` or `*.h` (case insensitive). The output from `find` is piped into `duplo` which then reads the filenames from `stdin` (the `-` tells `duplo` to get the filenames from `stdin`, a common unix convention in many commandline applications). The result of the analysis is then written to `out.txt`.
In each of the above commands, `duplo` will write the duplicated blocks into `out.txt`in addition to the information written to stdout.
134
+
This command also works in a similar fashion to the Bash command, but instead of piping into a local`duplo` executable, it will pipe into `duplo` running inside Docker. This is very convenient as you do not have to install `duplo` separately. You will have to install Docker though, if you haven't already. That is a good thing to do anyway, since it opens up a lot of possibilities apart from running `duplo`.
135
+
136
+
Again, similarly to the Bash command, this uses `find` to find files in the current directory, then passes the file list to Docker which will pass it further into an instance of the latest version of `duplo`. The working directory in the `duplo` container should be `/src` (that's where the `duplo` executable is located) and the current path of your host machine will be mapped to `/src` when the container is running. The `-i` allows `stdin` of your host machine to be passed into Docker to allow `duplo` to read the filenames. Any parameters to `duplo` can be placed at the end of the command as you can see `- out.txt` has been.
117
137
118
-
### 1.5.2. Passing files using file
138
+
### 5.2. Passing files using file
119
139
120
140
`duplo` can analyze files specified in a separate file:
121
141
@@ -135,30 +155,30 @@ In each of the above commands, `duplo` will write the duplicated blocks into `ou
135
155
136
156
Again, the duplicated blocks are written to `out.txt`.
137
157
138
-
### 1.5.3. Xml output
158
+
### 5.3. Xml output
139
159
140
160
Duplo can also output xml and there is a stylesheet that will format the result forviewingin a browser. This can be used as a report tab in your continuous integration tool (TeamCity, etc).
141
161
142
-
## 1.6. Feedback and Bug Reporting
162
+
## 6. Feedback and Bug Reporting
143
163
144
164
Please open an issue to discuss feedback,
145
165
feature requests and bug reports.
146
166
147
-
## 1.7. Algorithm Background
167
+
## 7. Algorithm Background
148
168
149
169
Duplo uses the same techniques as Duploc to detect duplicated code blocks. See
150
170
[Duca99bCodeDuplication](http://scg.unibe.ch/archive/papers/Duca99bCodeDuplication.pdf) for
151
171
further information.
152
172
153
-
### 1.7.1. Performance Measurements
173
+
### 7.1. Performance Measurements
154
174
155
175
| System | Files | Loc's | Time |
156
176
|-|-|-|-|
157
177
| Quake2 | 266 | 102740 | 18sec |
158
178
159
-
## 1.8. Developing
179
+
## 8. Developing
160
180
161
-
### 1.8.1. Unix
181
+
### 8.1. Unix
162
182
163
183
You need `CMake` and preferrably `fswatch` for the best experience.
164
184
@@ -183,11 +203,11 @@ build/> popd
183
203
> ./watch.sh
184
204
```
185
205
186
-
### 1.8.2. Windows
206
+
### 8.2. Windows
187
207
188
208
Use Visual Studio 2019 to open the included solution file (or try `CMake`).
189
209
190
-
### 1.8.3. Additional Language Support
210
+
### 8.3. Additional Language Support
191
211
192
212
Duplo can analyze all text files regardless of format, but it has special support for some programming languages (C++, C#, Java, for example). This allows Duplo to improve the duplication detection as it can ignore preprocessor directives and/or comments.
193
213
@@ -196,7 +216,7 @@ To implement support for a new language, there are a couple of options (in order
196
216
1. Implement `FileTypeBase` which has support for handling comments and preprocessor directives. You just need to decide what is a comment. With this option you need to implement a couple of methods, one which is `CreateLineFilter`. This is to remove multiline comments. Look at `CstyleCommentsFilter` for an example.
197
217
2. Implement `IFileType` interface directly. This gives you the most freedom but also is the hardest option of course.
198
218
199
-
### 1.8.4. Language Suggestions
219
+
### 8.4. Language Suggestions
200
220
201
221
- JavaScript (easy, just look at the existing C-based ones)
202
222
- Ruby
@@ -212,7 +232,7 @@ To implement support for a new language, there are a couple of options (in order
212
232
213
233
Send me a pull request!
214
234
215
-
## 1.9. Changes
235
+
## 9. Changes
216
236
217
237
- 0.5
218
238
- Fixed malformed xml (thanks [@ArsMasiuk](https://github.com/ArsMasiuk)!)
@@ -228,7 +248,7 @@ Send me a pull request!
228
248
- Fixed limitation of total number of lines of code
229
249
- Checking of arbitrary files
230
250
231
-
## 1.10. License
251
+
## 10. License
232
252
233
253
Duplo is free software; you can redistribute it and/or modify
234
254
it under the terms of the GNU General Public License as published by
0 commit comments