oceanprotocol/ocean.js

View on GitHub

Showing 71 of 201 total issues

File Provider.ts has 752 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import fetch from 'cross-fetch'
import { ethers, Signer, providers } from 'ethers'
import { LoggerInstance } from '../utils'
import {
  Arweave,
Severity: Major
Found in src/services/Provider.ts - About 1 day to fix

    File Datatoken.ts has 584 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { ethers, Signer } from 'ethers'
    import Decimal from 'decimal.js'
    import ERC20Template from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json'
    import ERC20TemplateEnterprise from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json'
    import { amountToUnits, sendTx, ZERO_ADDRESS } from '../utils'
    Severity: Major
    Found in src/contracts/Datatoken.ts - About 1 day to fix

      File NFT.ts has 531 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { BigNumber, ethers } from 'ethers'
      import ERC721Template from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json'
      import { generateDtName, sendTx, getEventFromTx, ZERO_ADDRESS } from '../utils'
      import {
        MetadataProof,
      Severity: Major
      Found in src/contracts/NFT.ts - About 1 day to fix

        File FixedRateExchange.ts has 488 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import FixedRateExchangeAbi from '@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json'
        import { sendTx, ZERO_ADDRESS } from '../utils'
        import {
          PriceAndFees,
          FeesInfo,
        Severity: Minor
        Found in src/contracts/FixedRateExchange.ts - About 7 hrs to fix

          Function orderAsset has 181 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export async function orderAsset(
            asset: Asset,
            consumerAccount: Signer,
            config: Config,
            datatoken: Datatoken,
          Severity: Major
          Found in src/utils/OrderUtils.ts - About 7 hrs to fix

            Function orderAsset has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
            Open

            export async function orderAsset(
              asset: Asset,
              consumerAccount: Signer,
              config: Config,
              datatoken: Datatoken,
            Severity: Minor
            Found in src/utils/OrderUtils.ts - About 6 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

            File NFTFactory.ts has 439 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { BigNumber, ethers } from 'ethers'
            import ERC721Factory from '@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json'
            import {
              generateDtName,
              ZERO_ADDRESS,
            Severity: Minor
            Found in src/contracts/NFTFactory.ts - About 6 hrs to fix

              Function createAsset has 140 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export async function createAsset(
                name: string,
                symbol: string,
                owner: Signer,
                assetUrl: any, // files object
              Severity: Major
              Found in src/utils/Assets.ts - About 5 hrs to fix

                Datatoken has 34 functions (exceeds 20 allowed). Consider refactoring.
                Open

                export class Datatoken extends SmartContract {
                  public abiEnterprise: AbiItem[]
                  public nft: Nft
                
                  getDefaultAbi() {
                Severity: Minor
                Found in src/contracts/Datatoken.ts - About 4 hrs to fix

                  Function sendTx has a Cognitive Complexity of 26 (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 3 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

                  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

                    File ConfigHelper.ts has 319 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 3 hrs to fix

                      Function getAddressesFromEnv has 87 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

                        Nft has 25 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

                          Function createAsset has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                          Open

                          export async function createAsset(
                            name: string,
                            symbol: string,
                            owner: Signer,
                            assetUrl: any, // files object
                          Severity: Minor
                          Found in src/utils/Assets.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

                          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 createDatatoken has 59 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: Major
                            Found in src/contracts/NFT.ts - About 2 hrs to fix

                              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

                                  File Assets.ts has 263 lines of code (exceeds 250 allowed). Consider refactoring.
                                  Open

                                  import { SHA256 } from 'crypto-js'
                                  import { ethers, Signer } from 'ethers'
                                  import { ConfigHelper } from '../../src/config'
                                  import { hexlify } from 'ethers/lib/utils'
                                  import { createHash } from 'crypto'
                                  Severity: Minor
                                  Found in src/utils/Assets.ts - About 2 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language