-
Notifications
You must be signed in to change notification settings - Fork 16
/
jscpd.node_cli.txt
194 lines (150 loc) · 10.1 KB
/
jscpd.node_cli.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
JSCPD
VERSION ==> #4.0.4
ALTERNATIVES ==> # - jscpd (prefered): multi-languages
# - jsinspect: JavaScript-only, does not always work correctly
# - synt: less options, TypeScript-oriented, less popular
GOAL ==> #Detect code duplication:
# - tokenize with reprism
# - support many programming languages
# - including embedding, e.g. `<script>` in HTML
# - compare token types (not values/names)
/=+===============================+=\
/ : : \
)==: CONFIG :==(
\ :_______________________________: /
\=+===============================+=/
CONF ==> #Can be:
# - PACKAGE_ROOT/.jscpd.json
# - PACKAGE.jscpd OBJ
# - CONF.config JSON_FILE
# - JSPCD.run(CONF)
# - jspcd --CONF_VAR CONF_VAL (dasherized)
/=+===============================+=\
/ : : \
)==: SKIP :==(
\ :_______________________________: /
\=+===============================+=/
/* jscpd:ignore-start|end */
<!-- jscpd:ignore-start|end --> #
/=+===============================+=\
/ : : \
)==: OPTIONS :==(
\ :_______________________________: /
\=+===============================+=/
CONF.path #'DIR'_ARR to include
CONF.ignore #'GLOB'_ARR to exclude
#Use minimatch (see its doc)
CONF.gitignore #BOOL (def: true). Use .gitignore
CONF.format #STR_ARR. Format/languages.
#Def: all.
#Run jscpd --list to see available ones
CONF.formatExts #'FORMAT:EXT,...;...'
#Determine the LANGUAGE according to file extension
#Def: see source code
CONF.silent #BOOL (def: false)
CONF.debug #BOOL (def: false)
CONF.blame #BOOL (def: false). Show authors and dates.
#Implies verbose
CONF.exitCode #NUM (def: 0). When duplicates are detected
CONF.reporters #STR_ARR
#Among:
# - console (def)
# - consoleFull: show code snippets (only of first one for each duplication)
# - time (always added on CLI): show execution time
# - verbose
# - badge: SVG
# - json: to jscpd-report.json
# - xml
# - html
# - markdown
# - csv
# - sarif
CONF.output #DIR for json|xml|html reporters (def: ./report)
CONF.absolute #BOOL (def: false). Use absolute paths in reports.
CONF.xslHref #FILE. Used with XML and XSL
CONF.minTokens #Duplication must be at least NUM tokens long to be reported
#Def: 50
#Note: tokens include small things like . ; ( ) { }
CONF.min|maxLines #Do not report if file is less|more than NUM lines long
#Def: 5|1000
#0 means infinite
CONF.maxSize #Do not report if file is more than STR bytes long (uses bytes, see its doc)
#Def: '100kb'
CONF.threshold #NUM (0-100). Def: none
#Exit code of 1 if duplicated lines percentage is above NUM
CONF.mode #Can be:
# - strict
# - mild (def): skip empty lines and empty symbols
# - weak: skip empty lines, empty symbols and comments
CONF.ignoreCase #BOOL (def: false). Ignore token case.
CONF.noSymlinks #BOOL (def: false). Do not follow symlinked directories.
CONF.skipLocal #'DIR'_ARR. Only report duplicates between different DIRs
CONF.store #Can be:
# - 'memory' (def):
# - does not work with really huge repos
# - 'leveldb':
# - 33% slower
# - creates intermediary .jscpd/ folder
# - 'redis'
/=+===============================+=\
/ : : \
)==: BADGE :==(
\ :_______________________________: /
\=+===============================+=/
JSCPD-BADGE-REPORTER ==> ##Creates a badge with duplication percentage
##See its doc
/=+===============================+=\
/ : : \
)==: CLI :==(
\ :_______________________________: /
\=+===============================+=/
jspcd [FILE|DIR...] #As CLI
#Def FILE|DIR: .
CONF.pattern #'GLOB' appended to any DIR (def: '**/*')
CONF.ignorePattern #'GLOB'. Ignore code blocks matching this.
/=+===============================+=\
/ : : \
)==: PROGRAMMATIC :==(
\ :_______________________________: /
\=+===============================+=/
jscpd('ARG'_ARR)
->PROMISE_CLONE_ARR #Simpler API, to prefer
@jscpd/core #
new Statistic([CONF]) #STATISTIC. Aggregates detection stats state
new Detector(TOKENIZER, STORE,
STATISTIC[, CONF]) #
DETECTOR.detect(FILE_ARR) #Find duplicates
->CLONE_ARR #Also trigger reporters
CLONE.format #'FORMAT'
CLONE.isNew #BOOL
CLONE.foundDate #DATE_NUM
CLONE.duplicationA|B #DUP
DUP.sourceId #STR
DUP.start|end.line|column #NUM
DUP.range #NUM_ARR
DUP.fragment #STR
DUP.blame.rev|author|date|line #STR
new MemoryStore() #STORE
@jscpd/leveldb-store #
new LevelDbStore() #STORE
@jscpd/redis-store #
new RedisStore() #STORE
@jscpd/tokenizer #
new Tokenizer() #
TOKENIZER.generateMaps
('ID', 'SOURCE', 'FORMAT'[,CONF])
->TOKENS_ARR #
TOKEN.format #'FORMAT'
TOKEN.type #STR
TOKEN.content #STR
TOKEN.length #NUM
@jscpd/finder #
getFilesToDetect([CONF])->FILE_ARR#Retrieve list of files to check after applying
#CONF.path|ignore|absolute|noSymlinks|format|formatExts|maxSize|minLines|maxLines
FILE.path #STR
FILE.name #STR
FILE.content #STR
FILE.stats #FSSTAT
FILE.dirent #OBJ: isBlockDevice(), etc. like FSSTAT.*