Showing 14 of 14 total issues
Function serialize
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
function serialize(key, val, options) {
const opt = options ?? {};
if(!fieldContentRegExp.test(key))
throw new TypeError('argument name is invalid');
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function serialize
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
function serialize(key, val, options) {
const opt = options ?? {};
if(!fieldContentRegExp.test(key))
throw new TypeError('argument name is invalid');
Function parse
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function parse(header) {
if(typeof header !== 'string')
throw new TypeError('argument str must be a string');
const obj = {}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function trigger
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
async trigger(method, path, input){
method = method.toUpperCase();
const params = {};
const app = this.context;
Function parse
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parse(header) {
if(typeof header !== 'string')
throw new TypeError('argument str must be a string');
const obj = {}
Function trigger
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
async trigger(method, path, input = {}){
if(!(input.body instanceof Readable)){
const ob = input.body ?? '';
const oh = input.headers ?? {};
Function initCors
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function initCors(opts, origin, res){
const options = { ...DEFAULT_OPTIONS, ...opts };
/* Configure Origin */
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function trigger
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
async trigger(method, path, input = {}){
if(!(input.body instanceof Readable)){
const ob = input.body ?? '';
const oh = input.headers ?? {};
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function matchRoute
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function matchRoute(method, path, params){
// this => API
const route = method + ' ' + path;
if(route in this.static)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function validateOpts
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function validateOpts(opts){
if(typeof opts != 'object')
throw new TypeError('Options argument must be an object');
this._websocket = opts.websocket;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function run
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function run(opts = {}){
const app = require(opts.path)();
if(! (app instanceof Nodecaf))
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function format
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function format(str, ...args){
let lastPos = 0;
while(args.length > 0){
const pos = str.indexOf('%s', lastPos);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function handleOptions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function handleOptions(opts, neededHeaders, res){
const options = { ...DEFAULT_OPTIONS, ...opts };
/* Configure Methods */
const methods = options.methods;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this function. Open
return new HTTPError(500, String(thing), 'text');