XYOracleNetwork/plugins

View on GitHub

Showing 232 of 232 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

export const getSellerSecretSignedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): AsyncPayloadValidationFunction<EscrowTerms> => {
  return getPartySecretSignedValidator(dictionary, 'seller')
}
packages/payload/packages/payments/src/Escrow/validators/escrow/buyerSecret.ts on lines 47..49

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 59.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

export const getBuyerSecretSignedValidator = (dictionary: Record<Hash, WithMeta<Payload>>): AsyncPayloadValidationFunction<EscrowTerms> => {
  return getPartySecretSignedValidator(dictionary, 'buyer')
}
packages/payload/packages/payments/src/Escrow/validators/escrow/sellerSecret.ts on lines 47..49

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 59.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

const getLogPrefix = (party: EscrowParty) => {
  const partySecret: EscrowPartySecret = party === 'seller' ? 'sellerSecret' : 'buyerSecret'
  return `EscrowTerms.${partySecret}`
}
packages/payload/packages/payments/src/Escrow/util/secret/findEscrowPartySecretSignatures.ts on lines 14..17

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 58.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

const getLogPrefix = (party: EscrowParty) => {
  const partySecret: EscrowPartySecret = party === 'seller' ? 'sellerSecret' : 'buyerSecret'
  return `EscrowTerms.${partySecret}`
}
packages/payload/packages/payments/src/Escrow/validators/common/SecretValidators/getPartySecretSignedValidator.ts on lines 17..20

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 58.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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/api/src/lib/checkIpfsUrl.ts - About 1 hr to fix

    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

      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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        export type ApiCallJsonResult<T extends ApiCallJsonResultType = ApiCallJsonResultType> = Payload<
          {
            call: Hash
            contentType: 'application/json'
            data: T
        packages/payloadset/packages/http/src/Payload/types/HttpCallJsonResult.ts on lines 11..18

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 57.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        export type HttpCallJsonResult<T extends HttpCallJsonResultType = HttpCallJsonResultType> = Payload<
          {
            call: Hash
            contentType: 'application/json'
            data: T
        packages/payloadset/packages/api/src/Payload/types/ApiCallJsonResult.ts on lines 11..18

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 57.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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 })
        
        

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

          export const isEvmCallFailure = (payload?: EvmCallResult): payload is EvmCallFailure => {
            return (payload as EvmCallFailure | undefined)?.error !== undefined
          }
          Severity: Major
          Found in packages/payloadset/packages/evm/packages/call/src/Payload.ts and 3 other locations - About 55 mins to fix
          packages/payload/packages/crypto/packages/nft/packages/contract/packages/function-read/src/Payload.ts on lines 57..59
          packages/payload/packages/crypto/packages/nft/packages/contract/packages/function-read/src/Payload.ts on lines 61..63
          packages/payloadset/packages/evm/packages/call/src/Payload.ts on lines 42..44

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 54.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

          export const isEvmCallSuccess = (payload?: EvmCallResult): payload is EvmCallSuccess => {
            return (payload as EvmCallSuccess | undefined)?.result !== undefined
          }
          Severity: Major
          Found in packages/payloadset/packages/evm/packages/call/src/Payload.ts and 3 other locations - About 55 mins to fix
          packages/payload/packages/crypto/packages/nft/packages/contract/packages/function-read/src/Payload.ts on lines 57..59
          packages/payload/packages/crypto/packages/nft/packages/contract/packages/function-read/src/Payload.ts on lines 61..63
          packages/payloadset/packages/evm/packages/call/src/Payload.ts on lines 46..48

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 54.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

          export const isCryptoContractFunctionCallFailure = (payload?: CryptoContractFunctionCallResult): payload is CryptoContractFunctionCallFailure => {
            return (payload as CryptoContractFunctionCallFailure | undefined)?.error !== undefined
          }
          packages/payload/packages/crypto/packages/nft/packages/contract/packages/function-read/src/Payload.ts on lines 57..59
          packages/payloadset/packages/evm/packages/call/src/Payload.ts on lines 42..44
          packages/payloadset/packages/evm/packages/call/src/Payload.ts on lines 46..48

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 54.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

          export const isCryptoContractFunctionCallSuccess = (payload?: CryptoContractFunctionCallResult): payload is CryptoContractFunctionCallSuccess => {
            return (payload as CryptoContractFunctionCallSuccess | undefined)?.result !== undefined
          }
          packages/payload/packages/crypto/packages/nft/packages/contract/packages/function-read/src/Payload.ts on lines 61..63
          packages/payloadset/packages/evm/packages/call/src/Payload.ts on lines 42..44
          packages/payloadset/packages/evm/packages/call/src/Payload.ts on lines 46..48

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 54.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

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

          export const getAppraisalsValidValidator = (
            dictionary: Record<Hash, WithMeta<Payload>>,
            minimumExp: number,
          ): SyncPayloadValidationFunction<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 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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            const stackedPercentageDiscount = coupons
              .filter(coupon => isFixedPercentageCoupon(coupon) && isStackable(coupon))
              .reduce((acc, coupon) => acc + (coupon as FixedPercentageCoupon).percentage, 0) * (total - stackedFixedDiscount)
          packages/payloadset/packages/payments/src/Discount/lib/applyCoupons.ts on lines 35..37

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 53.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            const stackedFixedDiscount = coupons
              .filter(coupon => isFixedAmountCoupon(coupon) && isStackable(coupon))
              .reduce((acc, coupon) => acc + (coupon as FixedAmountCoupon).amount, 0)
          packages/payloadset/packages/payments/src/Discount/lib/applyCoupons.ts on lines 40..42

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 53.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language