Showing 114 of 365 total issues
Function removeEmptyFields
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export const removeEmptyFields = <T extends EmptyObject>(obj: T): T => {
if (obj === null) return obj
if (Array.isArray(obj)) {
return obj.map(value => (typeof value === 'object' ? removeEmptyFields(value) : value)) as T
- 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 emitSerial
has 31 lines of code (exceeds 25 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)
}
Function loadNodeFromManifest
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
async loadNodeFromManifest(wallet: WalletInstance, manifest: NodeManifest, path?: string): Promise<MemoryNode> {
const derivedWallet = path ? await wallet.derivePath(path) : await HDWallet.random()
const node = await MemoryNode.create({ account: derivedWallet, config: manifest.config })
// Load Private Modules
const privateModules
Function applyBoundWitnessDivinerQueryPayload
has 29 lines of code (exceeds 25 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
Function intraBoundwitnessSchemaCombinations
has 28 lines of code (exceeds 25 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
Function checkIpfsUrl
has 28 lines of code (exceeds 25 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
Function getTestNode
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const getTestNode = async (): Promise<NodeInstance> => {
const node = await MemoryNode.create()
const archivist = await MemoryArchivist.create({ account: 'random', config: { schema: MemoryArchivistConfigSchema, name: ArchivistName } })
const payloadDiviner = await MemoryPayloadDiviner.create({
account: 'random',
Function checkIpfsUrl
has 28 lines of code (exceeds 25 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
Function loadModule
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
async loadModule(wallet: WalletInstance, node: MemoryNode, manifest: ModuleManifest, external = true): Promise<void> {
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 assignCreatableModuleRegistry
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export const assignCreatableModuleRegistry = (
target: CreatableModuleRegistry = {},
...sources: CreatableModuleRegistry[]
): CreatableModuleRegistry => {
for (const source of sources)
- 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 verify
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
static async verify(msg: ArrayBuffer, signature: ArrayBuffer, address: ArrayBuffer) {
const verifier = await this.secp256k1()
if (verifier && this.wasmSupport.canUseWasm) {
for (const recoveryId of recoveryIds) {
try {
- 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 combinationsBySchema
has 27 lines of code (exceeds 25 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)) {
Function attachNode
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private attachNode(node: NodeInstance) {
const listener = async (event: MessageEvent) => {
const message = event.data as Message
switch (message.type) {
case 'xyoQuery': {
Function resolve
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
async resolve<T extends ModuleInstance = ModuleInstance>(
idOrFilter: ModuleFilter<T> | string = '*',
options?: ModuleFilterOptions<T>,
): Promise<T[] | T | undefined> {
if (idOrFilter === '*') {
Function unfiltered
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const unfiltered = (() => {
if (idOrFilter) {
if (typeof idOrFilter === 'string') {
if (idOrFilter === '*') {
return Object.values(this.modules) as T[]
Function pollForResponse
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
const pollForResponse = async () => {
try {
this.start()
let response = this.queryCache.get(routedQueryHash)
// Poll for response until cache key expires (response timed out)
Function build
has 26 lines of code (exceeds 25 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
Function constructor
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
constructor(params: EventsParams = {}) {
const mutatedParams = { ...params }
if (mutatedParams.debug) {
mutatedParams.debug.logger
= mutatedParams.debug.logger
- 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 off
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
off<TEventName extends keyof TEventData, TEventListener = EventListener<TEventData[TEventName]>>(
eventNames: TEventName | TEventName[],
listener: TEventListener,
) {
const eventNamesArray = Array.isArray(eventNames) ? eventNames : [eventNames]
- 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 resolveModuleIdentifier
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
static async resolveModuleIdentifier<T extends ModuleInstance = ModuleInstance>(
resolver: ModuleResolver,
path: ModuleIdentifier,
required?: boolean,
): Promise<T | undefined> {
- 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"