Showing 26 of 43 total issues
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 usePublish
has 125 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function usePublish(): UsePublish {
const { ocean, status, account, accountId } = useOcean()
const [isLoading, setIsLoading] = useState(false)
const [publishStep, setPublishStep] = useState<number | undefined>()
const [publishStepText, setPublishStepText] = useState<string | undefined>()
Function publish
has 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function publish(
asset: Metadata,
serviceType: ServiceType,
dataTokenOptions?: DataTokenOptions,
timeout?: number,
Function useMetadata
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function useMetadata(asset?: DID | string | DDO): UseMetadata {
const { ocean, config, status, networkId } = useOcean()
const [internalDdo, setDDO] = useState<DDO>()
const [internalDid, setDID] = useState<DID | string>()
const [metadata, setMetadata] = useState<Metadata>()
Function useCompute
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function useCompute(): UseCompute {
const { ocean, account, accountId } = useOcean()
const [computeStep, setComputeStep] = useState<number | undefined>()
const [computeStepText, setComputeStepText] = useState<string | undefined>()
const [computeError, setComputeError] = useState<string | undefined>()
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
Function useConsume
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function useConsume(): UseConsume {
const { ocean, account, accountId } = useOcean()
const [isLoading, setIsLoading] = useState(false)
const [consumeStep, setConsumeStep] = useState<number | undefined>()
const [consumeStepText, setConsumeStepText] = useState<string | undefined>()
Function compute
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function compute(
did: string,
computeService: ServiceCompute,
dataTokenAddress: string,
algorithmRawCode: string,
Function Trade
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function Trade() {
const { ocean, accountId } = useOcean()
const {
createPricing,
buyDT,
Function ConsumeDdo
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function ConsumeDdo() {
const { ocean, accountId } = useOcean()
const { consumeStepText, consume, consumeError } = useConsume()
const { compute, computeStepText } = useCompute()
const [did, setDid] = useState<string | undefined>()
Function useCompute
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
function useCompute(): UseCompute {
const { ocean, account, accountId } = useOcean()
const [computeStep, setComputeStep] = useState<number | undefined>()
const [computeStepText, setComputeStepText] = useState<string | undefined>()
const [computeError, setComputeError] = useState<string | undefined>()
- 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 getCheapestExchangePrice
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function getCheapestExchangePrice(
ocean: Ocean,
dataTokenAddress: string
): Promise<BestPrice> {
try {
Function usePublish
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
function usePublish(): UsePublish {
const { ocean, status, account, accountId } = useOcean()
const [isLoading, setIsLoading] = useState(false)
const [publishStep, setPublishStep] = useState<number | undefined>()
const [publishStepText, setPublishStepText] = useState<string | undefined>()
- 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 getFirstPoolPrice
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function getFirstPoolPrice(
ocean: Ocean,
dataTokenAddress: string,
poolAddress?: string
): Promise<BestPrice> {
Function consume
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function consume(
did: DID | string,
dataTokenAddress: string,
serviceType: ServiceType = 'access',
marketFeeAddress: string,
Function getCheapestPoolPrice
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function getCheapestPoolPrice(
ocean: Ocean,
dataTokenAddress: string
): Promise<BestPrice> {
const tokenPools = await ocean.pool.searchPoolforDT(dataTokenAddress)
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 Publish
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function Publish() {
const { publish, publishStepText, isLoading } = usePublish()
const [ddo, setDdo] = useState<DDO | undefined | null>()
const asset = {
Function getFirstExchangePrice
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function getFirstExchangePrice(
ocean: Ocean,
dataTokenAddress: string
): Promise<BestPrice> {
try {
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