DeFiCh/jellyfish

View on GitHub

Showing 358 of 388 total issues

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

export function fromScriptP2WPKH (script: Script, network: NetworkName): string | undefined {
  if (!isScriptP2WPKH(script)) {
    return undefined
  }

Severity: Major
Found in packages/jellyfish-address/src/script/P2WPKH.ts and 1 other location - About 2 hrs to fix
packages/jellyfish-address/src/script/P2WSH.ts on lines 11..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 117.

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

  @Get('listpoolpairs')
  async listPoolPairs (
    @Query('network', NetworkValidationPipe) network: SupportedNetwork = 'mainnet'
  ): Promise<{ [key: string]: LegacyPoolPairData }> {
    const api = this.whaleApiClientProvider.getClient(network)
Severity: Major
Found in apps/legacy-api/src/controllers/PoolPairController.ts and 1 other location - About 2 hrs to fix
apps/legacy-api/src/controllers/TokenController.ts on lines 23..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 117.

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

  static uInt16 (getter: () => number, setter: (data: number) => void): BufferComposer {
    return {
      fromBuffer: (buffer: SmartBuffer): void => {
        setter(buffer.readUInt16LE())
      },
Severity: Major
Found in packages/jellyfish-buffer/src/Composer.ts and 2 other locations - About 2 hrs to fix
packages/jellyfish-buffer/src/Composer.ts on lines 459..468
packages/jellyfish-buffer/src/Composer.ts on lines 476..485

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

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

  static int32 (getter: () => number, setter: (data: number) => void): BufferComposer {
    return {
      fromBuffer: (buffer: SmartBuffer): void => {
        setter(buffer.readInt32LE())
      },
Severity: Major
Found in packages/jellyfish-buffer/src/Composer.ts and 2 other locations - About 2 hrs to fix
packages/jellyfish-buffer/src/Composer.ts on lines 442..451
packages/jellyfish-buffer/src/Composer.ts on lines 476..485

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

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

  static uInt32 (getter: () => number, setter: (data: number) => void): BufferComposer {
    return {
      fromBuffer: (buffer: SmartBuffer): void => {
        setter(buffer.readUInt32LE())
      },
Severity: Major
Found in packages/jellyfish-buffer/src/Composer.ts and 2 other locations - About 2 hrs to fix
packages/jellyfish-buffer/src/Composer.ts on lines 442..451
packages/jellyfish-buffer/src/Composer.ts on lines 459..468

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

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

File update.masternode.spec.ts has 272 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  createTestingApp,
  DelayedEunosPayaTestContainer,
  invalidateFromHeight,
  stopTestingApp,

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

      composers (cs: CompositeSwap): BufferComposer[] {
        return [
          ComposableBuffer.single<PoolSwap>(() => cs.poolSwap, v => cs.poolSwap = v, v => new CPoolSwap(v)),
          ComposableBuffer.compactSizeArray<PoolId>(() => cs.pools, v => cs.pools = v, v => new CPoolId(v))
        ]
    Severity: Major
    Found in packages/jellyfish-transaction/src/script/dftx/dftx_pool.ts and 1 other location - About 2 hrs to fix
    packages/jellyfish-transaction/src/script/dftx/dftx_account.ts on lines 153..158

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

    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

      composers (tdi: TransferDomainPair): BufferComposer[] {
        return [
          ComposableBuffer.single<TransferDomainItem>(() => tdi.src, v => tdi.src = v, v => new CTransferDomainItem(v)),
          ComposableBuffer.single<TransferDomainItem>(() => tdi.dst, v => tdi.dst = v, v => new CTransferDomainItem(v))
        ]
    packages/jellyfish-transaction/src/script/dftx/dftx_pool.ts on lines 75..80

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

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

      async getSwapsHistory (
        network: NetworkName,
        limit: number,
        nextToken: NextToken
      ): Promise<{ swaps: LegacySubgraphSwap[], next: NextToken }> {
    Severity: Major
    Found in apps/whale-api/src/module.api/legacy.subgraph.service.ts - About 2 hrs to fix

      Function setup has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function setup (): Promise<void> {
        accountAlice = await alice.generateAddress()
        accountBob = await bob.generateAddress()
      
        await alice.token.create({
      Severity: Major
      Found in apps/whale-api/src/module.api/consortium.controller.spec.ts - About 2 hrs to fix

        Function mapPoolPair has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async mapPoolPair (
            id: string,
            info: PoolPairInfo,
            totalLiquidityUsd?: BigNumber,
            apr?: PoolPairData['apr'],
        Severity: Major
        Found in apps/whale-api/src/module.api/poolpair.controller.ts - About 2 hrs to fix

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

              return latest.map(x => ({
                ...x,
                count: x.weeks === lockStats.weeks ? (x.count + lockStats.count) : x.count,
                tvl: x.weeks === lockStats.weeks ? new BigNumber(x.tvl).plus(lockStats.tvl).toFixed(8) : x.tvl
              }))
          apps/whale-api/src/module.indexer/model/dftx/resign.masternode.ts on lines 55..59

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

          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

              return latest.map(x => ({
                ...x,
                count: x.weeks === lockStats.weeks ? (x.count - lockStats.count) : x.count,
                tvl: x.weeks === lockStats.weeks ? new BigNumber(x.tvl).minus(lockStats.tvl).toFixed(8) : x.tvl
              }))
          apps/whale-api/src/module.indexer/model/dftx/create.masternode.ts on lines 75..79

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

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

          async function setupLoanToken (): Promise<void> {
            const oracleId = await testing.rpc.oracle.appointOracle(await testing.generateAddress(), [
              { token: 'DFI', currency: 'USD' },
              { token: 'LOAN', currency: 'USD' }
            ], { weightage: 1 })
          Severity: Major
          Found in apps/whale-api/src/module.api/address.controller.spec.ts - About 2 hrs to fix

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

                {
                  provide: WhaleApiClient,
                  useFactory: (configService: ConfigService): WhaleApiClient => {
                    return new WhaleApiClient({
                      version: 'v0',
            Severity: Major
            Found in apps/status-api/src/modules/WhaleApiModule.ts and 1 other location - About 2 hrs to fix
            apps/status-api/src/modules/ControllerModule.ts on lines 26..36

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

            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 function fromScriptP2PKH (script: Script, network: NetworkName): string | undefined {
              if (!isScriptP2PKH(script)) {
                return undefined
              }
            
            
            Severity: Major
            Found in packages/jellyfish-address/src/script/P2PKH.ts and 1 other location - About 2 hrs to fix
            packages/jellyfish-address/src/script/P2SH.ts on lines 12..21

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

            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 function fromScriptP2SH (script: Script, network: NetworkName): string | undefined {
              if (!isScriptP2SH(script)) {
                return undefined
              }
            
            
            Severity: Major
            Found in packages/jellyfish-address/src/script/P2SH.ts and 1 other location - About 2 hrs to fix
            packages/jellyfish-address/src/script/P2PKH.ts on lines 14..23

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

            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

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

                {
                  provide: WhaleApiClient,
                  useFactory: (configService: ConfigService): WhaleApiClient => {
                    return new WhaleApiClient({
                      version: 'v0',
            Severity: Major
            Found in apps/status-api/src/modules/ControllerModule.ts and 1 other location - About 2 hrs to fix
            apps/status-api/src/modules/WhaleApiModule.ts on lines 45..55

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

            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

            PoolPairService has 22 functions (exceeds 20 allowed). Consider refactoring.
            Open

            @Injectable()
            export class PoolPairService {
              constructor (
                @Inject('NETWORK') protected readonly network: NetworkName,
                private readonly poolSwapPathfindingService: PoolSwapPathFindingService,
            Severity: Minor
            Found in apps/whale-api/src/module.api/poolpair.service.ts - About 2 hrs to fix

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

              function isScriptP2WPKH (script: Script): boolean {
                return script.stack.length === 2 &&
                  script.stack[0].type === OP_CODES.OP_0.type &&
                  script.stack[1].type === 'OP_PUSHDATA' && (script.stack[1] as OP_PUSHDATA).length() === 20
              }
              Severity: Major
              Found in packages/jellyfish-address/src/script/P2WPKH.ts and 2 other locations - About 2 hrs to fix
              packages/jellyfish-address/src/eth.ts on lines 9..13
              packages/jellyfish-address/src/script/P2WSH.ts on lines 5..9

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

              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