Total Complexity | 2 |
Complexity/F | 2 |
Lines of Code | 41 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /* |
||
10 | import { terser } from "rollup-plugin-terser"; |
||
11 | import fs from 'fs'; |
||
12 | |||
13 | // Load polyfill only in UMD dist |
||
14 | const codePointAtPolyfill = fs.readFileSync( |
||
15 | './node_modules/string.prototype.codepointat/codepointat.js', 'utf8'); |
||
16 | |||
17 | // Legal |
||
18 | const license = '/*!\n'+ |
||
19 | ' * Copyright (c) 2018 Rafael da Silva Rocha.\n'+ |
||
20 | ' */\n'; |
||
21 | |||
22 | export default [ |
||
23 | // umd bundle includes polyfill for String.codePointAt by @mathiasbynens |
||
24 | // @see https://www.npmjs.com/package/string.prototype.codepointat |
||
25 | { |
||
26 | input: 'main.js', |
||
27 | output: [ |
||
28 | { |
||
29 | file: 'dist/utf8-buffer-size.umd.js', |
||
30 | name: 'utf8BufferSize', |
||
31 | format: 'umd', |
||
32 | banner: license + codePointAtPolyfill |
||
33 | } |
||
34 | ], |
||
35 | plugins: [ |
||
36 | terser({ |
||
37 | output: { |
||
38 | comments: function(node, comment) { |
||
39 | var text = comment.value; |
||
40 | var type = comment.type; |
||
41 | if (type == "comment2") { |
||
|
|||
42 | // multiline comment |
||
43 | return /@preserve|!|@license|@cc_on/i.test(text); |
||
44 | } |
||
45 | } |
||
46 | } |
||
47 | }) |
||
48 | ] |
||
49 | } |
||
50 | ]; |
||
51 |
This check looks for functions where a
return
statement is found in some execution paths, but not in all.Consider this little piece of code
The function
isBig
will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly returnundefined
.This behaviour may not be what you had intended. In any case, you can add a
return undefined
to the other execution path to make the return value explicit.