oceanprotocol/ocean.js

View on GitHub

Showing 169 of 177 total issues

File ConfigHelper.ts has 258 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// eslint-disable-next-line import/no-named-default
import { default as DefaultContractsAddresses } from '@oceanprotocol/contracts/addresses/address.json'
import fs from 'fs'
import { Config } from '.'
import { LoggerInstance } from '../utils'
Severity: Minor
Found in src/config/ConfigHelper.ts - About 2 hrs to fix

    Function sendTx has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export async function sendTx(
      estGas: BigNumber,
      signer: Signer,
      gasFeeMultiplier: number,
      functionToSend: ContractFunction,
    Severity: Minor
    Found in src/utils/ContractUtils.ts - About 1 hr to fix

      Function computeStatus has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public async computeStatus(
          providerUri: string,
          consumerAddress: string,
          jobId?: string,
          did?: string,
      Severity: Minor
      Found in src/services/Provider.ts - About 1 hr to fix

        Function createFixedRate has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public async createFixedRate<G extends boolean = false>(
            dtAddress: string,
            address: string,
            fixedRateParams: FreCreationParams,
            estimateGas?: G
        Severity: Minor
        Found in src/contracts/Datatoken.ts - About 1 hr to fix

          Function createNFT has 43 lines of code (exceeds 25 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 1 hr to fix

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

              public async getNftPermissions(nftAddress: string, address: string): Promise<NftRoles> {
                const nftContract = this.getContract(nftAddress)
                const roles = await nftContract.getPermissions(address)
                return roles
              }
            Severity: Major
            Found in src/contracts/NFT.ts and 1 other location - About 1 hr to fix
            src/contracts/Datatoken.ts on lines 709..716

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

            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 getPermissions(
                dtAddress: string,
                address: string
              ): Promise<DatatokenRoles> {
                const dtContract = this.getContract(dtAddress)
            Severity: Major
            Found in src/contracts/Datatoken.ts and 1 other location - About 1 hr to fix
            src/contracts/NFT.ts on lines 676..680

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

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

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

              Function initializeCompute has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                public async initializeCompute(
                  assets: ComputeAsset[],
                  algorithm: ComputeAlgorithm,
                  computeEnv: string,
                  validUntil: number,
              Severity: Minor
              Found in src/services/Provider.ts - About 1 hr to fix

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

                  public async isDatatokenDeployer(
                    nftAddress: string,
                    address: string
                  ): Promise<boolean> {
                    const nftContract = this.getContract(nftAddress)
                Severity: Major
                Found in src/contracts/NFT.ts and 1 other location - About 1 hr to fix
                src/contracts/Datatoken.ts on lines 812..816

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

                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 isDatatokenDeployer(dtAddress: string, address: string): Promise<boolean> {
                    const dtContract = this.getContract(dtAddress)
                    const isDatatokenDeployer = await dtContract.isERC20Deployer(address)
                    return isDatatokenDeployer
                  }
                Severity: Major
                Found in src/contracts/Datatoken.ts and 1 other location - About 1 hr to fix
                src/contracts/NFT.ts on lines 698..705

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

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

                  public async waitForAqua(
                    did: string,
                    txid?: string,
                    signal?: AbortSignal
                  ): Promise<Asset> {
                Severity: Minor
                Found in src/services/Aquarius.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 checkDidFiles has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  public async checkDidFiles(
                    did: string,
                    serviceId: string,
                    providerUri: string,
                    withChecksum: boolean = false,
                Severity: Minor
                Found in src/services/Provider.ts - About 1 hr to fix

                  Function orderAsset has 12 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    asset: Asset,
                    consumerAccount: Signer,
                    config: Config,
                    datatoken: Datatoken,
                    providerUrl?: string,
                  Severity: Major
                  Found in src/utils/OrderUtils.ts - About 1 hr to fix

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

                    export interface UrlFile {
                      type: 'url'
                    
                      /**
                       * File index.
                    Severity: Major
                    Found in src/@types/File.ts and 1 other location - About 1 hr to fix
                    src/@types/File.ts on lines 34..59

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

                    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 interface GraphqlQuery {
                      type: 'graphql'
                    
                      /**
                       * @type {number}
                    Severity: Major
                    Found in src/@types/File.ts and 1 other location - About 1 hr to fix
                    src/@types/File.ts on lines 7..33

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

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

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

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

                        public async getDispensers(dtAddress: string): Promise<any[]> {
                          const dtContract = this.getContract(dtAddress)
                          const dispensers = await dtContract.getDispensers()
                          return dispensers
                        }
                      Severity: Major
                      Found in src/contracts/Datatoken.ts and 1 other location - About 1 hr to fix
                      src/contracts/Datatoken.ts on lines 789..793

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

                      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 getFixedRates(dtAddress: string): Promise<any[]> {
                          const dtContract = this.getContract(dtAddress)
                          const fixedRates = await dtContract.getFixedRates()
                          return fixedRates
                        }
                      Severity: Major
                      Found in src/contracts/Datatoken.ts and 1 other location - About 1 hr to fix
                      src/contracts/Datatoken.ts on lines 800..804

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

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

                        public async getComputeEnvironments(
                          providerUri: string,
                          signal?: AbortSignal
                        ): Promise<{ [chainId: number]: ComputeEnvironment[] }> {
                          const providerEndpoints = await this.getEndpoints(providerUri)
                      Severity: Minor
                      Found in src/services/Provider.ts - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language