Showing 59 of 173 total issues
File Provider.ts
has 748 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import fetch from 'cross-fetch'
import { ethers, Signer, providers } from 'ethers'
import { LoggerInstance } from '../utils'
import {
Arweave,
File Datatoken.ts
has 584 lines of code (exceeds 250 allowed). Consider refactoring. Open
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'
File NFT.ts
has 492 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { BigNumber, ethers } from 'ethers'
import ERC721Template from '@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json'
import { generateDtName, sendTx, getEventFromTx } from '../utils'
import {
MetadataProof,
File FixedRateExchange.ts
has 488 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import FixedRateExchangeAbi from '@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json'
import { sendTx, ZERO_ADDRESS } from '../utils'
import {
PriceAndFees,
FeesInfo,
Function orderAsset
has 178 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function orderAsset(
asset: Asset,
consumerAccount: Signer,
config: Config,
datatoken: Datatoken,
Function orderAsset
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
Open
export async function orderAsset(
asset: Asset,
consumerAccount: Signer,
config: Config,
datatoken: Datatoken,
- Read upRead up
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 415 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { BigNumber } from 'ethers'
import ERC721Factory from '@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json'
import {
generateDtName,
ZERO_ADDRESS,
Datatoken
has 34 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class Datatoken extends SmartContract {
public abiEnterprise: AbiItem[]
public nft: Nft
getDefaultAbi() {
FixedRateExchange
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class FixedRateExchange extends SmartContractWithAddress {
getDefaultAbi() {
return FixedRateExchangeAbi.abi as AbiItem[]
}
Function getAddressesFromEnv
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
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]) {
Nft
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class Nft extends SmartContract {
getDefaultAbi() {
return ERC721Template.abi as AbiItem[]
}
NftFactory
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class NftFactory extends SmartContractWithAddress {
getDefaultAbi() {
return ERC721Factory.abi as AbiItem[]
}
Provider
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class Provider {
/**
* Returns the provider endpoints
* @param {string} providerUri - the provider url
* @return {Promise<any>}
Function computeStart
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public async computeStart(
providerUri: string,
consumer: Signer,
computeEnv: string,
dataset: ComputeAsset,
Function computeStop
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public async computeStop(
did: string,
consumerAddress: string,
jobId: string,
providerUri: string,
Function computeDelete
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public async computeDelete(
did: string,
consumer: Signer,
jobId: string,
providerUri: string,
Function computeStatus
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public async computeStatus(
providerUri: string,
consumerAddress: string,
jobId?: string,
did?: string,
Function createFixedRate
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public async createFixedRate<G extends boolean = false>(
dtAddress: string,
address: string,
fixedRateParams: FreCreationParams,
estimateGas?: G
Function createNFT
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public async createNFT<G extends boolean = false>(
nftData: NftCreateData,
estimateGas?: G
): Promise<G extends false ? string : BigNumber> {
if (!nftData.templateIndex) nftData.templateIndex = 1
Function initialize
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public async initialize(
did: string,
serviceId: string,
fileIndex: number,
consumerAddress: string,