oceanprotocol/ocean.js

View on GitHub

Showing 71 of 201 total issues

Function computeDelete has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public async computeDelete(
    did: string,
    consumer: Signer,
    jobId: string,
    providerUri: string,
Severity: Major
Found in src/services/Provider.ts - About 2 hrs to fix

    Function computeStop has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      public async computeStop(
        did: string,
        consumerAddress: string,
        jobId: string,
        providerUri: string,
    Severity: Major
    Found in src/services/Provider.ts - About 2 hrs to fix

      Function createNFT has 53 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: Major
      Found in src/contracts/NFTFactory.ts - About 2 hrs to fix

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

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

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

            public async computeStatus(
              providerUri: string,
              consumerAddress: string,
              jobId?: string,
              agreementId?: 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 createDatatoken has a Cognitive Complexity of 14 (exceeds 5 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

              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

              Consider simplifying this complex logical expression.
              Open

                if (feeHistory.maxPriorityFeePerGas) {
                  let aggressiveFeePriorityFeePerGas = feeHistory.maxPriorityFeePerGas.toString()
                  let aggressiveFeePerGas = feeHistory.maxFeePerGas.toString()
                  if (gasFeeMultiplier > 1) {
                    aggressiveFeePriorityFeePerGas = Math.round(
              Severity: Critical
              Found in src/utils/ContractUtils.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

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

                    private async getErcCreationParams(dtParams: DatatokenCreateParams): Promise<any> {
                      let name: string, symbol: string
                      // Generate name & symbol if not present
                      if (!dtParams.name || !dtParams.symbol) {
                        ;({ name, symbol } = generateDtName())
                  Severity: Minor
                  Found in src/contracts/NFTFactory.ts - About 1 hr to fix

                    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 createAsset has 13 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        name: string,
                        symbol: string,
                        owner: Signer,
                        assetUrl: any, // files object
                        templateIDorAddress: string | number, // If string, it's template address , otherwise, it's templateId
                      Severity: Major
                      Found in src/utils/Assets.ts - About 1 hr to fix

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

                          private async getErcCreationParams(dtParams: DatatokenCreateParams): Promise<any> {
                            let name: string, symbol: string
                            // Generate name & symbol if not present
                            if (!dtParams.name || !dtParams.symbol) {
                              ;({ name, symbol } = generateDtName())
                        Severity: Minor
                        Found in src/contracts/NFTFactory.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 deployAccessListContract has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            public async deployAccessListContract<G extends boolean = false>(
                              nameAccessList: string,
                              symbolAccessList: string,
                              tokenURI: string[],
                              transferable: boolean = false,
                          Severity: Minor
                          Found in src/contracts/AccessListFactory.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

                              Function getConfig has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                public getConfig(network: string | number, infuraProjectId?: string): Config {
                                  const filterBy = typeof network === 'string' ? 'network' : 'chainId'
                              
                                  let config = configHelperNetworks.find((c) => c[filterBy] === network)
                              
                              
                              Severity: Minor
                              Found in src/config/ConfigHelper.ts - About 1 hr to fix

                                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

                                  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
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language