XYOracleNetwork/sdk-xyo-client-js

View on GitHub

Showing 342 of 346 total issues

Avoid too many return statements within this function.
Open

            return this.resolveByQuery<T>(Object.values(this.modules), filter.query)

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

      info(message?: unknown): void {
        this._logger?.info(this.generate(message, getFunctionName(3)))
      }
    Severity: Major
    Found in packages/shared/src/IdLogger.ts and 4 other locations - About 30 mins to fix
    packages/shared/src/IdLogger.ts on lines 18..20
    packages/shared/src/IdLogger.ts on lines 22..24
    packages/shared/src/IdLogger.ts on lines 30..32
    packages/shared/src/IdLogger.ts on lines 34..36

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 45.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

      log(message?: unknown): void {
        this._logger?.log(this.generate(message, getFunctionName(3)))
      }
    Severity: Major
    Found in packages/shared/src/IdLogger.ts and 4 other locations - About 30 mins to fix
    packages/shared/src/IdLogger.ts on lines 18..20
    packages/shared/src/IdLogger.ts on lines 22..24
    packages/shared/src/IdLogger.ts on lines 26..28
    packages/shared/src/IdLogger.ts on lines 34..36

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 45.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    export type Value<T extends JsonValue = JsonValue> = Payload<{
      schema: ValueSchema
      value: T
    }>
    Severity: Minor
    Found in packages/core-payload-plugins/packages/value/src/Payload.ts and 1 other location - About 30 mins to fix
    packages/modules/packages/bridge/packages/pub-sub/src/AsyncQueryBus/model/Params.ts on lines 9..12

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 45.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    export type AsyncQueryBusParams<TConfig extends AsyncQueryBusBaseConfig = AsyncQueryBusBaseConfig> = BaseParams<{
      config?: TConfig
      rootModule: ModuleInstance
    }>
    packages/core-payload-plugins/packages/value/src/Payload.ts on lines 7..10

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 45.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 5 locations. Consider refactoring.
    Open

      debug(message?: unknown): void {
        this._logger?.debug(this.generate(message, getFunctionName(3)))
      }
    Severity: Major
    Found in packages/shared/src/IdLogger.ts and 4 other locations - About 30 mins to fix
    packages/shared/src/IdLogger.ts on lines 22..24
    packages/shared/src/IdLogger.ts on lines 26..28
    packages/shared/src/IdLogger.ts on lines 30..32
    packages/shared/src/IdLogger.ts on lines 34..36

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 45.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Avoid too many return statements within this function.
    Open

              return (
                mod
                  ? Array.isArray(mod)
                    ? mod
                    : [mod]

      Avoid too many return statements within this function.
      Open

              return (
                mod
                  ? Array.isArray(mod)
                    ? mod
                    : [mod]

        Avoid too many return statements within this function.
        Open

                  return []

          Avoid too many return statements within this function.
          Open

                return flatResult.filter(duplicateModules)

            Avoid too many return statements within this function.
            Open

              return false
            Severity: Major
            Found in packages/protocol/packages/core/packages/hash/src/hasEmptyFields.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 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 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 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 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 (ObjectHasher.allowSubtle) {
                    try {
              Severity: Minor
              Found in packages/protocol/packages/core/packages/hash/src/ObjectHasher.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 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 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 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 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

              Severity
              Category
              Status
              Source
              Language