oceanprotocol/ocean.js

View on GitHub

Showing 169 of 177 total issues

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

      const response = await fetch(path, {
        method: 'POST',
        body: JSON.stringify(query),
        headers: {
          'Content-Type': 'application/json'
Severity: Major
Found in src/services/Aquarius.ts and 2 other locations - About 40 mins to fix
src/services/Aquarius.ts on lines 102..107
src/services/Provider.ts on lines 169..174

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 49.

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 3 locations. Consider refactoring.
Open

      const response = await fetch(path, {
        method: 'POST',
        body: JSON.stringify(data),
        headers: { 'Content-Type': 'application/octet-stream' },
        signal
Severity: Major
Found in src/services/Provider.ts and 2 other locations - About 40 mins to fix
src/services/Aquarius.ts on lines 102..107
src/services/Aquarius.ts on lines 170..177

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 49.

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

      if (response.ok) {
        return response.json()
      } else {
        throw new Error('querySearch failed: ' + response.status + response.statusText)
      }
Severity: Minor
Found in src/services/Aquarius.ts and 1 other location - About 40 mins to fix
src/services/Aquarius.ts on lines 147..153

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 48.

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

      if (response.ok) {
        return response.json()
      } else {
        throw new Error(
          'getAssetMetadata failed: ' + response.status + response.statusText
Severity: Minor
Found in src/services/Aquarius.ts and 1 other location - About 40 mins to fix
src/services/Aquarius.ts on lines 179..183

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 48.

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

Function sendTx has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  estGas: BigNumber,
  signer: Signer,
  gasFeeMultiplier: number,
  functionToSend: ContractFunction,
  ...args: any[]
Severity: Minor
Found in src/utils/ContractUtils.ts - About 35 mins to fix

    Function initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      public async initialize(
        did: string,
        serviceId: string,
        fileIndex: number,
        consumerAddress: string,
    Severity: Minor
    Found in src/services/Provider.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 createNFT has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      public async createNFT<G extends boolean = false>(
        nftData: NftCreateData,
        estimateGas?: G
      ): Promise<G extends false ? string : BigNumber> {
        if (!nftData.templateIndex) nftData.templateIndex = 1
    Severity: Minor
    Found in src/contracts/NFTFactory.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 getNonce has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      public async getNonce(
        providerUri: string,
        consumerAddress: string,
        signal?: AbortSignal,
        providerEndpoints?: any,
    Severity: Minor
    Found in src/services/Provider.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 computeDelete has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      public async computeDelete(
        did: string,
        consumer: Signer,
        jobId: string,
        providerUri: string,
    Severity: Minor
    Found in src/services/Provider.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

    Avoid too many return statements within this function.
    Open

          return true
    Severity: Major
    Found in src/contracts/Dispenser.ts - About 30 mins to fix

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

              return await datatoken.startOrder(
                asset.datatokens[datatokenIndex].address,
                orderParams.consumer,
                orderParams.serviceIndex,
                orderParams._providerFee,
      Severity: Minor
      Found in src/utils/OrderUtils.ts and 1 other location - About 30 mins to fix
      src/utils/OrderUtils.ts on lines 205..211

      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 txBuy
      Severity: Major
      Found in src/utils/OrderUtils.ts - About 30 mins to fix

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

          public async getCurrentTokenTemplateCount(): Promise<number> {
            const count = await this.contract.getCurrentTemplateCount()
            return count
          }
        Severity: Major
        Found in src/contracts/NFTFactory.ts and 4 other locations - About 30 mins to fix
        src/contracts/FixedRateExchange.ts on lines 140..143
        src/contracts/NFTFactory.ts on lines 93..96
        src/contracts/NFTFactory.ts on lines 102..105
        src/contracts/NFTFactory.ts on lines 120..123

        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

          public async getCurrentNFTCount(): Promise<number> {
            const nftCount = await this.contract.getCurrentNFTCount()
            return nftCount
          }
        Severity: Major
        Found in src/contracts/NFTFactory.ts and 4 other locations - About 30 mins to fix
        src/contracts/FixedRateExchange.ts on lines 140..143
        src/contracts/NFTFactory.ts on lines 102..105
        src/contracts/NFTFactory.ts on lines 120..123
        src/contracts/NFTFactory.ts on lines 129..132

        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 false
        Severity: Major
        Found in src/contracts/Dispenser.ts - About 30 mins to fix

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

                  return await datatoken.startOrder(
                    asset.datatokens[datatokenIndex].address,
                    orderParams.consumer,
                    orderParams.serviceIndex,
                    orderParams._providerFee,
          Severity: Minor
          Found in src/utils/OrderUtils.ts and 1 other location - About 30 mins to fix
          src/utils/OrderUtils.ts on lines 132..138

          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

            public async getCurrentTokenCount(): Promise<number> {
              const tokenCount = await this.contract.getCurrentTokenCount()
              return tokenCount
            }
          Severity: Major
          Found in src/contracts/NFTFactory.ts and 4 other locations - About 30 mins to fix
          src/contracts/FixedRateExchange.ts on lines 140..143
          src/contracts/NFTFactory.ts on lines 93..96
          src/contracts/NFTFactory.ts on lines 120..123
          src/contracts/NFTFactory.ts on lines 129..132

          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

            public async getNumberOfExchanges(): Promise<number> {
              const numExchanges = await this.contract.getNumberOfExchanges()
              return numExchanges
            }
          Severity: Major
          Found in src/contracts/FixedRateExchange.ts and 4 other locations - About 30 mins to fix
          src/contracts/NFTFactory.ts on lines 93..96
          src/contracts/NFTFactory.ts on lines 102..105
          src/contracts/NFTFactory.ts on lines 120..123
          src/contracts/NFTFactory.ts on lines 129..132

          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

            public async getCurrentNFTTemplateCount(): Promise<number> {
              const count = await this.contract.getCurrentNFTTemplateCount()
              return count
            }
          Severity: Major
          Found in src/contracts/NFTFactory.ts and 4 other locations - About 30 mins to fix
          src/contracts/FixedRateExchange.ts on lines 140..143
          src/contracts/NFTFactory.ts on lines 93..96
          src/contracts/NFTFactory.ts on lines 102..105
          src/contracts/NFTFactory.ts on lines 129..132

          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 3 locations. Consider refactoring.
          Open

            async getOPCCollector(): Promise<string> {
              const address = await this.contract.opcCollector()
              return address
            }
          Severity: Minor
          Found in src/contracts/FixedRateExchange.ts and 2 other locations - About 30 mins to fix
          src/contracts/FixedRateExchange.ts on lines 651..654
          src/contracts/NFTFactory.ts on lines 111..114

          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

          Severity
          Category
          Status
          Source
          Language