1package jscpd
2
3import "strings"
4
5#Schema: {
6 @jsonschema(schema="http://json-schema.org/draft-07/schema#")
7 @jsonschema(id="https://json.schemastore.org/jscpd.json")
8 close({
9 // minimum size of code block in lines to check for duplication
10 "minLines"?: int
11
12 // maximum size of source file in lines to check for duplication
13 "maxLines"?: int
14
15 // maximum size of source file in bytes to check for duplication
16 // (e.g., 102400, 1kb, 1m, 120kb)
17 "maxSize"?: matchN(>=1, [=~"^\\+?[0-9]+(\\.[0-9]+)? *([kKmMgGtTpP]?[bB]|[kKmMgG])?$", int])
18
19 // minimum size of code block in tokens to check for duplication
20 "minTokens"?: int
21
22 // maximum allowed duplicate lines expressed as a percentage; exit
23 // with error and exit code 1 when threshold exceeded
24 "threshold"?: number
25 "formatsExts"?: #formatMapping
26
27 // path to directory for non-console reports
28 "output"?: string
29
30 // paths that should be included in duplicate detection (default:
31 // [process.cwd()])
32 "path"?: [...string]
33
34 // glob pattern for files that should be included in duplicate
35 // detection (e.g., **/*.txt); only used to filter directories
36 // configured via path option
37 "pattern"?: string
38
39 // ignore code blocks matching these regular expressions
40 "ignorePattern"?: [...string]
41
42 // mode of detection quality; see
43 // https://github.com/kucherenko/jscpd/blob/master/packages/jscpd/README.md#mode
44 "mode"?: "mild" | "strict" | "weak"
45
46 // glob pattern for files that should be excluded from duplicate
47 // detection
48 "ignore"?: [...string]
49
50 // format or list of formats for which to detect duplication
51 // (default: all); see
52 // https://github.com/kucherenko/jscpd/blob/master/FORMATS.md
53 "format"?: matchN(1, [[...#format], #format])
54
55 // store used to collect information about code. v4 supports
56 // external stores such as leveldb and redis; v5 reports this
57 // config field as migrated to the CLI --store flag.
58 "store"?: matchN(>=1, ["leveldb" | "redis", strings.MinRunes(1)])
59
60 // a list of reporters to use to output information about
61 // duplication; built-ins include console,
62 // consoleFull/console-full, json, xml, csv, html, markdown,
63 // badge, sarif, ai, xcode, threshold, and silent; third-party
64 // reporters are also supported
65 "reporters"?: [...#reporter]
66
67 // get information about authors and dates of duplicated blocks
68 // from Git
69 "blame"?: bool
70
71 // do not write duplicate detection progress and result to console
72 "silent"?: bool
73
74 // show full information during duplicate detection
75 "verbose"?: bool
76
77 // use absolute paths in reports
78 "absolute"?: bool
79
80 // do not follow symlinks
81 "noSymlinks"?: bool
82
83 // skip duplicates within folders; just detect cross-folder
84 // duplicates
85 "skipLocal"?: bool
86
87 // ignore case of symbols in code (experimental)
88 "ignoreCase"?: bool
89
90 // respect .gitignore files. Enabled by default in current jscpd;
91 // set false to opt out in v4 configs.
92 "gitignore"?: bool
93 "reportersOptions"?: {
94 "badge"?: close({
95 // output path for duplication level badge (default:
96 // path.join(output, 'jscpd-badge.svg'))
97 "path"?: string
98
99 // badge subject text (URL-encoding needed for spaces or special
100 // characters)
101 "label"?: string
102 "labelColor"?: #color
103
104 // badge value text (URL-encoding needed for spaces or special
105 // characters, default: duplication %)
106 "status"?: string
107 "color"?: #color
108
109 // badge look: flat or classic
110 "style"?: "flat" | "classic"
111
112 // URL for icon to display in front of badge subject text (e.g.,
113 // data:image/svg+xml;base64,...)
114 "icon"?: string
115
116 // SVG width of icon to display in front of badge subject text;
117 // set this if icon is not square
118 "iconWidth"?: number
119
120 // size of badge relative to default of 1
121 "scale"?: number
122 })
123 ...
124 }
125
126 // exit code to use when at least one duplicate code block is
127 // detected but threshold is not exceeded
128 "exitCode"?: int
129 "formatsNames"?: #formatMapping
130
131 // v5 alias for format; format or list of formats for which to
132 // detect duplication
133 "formats"?: matchN(1, [[...#format], #format])
134
135 // directory used by the v4 store for cache files, useful for
136 // isolating parallel LevelDB runs. v5 reports this config field
137 // as migrated to the CLI --store-path flag.
138 "storePath"?: string
139
140 // v5 config field matching --no-gitignore; do not respect
141 // .gitignore files
142 "noGitignore"?: bool
143
144 // v5 config field matching --follow-symlinks; follow symbolic
145 // links
146 "followSymlinks"?: bool
147
148 // compatibility alias for noSymlinks with a capital L; prefer
149 // noSymlinks or followSymlinks
150 "noSymLinks"?: bool
151
152 // disable ANSI color output
153 "noColors"?: bool
154
155 // suppress tips and promotional messages after detection
156 "noTips"?: bool
157
158 // show debug information and do not run detection in v4; silently
159 // ignored by v5 config compatibility handling
160 "debug"?: bool
161
162 // v5 kebab-case alias for minTokens. minimum size of code block
163 // in tokens to check for duplication
164 "min-tokens"?: int
165
166 // v5 kebab-case alias for minLines. minimum size of code block in
167 // lines to check for duplication
168 "min-lines"?: int
169
170 // v5 kebab-case alias for maxLines. maximum size of source file
171 // in lines to check for duplication
172 "max-lines"?: int
173
174 // v5 kebab-case alias for maxSize. maximum size of source file in
175 // bytes to check for duplication (e.g., 102400, 1kb, 1m, 120kb)
176 "max-size"?: matchN(>=1, [=~"^\\+?[0-9]+(\\.[0-9]+)? *([kKmMgGtTpP]?[bB]|[kKmMgG])?$", int])
177
178 // v5 kebab-case alias for ignorePattern. ignore code blocks
179 // matching these regular expressions
180 "ignore-pattern"?: [...string]
181
182 // v5 kebab-case alias for ignoreCase. ignore case of symbols in
183 // code (experimental)
184 "ignore-case"?: bool
185
186 // v5 kebab-case alias for noGitignore. v5 config field matching
187 // --no-gitignore; do not respect .gitignore files
188 "no-gitignore"?: bool
189
190 // v5 kebab-case alias for followSymlinks. v5 config field
191 // matching --follow-symlinks; follow symbolic links
192 "follow-symlinks"?: bool
193
194 // v5 kebab-case alias for skipLocal. skip duplicates within
195 // folders; just detect cross-folder duplicates
196 "skip-local"?: bool
197
198 // v5 kebab-case alias for exitCode. exit code to use when at
199 // least one duplicate code block is detected but threshold is
200 // not exceeded
201 "exit-code"?: int
202
203 // v5 kebab-case alias for noColors. disable ANSI color output
204 "no-colors"?: bool
205
206 // v5 kebab-case alias for noTips. suppress tips and promotional
207 // messages after detection
208 "no-tips"?: bool
209 "formats-exts"?: #formatMapping
210 "formats-names"?: #formatMapping
211 })
212
213 #color: matchN(1, [#colorPreset, #colorHex])
214
215 #colorHex: =~"([0-9a-fA-F]{3}){1,2}"
216
217 #colorPreset: "green" | "blue" | "red" | "yellow" | "orange" | "purple" | "pink" | "grey" | "gray" | "cyan" | "black"
218
219 #format: matchN(>=1, ["abap" | "actionscript" | "ada" | "apacheconf" | "apl" | "applescript" | "arduino" | "arff" | "asciidoc" | "asm6502" | "aspnet" | "autohotkey" | "autoit" | "bash" | "basic" | "batch" | "bison" | "brainfuck" | "bro" | "c" | "c-header" | "clike" | "clojure" | "coffeescript" | "comments" | "cpp" | "cpp-header" | "crystal" | "csharp" | "csp" | "css-extras" | "css" | "d" | "dart" | "diff" | "django" | "docker" | "eiffel" | "elixir" | "elm" | "erb" | "erlang" | "flow" | "fortran" | "fsharp" | "gdscript" | "gedcom" | "gherkin" | "git" | "glsl" | "go" | "graphql" | "groovy" | "haml" | "handlebars" | "haskell" | "haxe" | "hpkp" | "hsts" | "http" | "ichigojam" | "icon" | "inform7" | "ini" | "io" | "j" | "java" | "javascript" | "jolie" | "json" | "jsx" | "julia" | "keymap" | "kotlin" | "latex" | "less" | "liquid" | "lisp" | "livescript" | "lolcode" | "lua" | "makefile" | "markdown" | "markup" | "matlab" | "mel" | "mizar" | "monkey" | "n4js" | "nasm" | "nginx" | "nim" | "nix" | "nsis" | "objectivec" | "ocaml" | "opencl" | "oz" | "parigp" | "pascal" | "perl" | "php" | "plsql" | "powershell" | "processing" | "prolog" | "properties" | "protobuf" | "pug" | "puppet" | "pure" | "python" | "q" | "qore" | "r" | "razor" | "reason" | "renpy" | "rest" | "rip" | "roboconf" | "ruby" | "rust" | "sas" | "sass" | "scala" | "scheme" | "scss" | "svelte" | "smalltalk" | "smarty" | "soy" | "sql" | "stylus" | "swift" | "tap" | "tcl" | "textile" | "tsx" | "tt2" | "twig" | "typescript" | "txt" | "vbnet" | "velocity" | "verilog" | "vhdl" | "vim" | "visual-basic" | "astro" | "vue" | "wasm" | "wiki" | "xeora" | "xojo" | "xquery" | "yaml" | "abnf" | "agda" | "antlr4" | "apex" | "aql" | "armasm" | "awk" | "bicep" | "bnf" | "cfscript" | "cfml" | "cmake" | "cobol" | "csv" | "cypher" | "dhall" | "dns-zone-file" | "dot" | "ebnf" | "editorconfig" | "excel-formula" | "factor" | "ftl" | "gcode" | "gettext" | "gml" | "go-module" | "hcl" | "hlsl" | "idris" | "ignore" | "jq" | "json5" | "kusto" | "lilypond" | "linker-script" | "llvm" | "log" | "mermaid" | "mongodb" | "n1ql" | "odin" | "openqasm" | "plant-uml" | "powerquery" | "promql" | "purescript" | "qsharp" | "racket" | "regex" | "rego" | "rescript" | "robotframework" | "shell-session" | "smali" | "solidity" | "sparql" | "stata" | "toml" | "turtle" | "typoscript" | "unrealscript" | "uri" | "vala" | "wgsl" | "wolfram" | "zig", strings.MinRunes(1)])
220
221 #formatMapping: matchN(>=1, [{
222 [string]: matchN(1, [[...string], string])
223 }, [...string], string])
224
225 #reporter: matchN(>=1, ["ai" | "badge" | "console" | "console-full" | "consoleFull" | "csv" | "full" | "html" | "json" | "markdown" | "sarif" | "silent" | "threshold" | "xcode" | "xml", strings.MinRunes(1)])
226}