XYOracleNetwork/sdk-xyo-client-js

View on GitHub

Showing 114 of 365 total issues

Avoid too many return statements within this function.
Open

      return false
Severity: Major
Found in packages/modules/packages/module/packages/model/src/lib/serializable.ts - About 30 mins to fix

    Function resolve has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      async resolve<T extends ModuleInstance = ModuleInstance>(
        idOrFilter: ModuleIdentifier | ModuleFilter<T> = '*',
        options?: ModuleFilterOptions<T>,
      ): Promise<T | T[] | undefined> {
        const instance = asModuleInstance(this.mod)
    Severity: Minor
    Found in packages/modules/packages/module/packages/wrapper/src/ModuleWrapper.ts - About 25 mins to fix

    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 listenerCount has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      listenerCount(eventNames?: keyof TEventData | (keyof TEventData)[]) {
        const eventNamesArray = Array.isArray(eventNames) ? eventNames : [eventNames]
        let count = 0
    
        for (const eventName of eventNamesArray) {
    Severity: Minor
    Found in packages/modules/packages/module/packages/events/src/Events/Events.ts - About 25 mins to fix

    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 a Cognitive Complexity of 6 (exceeds 5 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
    Severity: Minor
    Found in packages/manifest/packages/wrapper/src/Wrapper.ts - About 25 mins to fix

    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 determineAccount has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    export async function determineAccount(params: DetermineAccountParams, allowRandomAccount = true): Promise<AccountInstance> {
      if (isDetermineAccountFromAccountParams(params)) {
        if (params.account === 'random') {
          assertEx(allowRandomAccount, () => 'Random address not allowed')
          return await Account.random()

    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 emitInternal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      private async emitInternal<TEventName extends keyof TEventData, TEventArgs extends TEventData[TEventName]>(
        eventName: TEventName,
        eventArgs: TEventArgs,
        filter?: TEventArgs,
      ) {
    Severity: Minor
    Found in packages/modules/packages/module/packages/events/src/Events/Events.ts - About 25 mins to fix

    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 getProvider has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      async getProvider(cache = false, error?: string | boolean): Promise<Provider | undefined> {
        const providers = await this.getProviders(cache)
        if (providers.length === 0) {
          if (error) {
            throw new Error(typeof error === 'string' ? error : 'No providers available')

    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 parseQuery has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      static async parseQuery<T extends Query = Query>(obj: unknown, payloads?: Payload[]): Promise<QueryBoundWitnessWrapper<T>> {
        assertEx(!Array.isArray(obj), () => 'Array can not be converted to QueryBoundWitnessWrapper')
        switch (typeof obj) {
          case 'object': {
            const castWrapper = obj as QueryBoundWitnessWrapper<T>

    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 hashableFields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      static async hashableFields<T extends Payload = Payload<AnyObject>>(
        schema: string,
        fields?: WithoutSchema<WithoutMeta<T>>,
        $meta?: JsonObject,
        $hash?: Hash,
    Severity: Minor
    Found in packages/protocol/packages/payload/packages/builder/src/Builder.ts - About 25 mins to fix

    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 handleMonitorResponseError has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      protected handleMonitorResponseError<T>(error: ApiError, trapAxiosException: boolean) {
        if (!error.isError) {
          throw error
        }
    
    
    Severity: Minor
    Found in packages/sdk-utils/packages/api/src/Base.ts - About 25 mins to fix

    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 relative has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      relative(direction: string) {
        const directionConstant = assertEx(RelativeDirectionConstantLookup[direction], () => 'Invalid direction')
        let quadkey = this.base4Hash
        if (quadkey.length === 0) {
          return this
    Severity: Minor
    Found in packages/sdk-utils/packages/quadkey/src/Quadkey.ts - About 25 mins to fix

    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 on has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      on<TEventName extends keyof TEventData = keyof TEventData>(
        eventNames: TEventName | TEventName[],
        listener: EventListener<TEventData[TEventName]>,
        filter?: TEventData[TEventName],
      ) {
    Severity: Minor
    Found in packages/modules/packages/module/packages/events/src/Events/Events.ts - About 25 mins to fix

    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 constructor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      constructor(huri: Hash | Huri | string, { archivistUri, token }: HuriOptions = {}) {
        const huriString
          = Huri.isHuri(huri)?.href
          ?? (typeof huri === 'string'
            ? (huri as string)
    Severity: Minor
    Found in packages/protocol/packages/payload/packages/huri/src/Huri.ts - About 25 mins to fix

    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 hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      static async hash<T extends EmptyObject>(obj: T): Promise<Hash> {
        const stringToHash = this.stringifyHashFields(obj)
    
        if (PayloadHasher.allowSubtle) {
          try {
    Severity: Minor
    Found in packages/protocol/packages/core/packages/hash/src/PayloadHasher.ts - About 25 mins to fix

    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

    Severity
    Category
    Status
    Source
    Language