XYOracleNetwork/plugins

View on GitHub

Showing 39 of 231 total issues

Function checkIpfsUrl has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const checkIpfsUrl = (urlToCheck: string, ipfsGateway?: string): string => {
  try {
    const url = new URL(urlToCheck)
    let protocol = url.protocol
    let host = url.host
Severity: Minor
Found in packages/payloadset/packages/http/src/lib/checkIpfsUrl.ts - About 1 hr to fix

    Function getNftsOwnedByAddress has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    export const getNftsOwnedByAddress = async (
      /** @param publicAddress The address of the wallet to search for NFTs */
      publicAddress: string,
      /** @param provider The provider to use for accessing the block chain */
      providers: Provider[],

    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 getAssetsFromWallet has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const getAssetsFromWallet = async (address: string, maxNfts = 10, timeout = 2000) => {
      const endpoint = assertEx(process.env.QUICKNODE_API_URI, () => 'No endpoint found')
    
      const axios = new AxiosJson({ timeout })
    
    

      Function getAppraisalsValidValidator has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      export const getAppraisalsValidValidator = (
        dictionary: Record<Hash, WithMeta<Payload>>,
        minimumExp: number,
      ): PayloadValidationFunction<EscrowTerms> => {
        return (terms: EscrowTerms) => {

      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 validDisplayType has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      const validDisplayType = (attribute: OpenSeaNftAttribute): boolean => {
        switch (attribute?.display_type) {
          case 'number':
          case 'boost_number': {
            if (isNumber(attribute?.value)) return true

      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 calculatePropertyDistribution has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      export const calculatePropertyDistribution = <T>(array: T[], property: keyof T): Distribution<T> => {
        const distribution: Distribution<T> = {}
        for (const item of array) {
          const value = item[property]
          if (value !== undefined && value !== null) {

      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 getDomainAllowedHyphensValidator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export const getDomainAllowedHyphensValidator = (
        options?: { end?: boolean; start?: boolean },
      ): PayloadValidationFunctionWithError<Payload<DomainFields>> => {
        return (
          payload: Payload<DomainFields>,

      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

      Avoid deeply nested control flow statements.
      Open

                if (!distribution[property]) {
                  distribution[property] = { [valueString]: 1 }
                } else if (distribution[property]![valueString]) {
                  ;(distribution[property] as Record<string, number>)[valueString] += 1
                } else {

        Avoid too many return statements within this function.
        Open

          if (!isWeb3(animation_url)) return score

          Avoid too many return statements within this function.
          Open

            return incrementTotal(score)

            Avoid too many return statements within this function.
            Open

              return false

              Function evaluateAttribute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export const evaluateAttribute = (attribute: OpenSeaNftAttribute): ScaledScore => {
                const score: ScaledScore = [0, 1]
                const max_value = attribute?.max_value
                const trait_type = attribute?.trait_type
                const value = attribute?.value

              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 getDomainLengthValidator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export const getDomainLengthValidator = (
                minNameLength = MIN_DOMAIN_LENGTH,
                maxLength = MAX_DOMAIN_LENGTH,
              ): PayloadValidationFunctionWithError<Payload<DomainFields>> => {
                return (

              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 scoreAnimationUrl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export const scoreAnimationUrl = (animation_url: unknown): ScaledScore => {
                const score: ScaledScore = [0, 0]
                if (animation_url === undefined || animation_url === null) return PASS
                incrementPossible(score)
                if (typeof animation_url !== 'string') return score

              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 calculateSingularFixedPriceDiscount has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              const calculateSingularFixedPriceDiscount = (total: number, appraisals: HashLeaseEstimate[], coupons: Coupon[], stackable = false): number => {
                // Find all singular fixed price discounts
                const singularFixedPriceDiscounts = coupons
                  .filter(isFixedPriceCoupon)
                  .filter(coupon => stackable ? isStackable(coupon) : !isStackable(coupon))
              Severity: Minor
              Found in packages/payloadset/packages/payments/src/Discount/lib/applyCoupons.ts - About 25 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 moduleIdentifiersContainsAllOf has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export const moduleIdentifiersContainsAllOf = (
                escrowTerms: EscrowTerms,
                selector: PayloadValueExpression<EscrowTerms, 'appraisalAuthorities' | 'buyer' | 'escrowAgent' | 'paymentAuthorities' | 'seller'>,
                moduleIdentifiers: ModuleIdentifier[],
                required: boolean = true,

              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 getNftsOwnedByAddressWithMetadata has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export const getNftsOwnedByAddressWithMetadata = async (
                /** @param publicAddress The address of the wallet to search for NFTs */
                publicAddress: string,
                /** @param provider The provider to use for accessing the block chain */
                providers: Provider[],

              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 getDomainReservedNamesValidator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export const getDomainReservedNamesValidator = (reservedNames: string[]): PayloadValidationFunction<Payload<DomainFields>> => {
                return (payload: Payload<DomainFields>) => {
                  const { domain } = payload
                  // Check if any of our fragments are in the name
                  for (const reserved of reservedNames) {

              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 moduleIdentifiersContainsOneOf has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export const moduleIdentifiersContainsOneOf = (
                escrowTerms: EscrowTerms,
                propertyExpression: PayloadValueExpression<EscrowTerms, 'appraisalAuthorities' | 'buyer' | 'escrowAgent' | 'paymentAuthorities' | 'seller'>,
                moduleIdentifiers: ModuleIdentifier[],
                required: boolean = true,

              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

              Severity
              Category
              Status
              Source
              Language