oceanprotocol/ocean.js

View on GitHub

Showing 71 of 201 total issues

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

    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 getConfig has a Cognitive Complexity of 11 (exceeds 5 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

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

                  Function createNftWithDatatokenWithDispenser has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    public async createNftWithDatatokenWithDispenser<G extends boolean = false>(
                      nftCreateData: NftCreateData,
                      dtParams: DatatokenCreateParams,
                      dispenserParams: DispenserCreationParams,
                      estimateGas?: G
                  Severity: Minor
                  Found in src/contracts/NFTFactory.ts - About 1 hr to fix

                    Function createDispenser has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      public async createDispenser<G extends boolean = false>(
                        dtAddress: string,
                        address: string,
                        dispenserAddress: string,
                        dispenserParams: DispenserParams,
                    Severity: Minor
                    Found in src/contracts/Datatoken.ts - About 1 hr to fix

                      Function startOrder has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        public async startOrder<G extends boolean = false>(
                          dtAddress: string,
                          consumer: string,
                          serviceIndex: number,
                          providerFees: ProviderFees,
                      Severity: Minor
                      Found in src/contracts/Datatoken.ts - About 1 hr to fix

                        Function createNFT has a Cognitive Complexity of 9 (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 55 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 computeStatus has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                        Open

                          public async computeStatus(
                            providerUri: string,
                            consumerAddress: string,
                            jobId?: string,
                            agreementId?: string,
                        Severity: Minor
                        Found in src/services/Provider.ts - About 55 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 transfer has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                          signer: Signer,
                          config: Config,
                          tokenAddress: string,
                          recipient: string,
                          amount: string,
                        Severity: Minor
                        Found in src/utils/TokenUtils.ts - About 45 mins to fix

                          Function calculateActiveTemplateIndex has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                          export async function calculateActiveTemplateIndex(
                            owner: Signer,
                            nftContractAddress: string, // addresses.ERC721Factory,
                            template: string | number
                          ): Promise<number> {
                          Severity: Minor
                          Found in src/utils/Assets.ts - About 45 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 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 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

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

                            export function getOceanArtifactsAdressesByChainId(chain: number): any {
                              try {
                                // eslint-disable-next-line security/detect-non-literal-fs-filename
                                const data = getOceanArtifactsAdresses()
                                if (data) {
                            Severity: Minor
                            Found in src/utils/Assets.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 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

                            Severity
                            Category
                            Status
                            Source
                            Language