src/hooks/usePricing/usePricing.ts
Function usePricing
has 220 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function usePricing(ddo: DDO): UsePricing {
const { ocean, accountId, config } = useOcean()
const [pricingIsLoading, setPricingIsLoading] = useState(false)
const [pricingStep, setPricingStep] = useState<number>()
const [pricingStepText, setPricingStepText] = useState<string>()
Function usePricing
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Wontfix
Wontfix
function usePricing(ddo: DDO): UsePricing {
const { ocean, accountId, config } = useOcean()
const [pricingIsLoading, setPricingIsLoading] = useState(false)
const [pricingStep, setPricingStep] = useState<number>()
const [pricingStepText, setPricingStepText] = useState<string>()
- 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
Function buyDT
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function buyDT(
dtAmount: number | string
): Promise<TransactionReceipt | void> {
if (!ocean || !accountId) return
File usePricing.ts
has 253 lines of code (exceeds 250 allowed). Consider refactoring. Wontfix
Wontfix
import { DDO, Logger } from '@oceanprotocol/lib'
import { useEffect, useState } from 'react'
import { useOcean } from 'providers'
import { PriceOptions } from './PriceOptions'
import { TransactionReceipt } from 'web3-core'
Function createPricing
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function createPricing(
priceOptions: PriceOptions
): Promise<TransactionReceipt | void> {
if (!ocean || !accountId || !dtSymbol) return
Function sellDT
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function sellDT(
dtAmount: number | string
): Promise<TransactionReceipt | void> {
if (!ocean || !accountId) return