File transactionAggregator.ts
has 336 lines of code (exceeds 250 allowed). Consider refactoring. Open
'use strict'
import * as Debug from 'debug'
import { EventEmitter2 } from 'eventemitter2'
import EWMA from './EWMA'
Function matchPath
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
matchPath (path, routes) {
// empty route is / without the fist slash
if (!path || !routes) return false
if (path === '/') return routes[path] ? path : null
- 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 prepareAggregationforShipping
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
prepareAggregationforShipping () {
let routes = this.cache.routes
const normalized: Trace = {
routes: [],
Function aggregate
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
aggregate (packet) {
if (this.validateData(packet) === false) return false
// Get http path of current span
let path = packet.spans[0].labels['http/path']
Function compareList
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
compareList (one: any[], two: any[]) {
if (one.length !== two.length) return false
for (let i = 0; i < one.length; i++) {
if (one[i].name !== two[i].name) 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 mergeTrace
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
mergeTrace (aggregated, trace) {
if (!aggregated || !trace) return
// if the trace doesn't any spans stop aggregation here
if (trace.spans.length === 0) return
Function mergeTrace
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
mergeTrace (aggregated, trace) {
if (!aggregated || !trace) return
// if the trace doesn't any spans stop aggregation here
if (trace.spans.length === 0) return
- 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 matchPath
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
matchPath (path, routes) {
// empty route is / without the fist slash
if (!path || !routes) return false
if (path === '/') return routes[path] ? path : null
Avoid too many return
statements within this function. Open
if (one[i].labels.length !== two[i].labels.length) return false
Avoid too many return
statements within this function. Open
return false
Avoid too many return
statements within this function. Open
return segments.join('/')
Avoid too many return
statements within this function. Open
return true
Avoid too many return
statements within this function. Open
if (one[i].labels && !two[i].labels) return false
Avoid too many return
statements within this function. Open
if (j === 0) return segments.join('/')
Function aggregate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
aggregate (packet) {
if (this.validateData(packet) === false) return false
// Get http path of current span
let path = packet.spans[0].labels['http/path']
- 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"