XYOracleNetwork/clients

View on GitHub

Showing 24 of 134 total issues

Function findPayload has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

export const findPayload = async (
  archivist: ArchivistInstance,
  boundWitnessDiviner: BoundWitnessDiviner,
  payloadDiviner: PayloadDiviner,
  pointer: PointerPayload,

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 witnessNftCollections has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const witnessNftCollections = async (node: NodeInstance) => {
  const archivistMod = assertEx(await node.resolve(TYPES.Archivist), () => `Resolving: ${TYPES.Archivist}`)
  const archivist = assertEx(asArchivistInstance(archivistMod), () => `Creating: ${TYPES.Archivist}`)

  const nftCollectionScoreDivinerMod = assertEx(

    Function getCommand has 69 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const getCommand = async (node: NodeInstance): Promise<boolean> => {
      return await new Promise((resolve) => {
        terminal.once('key', (name: string) => {
          if (name === 'ESCAPE') resolve(true)
          if (name === 'CTRL_C') resolve(false)
    Severity: Major
    Found in packages/cli/src/terminal/getCommand.ts - About 2 hrs to fix

      Function readFileDeep has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

      export const readFileDeep = (names: string[]) => {
        let depth = 0
        let result: string | undefined
        let filename
        let resolvedPath
      Severity: Minor
      Found in packages/cli/src/lib/file/readFileDeep.ts - About 2 hrs 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 handler has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      const handler: RequestHandler<AddressPathParams, ModuleQueryResult, PostAddressRequestBody> = async (req, res, next) => {
        const { address } = req.params
        const { node } = req.app
        // console.log(`address post[${node.address}]: ${address}`)
        // console.log('\nManifest')

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

      const handler: RequestHandler<AddressPathParams, Payload[]> = async (req, res, next) => {
        const { address } = req.params
        const { node } = req.app
        if (address) {
          let modules: ModuleInstance[] = []

      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 addWitnessModuleFactories has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const addWitnessModuleFactories = (container: Container) => {
        const locator = container.get<ModuleFactoryLocator>(TYPES.ModuleFactoryLocator)
        locator.register(
          CryptoNftCollectionWitness.factory({ providers: () => getProvidersFromEnv(8) }),
        )

        Function getCommand has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        export const getCommand = async (node: NodeInstance): Promise<boolean> => {
          return await new Promise((resolve) => {
            terminal.once('key', (name: string) => {
              if (name === 'ESCAPE') resolve(true)
              if (name === 'CTRL_C') resolve(false)
        Severity: Minor
        Found in packages/cli/src/terminal/getCommand.ts - About 1 hr 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 generateThumbnail has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const generateThumbnail = async (
          address: string,
          name: string,
          score: Hash,
          archivist: ArchivistInstance,

          Function getEthereumGasWitness has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const getEthereumGasWitness: WitnessProvider<Provider> = async (provider = getProvider()): Promise<AttachableWitnessInstance[]> => {
            const witnesses: AttachableWitnessInstance[] = [
              await EthereumGasBlocknativeWitness.create({
                account: await getAccount(WalletPaths.EthereumGas.Witness.Blocknative),
                config: { schema: EthereumGasBlocknativeWitnessConfigSchema },

            Function handler has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const handler: RequestHandler<AddressPathParams, ModuleQueryResult, PostAddressRequestBody> = async (req, res, next) => {
              const { address } = req.params
              const { node } = req.app
              // console.log(`address post[${node.address}]: ${address}`)
              // console.log('\nManifest')

              Function getLoggingErrorHandler has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              export const getLoggingErrorHandler = (logger: Logger): ErrorRequestHandler => {
                return (err: PossibleError, _req: Request, res: Response, next: NextFunction) => {
                  if (res.headersSent) {
                    return next()
                  }

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

              export const witnessNftCollections = async (node: NodeInstance) => {
                const archivistMod = assertEx(await node.resolve(TYPES.Archivist), () => `Resolving: ${TYPES.Archivist}`)
                const archivist = assertEx(asArchivistInstance(archivistMod), () => `Creating: ${TYPES.Archivist}`)
              
                const nftCollectionScoreDivinerMod = assertEx(

              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 configureMemoryNode has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const configureMemoryNode = async (container: Container, _memoryNode?: NodeInstance, _account?: AccountInstance) => {
                const node = await loadNodeFromConfig(container)
                // const node: NodeInstance = memoryNode ?? (await MemoryNode.create({ account, config }))
                container.bind<NodeInstance>(TYPES.Node).toConstantValue(node)
                const configHashes = process.env.CONFIG_HASHES

                Function connect has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const connect = async (attempts = 60, interval = 500): Promise<NodeInstance> => {
                  // TODO: Configurable via config or dynamically determined
                  const apiDomain = process.env.API_DOMAIN || 'http://localhost:8080'
                  const apiConfig = { apiDomain }
                  printLine(`Connecting to Node at: ${apiDomain}`)
                Severity: Minor
                Found in packages/cli/src/lib/connect/connect.ts - About 1 hr to fix

                  Function connect has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const connect = async (attempts = 60, interval = 500): Promise<NodeInstance> => {
                    // TODO: Configurable via config or dynamically determined
                    const apiDomain = process.env.API_DOMAIN || 'http://localhost:8080'
                    const apiConfig = { apiDomain }
                    printLine(`Connecting to Node at: ${apiDomain}`)
                  Severity: Minor
                  Found in packages/cli/src/lib/connect/connect.ts - About 55 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 defineJobs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const defineJobs = (jobQueue: JobQueue, jobs: Job[]) => {
                    jobs.map((job) => {
                      const { name, task } = job
                      jobQueue.define(name, options, task)
                      if (job.onComplete) jobQueue.on(`complete:${name}`, job.onComplete)
                  Severity: Minor
                  Found in packages/modules-mongo/packages/diviner/src/JobQueue/defineJobs.ts - About 45 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 configureMemoryNode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const configureMemoryNode = async (container: Container, _memoryNode?: NodeInstance, _account?: AccountInstance) => {
                    const node = await loadNodeFromConfig(container)
                    // const node: NodeInstance = memoryNode ?? (await MemoryNode.create({ account, config }))
                    container.bind<NodeInstance>(TYPES.Node).toConstantValue(node)
                    const configHashes = process.env.CONFIG_HASHES

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

                  export const getBridgeConfig = async (args: BaseArguments): Promise<HttpBridgeConfig> => {
                    const { network, verbose } = args
                    try {
                      let nodeUrl = process.env.API_DOMAIN || 'http://localhost:8080'
                      if (network) {
                  Severity: Minor
                  Found in packages/cli/src/command/util/getBridgeConfig.ts - About 35 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 getConfig has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const getConfig = async (): Promise<ModuleConfig> => {
                    const [config, path] = readFileDeep(['xyo-config.json', 'xyo-config.js'])
                    let configObj: ModuleConfig | undefined
                    if (config) {
                      if (path?.endsWith('.json')) {
                  Severity: Minor
                  Found in packages/cli/src/command/commands/config/show.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