oceanprotocol/ocean.js

View on GitHub

Showing 169 of 177 total issues

Function getExchange has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public async getExchange(exchangeId: string): Promise<FixedPriceExchange> {
    const result: FixedPriceExchange = await this.contract.getExchange(exchangeId)
    const exchange: FixedPriceExchange = {
      active: result.active,
      datatoken: result.datatoken,
Severity: Minor
Found in src/contracts/FixedRateExchange.ts - About 1 hr to fix

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

        if (response?.ok) {
          const results: FileInfo[] = await response.json()
          for (const result of results) {
            files.push(result)
          }
    Severity: Major
    Found in src/services/Provider.ts and 1 other location - About 1 hr to fix
    src/services/Provider.ts on lines 222..228

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

    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

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

        if (response?.ok) {
          const results: FileInfo[] = await response.json()
          for (const result of results) {
            files.push(result)
          }
    Severity: Major
    Found in src/services/Provider.ts and 1 other location - About 1 hr to fix
    src/services/Provider.ts on lines 277..283

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

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

      public async calcBaseInGivenDatatokensOut(
        exchangeId: string,
        datatokenAmount: string,
        consumeMarketFee: string = '0'
      ): Promise<PriceAndFees> {
    Severity: Minor
    Found in src/contracts/FixedRateExchange.ts - About 1 hr to fix

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

        public async getNFTAddress(dtAddress: string): Promise<string> {
          const dtContract = this.getContract(dtAddress)
          const nftAddress = await dtContract.getERC721Address()
          return nftAddress
        }
      Severity: Major
      Found in src/contracts/Datatoken.ts and 3 other locations - About 1 hr to fix
      src/contracts/Datatoken.ts on lines 429..433
      src/contracts/Datatoken.ts on lines 756..760
      src/contracts/Datatoken.ts on lines 767..771

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

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

        public async getName(dtAddress: string): Promise<string> {
          const dtContract = this.getContract(dtAddress)
          const name = await dtContract.name()
          return name
        }
      Severity: Major
      Found in src/contracts/Datatoken.ts and 3 other locations - About 1 hr to fix
      src/contracts/Datatoken.ts on lines 429..433
      src/contracts/Datatoken.ts on lines 756..760
      src/contracts/Datatoken.ts on lines 778..782

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

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

        public async getSymbol(dtAddress: string): Promise<string> {
          const dtContract = this.getContract(dtAddress)
          const symbol = await dtContract.symbol()
          return symbol
        }
      Severity: Major
      Found in src/contracts/Datatoken.ts and 3 other locations - About 1 hr to fix
      src/contracts/Datatoken.ts on lines 429..433
      src/contracts/Datatoken.ts on lines 767..771
      src/contracts/Datatoken.ts on lines 778..782

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

      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

            maxPriorityFeePerGas:
              (chainId === MUMBAI_NETWORK_ID || chainId === POLYGON_NETWORK_ID) &&
              Number(aggressiveFeePriorityFeePerGas) < MIN_GAS_FEE_POLYGON
                ? MIN_GAS_FEE_POLYGON
                : chainId === SEPOLIA_NETWORK_ID &&
      Severity: Major
      Found in src/utils/ContractUtils.ts and 1 other location - About 1 hr to fix
      src/utils/ContractUtils.ts on lines 144..151

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

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

        public async getPaymentCollector(dtAddress: string): Promise<string> {
          const dtContract = this.getContract(dtAddress)
          const paymentCollector = await dtContract.getPaymentCollector()
          return paymentCollector
        }
      Severity: Major
      Found in src/contracts/Datatoken.ts and 3 other locations - About 1 hr to fix
      src/contracts/Datatoken.ts on lines 756..760
      src/contracts/Datatoken.ts on lines 767..771
      src/contracts/Datatoken.ts on lines 778..782

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

      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

        public async getId(dtAddress: string): Promise<number> {
          const dtContract = this.getContract(dtAddress)
          const id = await dtContract.getId()
          return id
        }
      Severity: Major
      Found in src/contracts/Datatoken.ts and 1 other location - About 1 hr to fix
      src/contracts/Datatoken.ts on lines 734..738

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

      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

        public async getDecimals(dtAddress: string): Promise<number> {
          const dtContract = this.getContract(dtAddress)
          const decimals = await dtContract.decimals()
          return decimals
        }
      Severity: Major
      Found in src/contracts/Datatoken.ts and 1 other location - About 1 hr to fix
      src/contracts/Datatoken.ts on lines 745..749

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

      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

            maxFeePerGas:
              (chainId === MUMBAI_NETWORK_ID || chainId === POLYGON_NETWORK_ID) &&
              Number(aggressiveFeePerGas) < MIN_GAS_FEE_POLYGON
                ? MIN_GAS_FEE_POLYGON
                : chainId === SEPOLIA_NETWORK_ID &&
      Severity: Major
      Found in src/utils/ContractUtils.ts and 1 other location - About 1 hr to fix
      src/utils/ContractUtils.ts on lines 135..142

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

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

        public async buyDatatokens<G extends boolean = false>(
          exchangeId: string,
          datatokenAmount: string,
          maxBaseTokenAmount: string,
          consumeMarketAddress: string = ZERO_ADDRESS,
      Severity: Minor
      Found in src/contracts/FixedRateExchange.ts - About 1 hr to fix

        Function sellDatatokens has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public async sellDatatokens<G extends boolean = false>(
            exchangeId: string,
            datatokenAmount: string,
            minBaseTokenAmount: string,
            consumeMarketAddress: string = ZERO_ADDRESS,
        Severity: Minor
        Found in src/contracts/FixedRateExchange.ts - About 1 hr to fix

          Function getDownloadUrl has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public async getDownloadUrl(
              did: string,
              serviceId: string,
              fileIndex: number,
              transferTxId: string,
          Severity: Minor
          Found in src/services/Provider.ts - About 1 hr to fix

            Function getComputeResultUrl has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              public async getComputeResultUrl(
                providerUri: string,
                consumer: Signer,
                jobId: string,
                index: number
            Severity: Minor
            Found in src/services/Provider.ts - About 1 hr to fix

              Function validate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                public async validate(ddo: DDO, signal?: AbortSignal): Promise<ValidateMetadata> {
                  const status: ValidateMetadata = {
                    valid: false
                  }
                  let jsonResponse
              Severity: Minor
              Found in src/services/Aquarius.ts - About 1 hr to fix

                Function setMetadata has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  public async setMetadata<G extends boolean = false>(
                    nftAddress: string,
                    address: string,
                    metadataState: number,
                    metadataDecryptorUrl: string,
                Severity: Minor
                Found in src/contracts/NFT.ts - About 1 hr to fix

                  Function approve has 9 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    signer: Signer,
                    config: Config,
                    account: string,
                    tokenAddress: string,
                    spender: string,
                  Severity: Major
                  Found in src/utils/TokenUtils.ts - About 1 hr to fix

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

                        const amount = await this.contract.calcBaseOutGivenInDT(
                          exchangeId,
                          await this.amountToUnits(exchange.datatoken, datatokenAmount, +exchange.dtDecimals),
                          await this.amountToUnits(null, consumeMarketFee, 18)
                        )
                    Severity: Major
                    Found in src/contracts/FixedRateExchange.ts and 1 other location - About 1 hr to fix
                    src/contracts/FixedRateExchange.ts on lines 311..319

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

                    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