Showing 8 of 8 total issues
Function createRouter
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
export const createRouter = (routes, base = '/') => async (req, res, next = () => {}) => {
if (base === '*') {
const i = req.url.indexOf('/', 1)
req.base = req.url.slice(0, i)
req.url = req.url.slice(i)
- 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 getMetricsDigest
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const getMetricsDigest = () => {
const formatUptime = (uptime) => {
const pad = s => (s < 10 ? '0' : '') + s
const hours = Math.floor(uptime / (60 * 60))
const minutes = Math.floor(uptime % (60 * 60) / 60)
Function matchByName
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export const matchByName = (opts, name, version) =>
opts.name?.some(n => {
if (n === name) {
return true
}
- 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 matchByOrg
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export const matchByOrg = (opts, org) =>
opts.org?.some(n => {
if (!org) {
return false
}
- 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 trace
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export const trace = async (req, res, next) => {
req.id = res.id = genId()
const ctx = getCtx()
ctx.logExtra = Object.assign(ctx.logExtra || {}, {
- 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 res
.writeHead(FOUND, {Location: tarball})
.end()
Function createServer
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export const createServer = ({host, port, secure, router, keepAliveTimeout, headersTimeout, requestTimeout }) => {
const entrypoint = `${secure ? 'https' : 'http'}://${host}:${port}`
const lib = secure ? https : http
const options = {...secure}
const sockets = createSocketPool()
- 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 logDenied
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const logDenied = (name, directives) => {
const denied = Object.entries(directives).reduce((m, [v, {policy, pluginName, options}]) => {
if (policy === 'deny') {
const snap = JSON.stringify({pluginName, policy, options})
if (!m[snap]) {
- 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"