oceanprotocol/ocean.js

View on GitHub
src/utils/Assets.ts

Summary

Maintainability
D
1 day
Test Coverage
D
67%

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

    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

    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

      Function createAsset has 13 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        name: string,
        symbol: string,
        owner: Signer,
        assetUrl: any, // files object
        templateIDorAddress: string | number, // If string, it's template address , otherwise, it's templateId
      Severity: Major
      Found in src/utils/Assets.ts - About 1 hr to fix

        Function calculateActiveTemplateIndex has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export async function calculateActiveTemplateIndex(
          owner: Signer,
          nftContractAddress: string, // addresses.ERC721Factory,
          template: string | number
        ): Promise<number> {
        Severity: Minor
        Found in src/utils/Assets.ts - About 45 mins 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

        Function getOceanArtifactsAdressesByChainId has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        export function getOceanArtifactsAdressesByChainId(chain: number): any {
          try {
            // eslint-disable-next-line security/detect-non-literal-fs-filename
            const data = getOceanArtifactsAdresses()
            if (data) {
        Severity: Minor
        Found in src/utils/Assets.ts - About 35 mins 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

        There are no issues that match your filters.

        Category
        Status