Showing 114 of 365 total issues
Function combinationsBySchema
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
export const combinationsBySchema = async (payloads: Payload[], schemas: string[]): Promise<Payload[][]> => {
// Group payloads by schema
const groupedPayloads: Record<string, Payload[]> = Object.fromEntries(schemas.map(schema => [schema, []]))
for (const payload of payloads) {
if (schemas.includes(payload.schema)) {
- 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 intraBoundwitnessSchemaCombinations
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
export const intraBoundwitnessSchemaCombinations = (boundwitness: BoundWitness, schemas: Schema[]): Hash[][] => {
// Map to store the indices of each element in the source array
const indexMap: Record<string, number[]> = {}
// Populate the index map with positions of each element
- 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
File Quadkey.ts
has 266 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { assertEx } from '@xylabs/assert'
import { hexFromArrayBuffer, hexFromHexString } from '@xylabs/hex'
import type {
MercatorBoundingBox,
MercatorLngLat,
Function emitSerial
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
async emitSerial<TEventName extends keyof TEventData>(eventName: TEventName, eventArgs: TEventData[TEventName]) {
if (isMetaEvent(eventName) && !Events.canEmitMetaEvents) {
throw new TypeError(NO_META_EVENT_ERROR_MESSAGE)
}
- 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 registerCreatableModuleFactory
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
export const registerCreatableModuleFactory = <TModule extends AttachableModuleInstance>(
registry: CreatableModuleRegistry,
factory: CreatableModuleFactory<TModule> | LabeledCreatableModuleFactory<TModule>,
labels?: Labels,
/** register this as the primary factory for every schema it supports */
- 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 send
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
async send(address: Address, query: QueryBoundWitness, payloads?: Payload[] | undefined): Promise<ModuleQueryResult> {
this.logger?.debug(`Begin issuing query to: ${address}`)
const $meta = { ...query?.$meta, destination: [address] }
const routedQuery = await PayloadBuilder.build({ ...query, $meta })
// console.log('queryArchivist - calling')
Function isSerializable
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
export const isSerializable = (value: unknown, maxDepth = 10): boolean => {
if (maxDepth <= 0) {
return false
}
if (value === null || typeof value === 'boolean' || typeof value === 'number' || typeof value === 'string') {
- 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 resolveHandler
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
resolveHandler<T extends ModuleInstance = ModuleInstance>(
idOrFilter: ModuleFilter<T> | string = '*',
options?: ModuleFilterOptions<T>,
): Promisable<T[]> {
const unfiltered = (() => {
Function resolve
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
async resolve<T extends ModuleInstance = ModuleInstance>(
idOrFilter: ModuleFilter<T> | ModuleIdentifier = '*',
options?: ModuleFilterOptions<T>,
): Promise<T | T[] | undefined> {
// console.log(`childAddressMap: ${toJsonString(this.childAddressMap, 10)}`)
Function loadModule
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
async loadModule(wallet: WalletInstance, node: MemoryNode, manifest: ModuleManifest, external = true): Promise<void> {
console.log('loadModule', manifest.config.name)
const collision = async (node: NodeInstance, name: string, external: boolean) => {
const externalConflict = external ? (await node.resolve({ name: [name] }, { direction: external ? 'all' : 'down' })).length > 0 : false
return externalConflict || (await node.resolve({ name: [name] }, { direction: 'down' })).length > 0
- 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 checkIpfsUrl
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export const checkIpfsUrl = (urlToCheck: string, ipfsGateway?: string): string => {
try {
const url = new URL(urlToCheck)
let protocol = url.protocol
let host = url.host
- 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 checkIpfsUrl
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export const checkIpfsUrl = (urlToCheck: string, ipfsGateway?: string): string => {
try {
const url = new URL(urlToCheck)
let protocol = url.protocol
let host = url.host
- 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 build
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
static async build<T extends Payload = Payload<AnyObject>>(payload: T | T[], options: BuildOptions = {}) {
if (Array.isArray(payload)) {
return await Promise.all(payload.map(payload => this.build(payload, options)))
} else {
const { stamp = false, validate = true } = options
- 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 applyBoundWitnessDivinerQueryPayload
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export const applyBoundWitnessDivinerQueryPayload = (filter?: BoundWitnessDivinerQueryPayload, payloads: Payload[] = []) => {
if (!filter) return []
const {
addresses, payload_hashes, payload_schemas, limit, offset, order = 'desc', sourceQuery, destination, timestamp,
} = filter
- 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 hasEmptyFields
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export const hasEmptyFields = <T extends EmptyObject>(obj: T): boolean => {
if (obj === null || Array.isArray(obj)) return false
if (obj === undefined || Object.keys(obj).length === 0) 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 loadNodeFromManifest
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
async loadNodeFromManifest(wallet: WalletInstance, manifest: NodeManifest, path?: string, loadConfigChildren = false): Promise<MemoryNode> {
console.log('loadNodeFromManifest', manifest.config.name)
const derivedWallet = path ? await wallet.derivePath(path) : await HDWallet.random()
const node = await MemoryNode.create({ account: derivedWallet, config: manifest.config })
// Load Private Modules
Function getGridBoundingBox
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
getGridBoundingBox(size: number) {
const hash = this.base4Hash
let index = 0
let left = 0
let top = 0
Function registerCreatableModuleFactory
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const registerCreatableModuleFactory = <TModule extends AttachableModuleInstance>(
registry: CreatableModuleRegistry,
factory: CreatableModuleFactory<TModule> | LabeledCreatableModuleFactory<TModule>,
labels?: Labels,
/** register this as the primary factory for every schema it supports */
Function clearListeners
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
clearListeners(eventNames: keyof TEventData | (keyof TEventData)[]) {
const eventNamesArray = Array.isArray(eventNames) ? eventNames : [eventNames]
for (const eventName of eventNamesArray) {
this.logIfDebugEnabled('clear', eventName)
- 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 transform
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async transform(identifier: ModuleIdentifier): Promise<ModuleIdentifier> {
const parts = identifier.split(':')
const first = parts.shift()
const nameParts = first?.split('.')
if (nameParts?.length === 2 && nameParts[1] === this.root) {
- 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"