oceanprotocol/ocean.js

View on GitHub

Showing 169 of 177 total issues

FixedRateExchange has 30 functions (exceeds 20 allowed). Consider refactoring.
Open

export class FixedRateExchange extends SmartContractWithAddress {
  getDefaultAbi() {
    return FixedRateExchangeAbi.abi as AbiItem[]
  }

Severity: Minor
Found in src/contracts/FixedRateExchange.ts - About 3 hrs to fix

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

    export async function unitsToAmount(
      signer: Signer,
      token: string,
      amount: string,
      tokenDecimals?: number
    Severity: Major
    Found in src/utils/ContractUtils.ts and 1 other location - About 3 hrs to fix
    src/utils/ContractUtils.ts on lines 84..96

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

    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 async function amountToUnits(
      signer: Signer,
      token: string,
      amount: string,
      tokenDecimals?: number
    Severity: Major
    Found in src/utils/ContractUtils.ts and 1 other location - About 3 hrs to fix
    src/utils/ContractUtils.ts on lines 61..74

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

    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 claimRewards<G extends boolean = false>(
        userAddress: string,
        tokenAddress: string,
        estimateGas?: G
      ): Promise<ReceiptOrEstimate<G>> {
    Severity: Major
    Found in src/contracts/df/DfRewards.ts and 1 other location - About 3 hrs to fix
    src/contracts/df/DfStrategyV1.ts on lines 36..57

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

    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 claimMultipleRewards<G extends boolean = false>(
        userAddress: string,
        tokenAddresses: string[],
        estimateGas?: G
      ): Promise<ReceiptOrEstimate<G>> {
    Severity: Major
    Found in src/contracts/df/DfStrategyV1.ts and 1 other location - About 3 hrs to fix
    src/contracts/df/DfRewards.ts on lines 36..54

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

    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

        try {
          response = await fetch(computeStopUrl, {
            method: 'PUT',
            body: JSON.stringify(payload),
            headers: { 'Content-Type': 'application/json' },
    Severity: Major
    Found in src/services/Provider.ts and 2 other locations - About 3 hrs to fix
    src/services/Provider.ts on lines 578..590
    src/services/Provider.ts on lines 841..853

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

    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

        try {
          response = await fetch(computeStartUrl, {
            method: 'POST',
            body: JSON.stringify(payload),
            headers: { 'Content-Type': 'application/json' },
    Severity: Major
    Found in src/services/Provider.ts and 2 other locations - About 3 hrs to fix
    src/services/Provider.ts on lines 655..667
    src/services/Provider.ts on lines 841..853

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

    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

        try {
          response = await fetch(computeDeleteUrl, {
            method: 'DELETE',
            body: JSON.stringify(payload),
            headers: { 'Content-Type': 'application/json' },
    Severity: Major
    Found in src/services/Provider.ts and 2 other locations - About 3 hrs to fix
    src/services/Provider.ts on lines 578..590
    src/services/Provider.ts on lines 655..667

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

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

      public getAddressesFromEnv(network: string, customAddresses?: any): Partial<Config> {
        // use the defaults first
        let configAddresses: Partial<Config>
        // load from custom addresses structure
        if (customAddresses && customAddresses[network]) {
    Severity: Major
    Found in src/config/ConfigHelper.ts - About 3 hrs to fix

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

          try {
            response = await fetch(path, {
              method: 'POST',
              body: JSON.stringify(args),
              headers: { 'Content-Type': 'application/json' },
      Severity: Major
      Found in src/services/Provider.ts and 1 other location - About 2 hrs to fix
      src/services/Provider.ts on lines 207..218

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

      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

          try {
            response = await fetch(path, {
              method: 'POST',
              body: JSON.stringify(args),
              headers: { 'Content-Type': 'application/json' },
      Severity: Major
      Found in src/services/Provider.ts and 1 other location - About 2 hrs to fix
      src/services/Provider.ts on lines 262..273

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

      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 getBasetokenSupply(exchangeId: string): Promise<string> {
          const btSupply = await this.contract.getBTSupply(exchangeId)
          const exchange = await this.getExchange(exchangeId)
          return await this.unitsToAmount(exchange.baseToken, btSupply, +exchange.btDecimals)
        }
      Severity: Major
      Found in src/contracts/FixedRateExchange.ts and 1 other location - About 2 hrs to fix
      src/contracts/FixedRateExchange.ts on lines 272..276

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

      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 getDatatokenSupply(exchangeId: string): Promise<string> {
          const dtSupply = await this.contract.getDTSupply(exchangeId)
          const exchange = await this.getExchange(exchangeId)
          return await this.unitsToAmount(exchange.datatoken, dtSupply, +exchange.dtDecimals)
        }
      Severity: Major
      Found in src/contracts/FixedRateExchange.ts and 1 other location - About 2 hrs to fix
      src/contracts/FixedRateExchange.ts on lines 283..287

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

      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

      Nft has 24 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export class Nft extends SmartContract {
        getDefaultAbi() {
          return ERC721Template.abi as AbiItem[]
        }
      
      
      Severity: Minor
      Found in src/contracts/NFT.ts - About 2 hrs to fix

        NftFactory has 23 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export class NftFactory extends SmartContractWithAddress {
          getDefaultAbi() {
            return ERC721Factory.abi as AbiItem[]
          }
        
        
        Severity: Minor
        Found in src/contracts/NFTFactory.ts - About 2 hrs to fix

          Function sendTx has a Cognitive Complexity of 18 (exceeds 5 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 2 hrs 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

          Provider has 22 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export class Provider {
            /**
             * Returns the provider endpoints
             * @param {string} providerUri - the provider url
             * @return {Promise<any>}
          Severity: Minor
          Found in src/services/Provider.ts - About 2 hrs to fix

            Function computeStart has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              public async computeStart(
                providerUri: string,
                consumer: Signer,
                computeEnv: string,
                dataset: ComputeAsset,
            Severity: Major
            Found in src/services/Provider.ts - About 2 hrs to fix

              Function computeStop has 56 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 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
                  Severity
                  Category
                  Status
                  Source
                  Language