XYOracleNetwork/plugins

View on GitHub

Showing 232 of 232 total issues

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

export const isHttpCallXmlResult = (x?: unknown | null): x is HttpCallXmlResult => {
  return isPayloadOfSchemaType(HttpCallResultSchema)(x) && typeof (x as HttpCallXmlResult)?.data === 'string'
}
packages/payloadset/packages/api/src/Payload/identity/isApiCallBase64Result.ts on lines 6..8
packages/payloadset/packages/api/src/Payload/identity/isApiCallXmlResult.ts on lines 6..8
packages/payloadset/packages/http/src/Payload/identity/isHttpCallBase64Result.ts on lines 6..8

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 66.

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 5 locations. Consider refactoring.
Open

export const BowserSystemInfoPlugin = () =>
  createPayloadSetWitnessPlugin<BowserSystemInfoWitness>(
    { required: { [BowserSystemInfoSchema]: 1 }, schema: PayloadSetSchema },
    {
      witness: async (params) => {
packages/payloadset/packages/blockchain/packages/ethereum/packages/gas/packages/ethers/src/Plugin.ts on lines 7..15
packages/payloadset/packages/crypto/packages/cards/packages/move/src/Plugin.ts on lines 7..15
packages/payloadset/packages/crypto/packages/nft/packages/wallet/quicknode/src/Plugin.ts on lines 6..14
packages/payloadset/packages/location/src/Plugin.ts on lines 7..15

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 66.

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 5 locations. Consider refactoring.
Open

export const CryptoCardsMovePlugin = () =>
  createPayloadSetWitnessPlugin<CryptoCardsMoveWitness>(
    { required: { [CryptoCardsMoveSchema]: 1 }, schema: PayloadSetSchema },
    {
      witness: async (params) => {
packages/payloadset/packages/blockchain/packages/ethereum/packages/gas/packages/ethers/src/Plugin.ts on lines 7..15
packages/payloadset/packages/crypto/packages/nft/packages/wallet/quicknode/src/Plugin.ts on lines 6..14
packages/payloadset/packages/location/src/Plugin.ts on lines 7..15
packages/payloadset/packages/system/packages/info/packages/bowser/src/Plugin.ts on lines 7..15

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 66.

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 isHttpCallBase64Result = (x?: unknown | null): x is HttpCallBase64Result => {
  return isPayloadOfSchemaType(HttpCallResultSchema)(x) && typeof (x as HttpCallBase64Result)?.data === 'string'
}
packages/payloadset/packages/api/src/Payload/identity/isApiCallBase64Result.ts on lines 6..8
packages/payloadset/packages/api/src/Payload/identity/isApiCallXmlResult.ts on lines 6..8
packages/payloadset/packages/http/src/Payload/identity/isHttpCallXmlResult.ts on lines 6..8

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 66.

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

    try {
      symbol = await contract721.symbol()
    } catch (ex) {
      const error = ex as Error
      console.log(`symbol: ${error.message}`)
packages/payloadset/packages/crypto/packages/nft/packages/nft/packages/witness/src/lib/getNftCollectionMetadata.ts on lines 20..25

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 66.

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 isApiCallBase64Result = (x?: unknown | null): x is ApiCallBase64Result => {
  return isPayloadOfSchemaType(ApiCallResultSchema)(x) && typeof (x as ApiCallBase64Result)?.data === 'string'
}
packages/payloadset/packages/api/src/Payload/identity/isApiCallXmlResult.ts on lines 6..8
packages/payloadset/packages/http/src/Payload/identity/isHttpCallBase64Result.ts on lines 6..8
packages/payloadset/packages/http/src/Payload/identity/isHttpCallXmlResult.ts on lines 6..8

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 66.

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 isApiUriTemplateCall = (value?: unknown): value is ApiUriTemplateCall =>
  isApiCall(value) && !!((value as ApiUriTemplateCall).uriTemplate || (value as ApiUriTemplateCall).params)
packages/payloadset/packages/http/src/Payload/identity/isHttpUriTemplateCall.ts on lines 4..5

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 66.

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

    try {
      name = await contract721.name()
    } catch (ex) {
      const error = ex as Error
      console.log(`name: ${error.message}`)
packages/payloadset/packages/crypto/packages/nft/packages/nft/packages/witness/src/lib/getNftCollectionMetadata.ts on lines 27..32

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 66.

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 isHttpUriTemplateCall = (value?: unknown): value is HttpUriTemplateCall =>
  isHttpCall(value) && !!((value as HttpUriTemplateCall).uriTemplate || (value as HttpUriTemplateCall).params)
packages/payloadset/packages/api/src/Payload/identity/isApiUriTemplateCall.ts on lines 4..5

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 66.

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 5 locations. Consider refactoring.
Open

export const EthereumGasEthersPlugin = () =>
  createPayloadSetWitnessPlugin<EthereumGasEthersWitness>(
    { required: { [EthereumGasEthersSchema]: 1 }, schema: PayloadSetSchema },
    {
      witness: async (params) => {
packages/payloadset/packages/crypto/packages/cards/packages/move/src/Plugin.ts on lines 7..15
packages/payloadset/packages/crypto/packages/nft/packages/wallet/quicknode/src/Plugin.ts on lines 6..14
packages/payloadset/packages/location/src/Plugin.ts on lines 7..15
packages/payloadset/packages/system/packages/info/packages/bowser/src/Plugin.ts on lines 7..15

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 66.

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 isApiCallXmlResult = (x?: unknown | null): x is ApiCallXmlResult => {
  return isPayloadOfSchemaType(ApiCallResultSchema)(x) && typeof (x as ApiCallXmlResult)?.data === 'string'
}
packages/payloadset/packages/api/src/Payload/identity/isApiCallBase64Result.ts on lines 6..8
packages/payloadset/packages/http/src/Payload/identity/isHttpCallBase64Result.ts on lines 6..8
packages/payloadset/packages/http/src/Payload/identity/isHttpCallXmlResult.ts on lines 6..8

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 66.

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 isEmailWithSources = (value: unknown): value is Email => {
  return isPayloadOfSchemaTypeWithSources<Email>(EmailAddressSchema)(value) && isValidEmail(value.address)
}
Severity: Major
Found in packages/payload/packages/email/src/Payload.ts and 1 other location - About 1 hr to fix
packages/payload/packages/email/src/Payload.ts on lines 62..64

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 65.

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 isEmail = (value: unknown): value is Email => {
  return isPayloadOfSchemaType<Email>(EmailAddressSchema)(value) && isValidEmail(value.address)
}
Severity: Major
Found in packages/payload/packages/email/src/Payload.ts and 1 other location - About 1 hr to fix
packages/payload/packages/email/src/Payload.ts on lines 69..71

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 65.

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

        maxNftsArray.map(async (_value, i) => {
          const tokenId = (await tryCall(async () => await enumerable.tokenByIndex(i, { blockTag: block }))) ?? BigInt(i)
          if (tokenId !== undefined) {
            const supply
              = finalTypes.includes(toTokenType('ERC1155'))

    Function getErc1967SlotStatus has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const getErc1967SlotStatus = async (provider: Provider, address: string, block?: number): Promise<Erc1967SlotStatus> => {
      const status: Erc1967SlotStatus = {
        address,
        implementation: address,
        slots: {

      Function getNftCollectionMetadata has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const getNftCollectionMetadata = async (
        /**
         * The address of the NFT contract to search for
         */
        contractAddress: string,

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

          const singularFixedDiscount = Math.max(...coupons
            .filter(coupon => isFixedAmountCoupon(coupon) && !isStackable(coupon))
            .map(coupon => (coupon as FixedAmountCoupon).amount), 0)
        packages/payloadset/packages/payments/src/Discount/lib/applyCoupons.ts on lines 28..30

        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 60.

        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 singularPercentageDiscount = (Math.max(...coupons
            .filter(coupon => isFixedPercentageCoupon(coupon) && !isStackable(coupon))
            .map(coupon => (coupon as FixedPercentageCoupon).percentage), 0)) * total
        packages/payloadset/packages/payments/src/Discount/lib/applyCoupons.ts on lines 25..27

        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 60.

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

        export const applyCoupons = (appraisals: HashLeaseEstimate[], coupons: Coupon[]): Discount => {
          // Ensure all appraisals and coupons are in USD
          const allAppraisalsAreUSD = appraisals.every(appraisal => appraisal.currency === 'USD')
          assertEx(allAppraisalsAreUSD, 'All appraisals must be in USD')
          const allCouponsAreUSD = coupons.map(coupon => (coupon as Partial<AmountFields>)?.currency).filter(exists).every(currency => currency === 'USD')

          Function createConditionForMaximumAppraisalAmount has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const createConditionForMaximumAppraisalAmount = (maximumAppraisalAmount: number): Condition => {
            return {
              schema: SchemaSchema,
              definition: {
                allOf: [
            Severity
            Category
            Status
            Source
            Language