DeFiCh/jellyfish

View on GitHub

Showing 358 of 388 total issues

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

const OraclePriceAggregatedIntervalMapping: ModelMapping<OraclePriceAggregatedInterval> = {
  type: 'oracle_price_aggregated_interval',
  index: {
    key_sort: {
      name: 'oracle_price_aggregated_interval_key_sort',
apps/whale-api/src/module.model/oracle.history.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.active.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.aggregated.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.feed.ts on lines 5..20
apps/whale-api/src/module.model/oracle.token.currency.ts on lines 5..20
apps/whale-api/src/module.model/pool.swap.aggregated.ts on lines 5..20
apps/whale-api/src/module.model/pool.swap.ts on lines 5..20
apps/whale-api/src/module.model/script.activity.ts on lines 5..20
apps/whale-api/src/module.model/script.unspent.ts on lines 5..20
apps/whale-api/src/module.model/transaction.vin.ts on lines 5..20
apps/whale-api/src/module.model/transaction.vout.ts on lines 6..21
apps/whale-api/src/module.model/vault.auction.batch.history.ts on lines 5..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 102.

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

const PoolSwapAggregatedMapping: ModelMapping<PoolSwapAggregated> = {
  type: 'pool_swap_aggregated',
  index: {
    key_sort: {
      name: 'pool_swap_aggregated_key_bucket',
Severity: Major
Found in apps/whale-api/src/module.model/pool.swap.aggregated.ts and 12 other locations - About 1 hr to fix
apps/whale-api/src/module.model/oracle.history.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.active.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.aggregated.interval.ts on lines 12..27
apps/whale-api/src/module.model/oracle.price.aggregated.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.feed.ts on lines 5..20
apps/whale-api/src/module.model/oracle.token.currency.ts on lines 5..20
apps/whale-api/src/module.model/pool.swap.ts on lines 5..20
apps/whale-api/src/module.model/script.activity.ts on lines 5..20
apps/whale-api/src/module.model/script.unspent.ts on lines 5..20
apps/whale-api/src/module.model/transaction.vin.ts on lines 5..20
apps/whale-api/src/module.model/transaction.vout.ts on lines 6..21
apps/whale-api/src/module.model/vault.auction.batch.history.ts on lines 5..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 102.

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

const TransactionVoutMapping: ModelMapping<TransactionVout> = {
  type: 'transaction_vout',
  index: {
    txid_n: {
      name: 'transaction_vout_txid_n',
Severity: Major
Found in apps/whale-api/src/module.model/transaction.vout.ts and 12 other locations - About 1 hr to fix
apps/whale-api/src/module.model/oracle.history.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.active.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.aggregated.interval.ts on lines 12..27
apps/whale-api/src/module.model/oracle.price.aggregated.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.feed.ts on lines 5..20
apps/whale-api/src/module.model/oracle.token.currency.ts on lines 5..20
apps/whale-api/src/module.model/pool.swap.aggregated.ts on lines 5..20
apps/whale-api/src/module.model/pool.swap.ts on lines 5..20
apps/whale-api/src/module.model/script.activity.ts on lines 5..20
apps/whale-api/src/module.model/script.unspent.ts on lines 5..20
apps/whale-api/src/module.model/transaction.vin.ts on lines 5..20
apps/whale-api/src/module.model/vault.auction.batch.history.ts on lines 5..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 102.

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

const TransactionVinMapping: ModelMapping<TransactionVin> = {
  type: 'transaction_vin',
  index: {
    txid_id: {
      name: 'transaction_vin_txid_id',
Severity: Major
Found in apps/whale-api/src/module.model/transaction.vin.ts and 12 other locations - About 1 hr to fix
apps/whale-api/src/module.model/oracle.history.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.active.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.aggregated.interval.ts on lines 12..27
apps/whale-api/src/module.model/oracle.price.aggregated.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.feed.ts on lines 5..20
apps/whale-api/src/module.model/oracle.token.currency.ts on lines 5..20
apps/whale-api/src/module.model/pool.swap.aggregated.ts on lines 5..20
apps/whale-api/src/module.model/pool.swap.ts on lines 5..20
apps/whale-api/src/module.model/script.activity.ts on lines 5..20
apps/whale-api/src/module.model/script.unspent.ts on lines 5..20
apps/whale-api/src/module.model/transaction.vout.ts on lines 6..21
apps/whale-api/src/module.model/vault.auction.batch.history.ts on lines 5..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 102.

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

const PoolSwapMapping: ModelMapping<PoolSwap> = {
  type: 'pool_swap',
  index: {
    key_sort: {
      name: 'pool_swap_sort',
Severity: Major
Found in apps/whale-api/src/module.model/pool.swap.ts and 12 other locations - About 1 hr to fix
apps/whale-api/src/module.model/oracle.history.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.active.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.aggregated.interval.ts on lines 12..27
apps/whale-api/src/module.model/oracle.price.aggregated.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.feed.ts on lines 5..20
apps/whale-api/src/module.model/oracle.token.currency.ts on lines 5..20
apps/whale-api/src/module.model/pool.swap.aggregated.ts on lines 5..20
apps/whale-api/src/module.model/script.activity.ts on lines 5..20
apps/whale-api/src/module.model/script.unspent.ts on lines 5..20
apps/whale-api/src/module.model/transaction.vin.ts on lines 5..20
apps/whale-api/src/module.model/transaction.vout.ts on lines 6..21
apps/whale-api/src/module.model/vault.auction.batch.history.ts on lines 5..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 102.

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

const OraclePriceAggregatedMapping: ModelMapping<OraclePriceAggregated> = {
  type: 'oracle_price_aggregated',
  index: {
    key_sort: {
      name: 'oracle_price_aggregated_key_sort',
apps/whale-api/src/module.model/oracle.history.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.active.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.aggregated.interval.ts on lines 12..27
apps/whale-api/src/module.model/oracle.price.feed.ts on lines 5..20
apps/whale-api/src/module.model/oracle.token.currency.ts on lines 5..20
apps/whale-api/src/module.model/pool.swap.aggregated.ts on lines 5..20
apps/whale-api/src/module.model/pool.swap.ts on lines 5..20
apps/whale-api/src/module.model/script.activity.ts on lines 5..20
apps/whale-api/src/module.model/script.unspent.ts on lines 5..20
apps/whale-api/src/module.model/transaction.vin.ts on lines 5..20
apps/whale-api/src/module.model/transaction.vout.ts on lines 6..21
apps/whale-api/src/module.model/vault.auction.batch.history.ts on lines 5..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 102.

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

const VaultAuctionHistoryMapping: ModelMapping<VaultAuctionBatchHistory> = {
  type: 'vault_auction_history',
  index: {
    vault_auction_history_key_sort: {
      name: 'vault_auction_history_key_sort',
apps/whale-api/src/module.model/oracle.history.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.active.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.aggregated.interval.ts on lines 12..27
apps/whale-api/src/module.model/oracle.price.aggregated.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.feed.ts on lines 5..20
apps/whale-api/src/module.model/oracle.token.currency.ts on lines 5..20
apps/whale-api/src/module.model/pool.swap.aggregated.ts on lines 5..20
apps/whale-api/src/module.model/pool.swap.ts on lines 5..20
apps/whale-api/src/module.model/script.activity.ts on lines 5..20
apps/whale-api/src/module.model/script.unspent.ts on lines 5..20
apps/whale-api/src/module.model/transaction.vin.ts on lines 5..20
apps/whale-api/src/module.model/transaction.vout.ts on lines 6..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 102.

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

const ScriptActivityMapping: ModelMapping<ScriptActivity> = {
  type: 'script_activity',
  index: {
    hid_id: {
      name: 'script_activity_hid_id',
Severity: Major
Found in apps/whale-api/src/module.model/script.activity.ts and 12 other locations - About 1 hr to fix
apps/whale-api/src/module.model/oracle.history.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.active.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.aggregated.interval.ts on lines 12..27
apps/whale-api/src/module.model/oracle.price.aggregated.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.feed.ts on lines 5..20
apps/whale-api/src/module.model/oracle.token.currency.ts on lines 5..20
apps/whale-api/src/module.model/pool.swap.aggregated.ts on lines 5..20
apps/whale-api/src/module.model/pool.swap.ts on lines 5..20
apps/whale-api/src/module.model/script.unspent.ts on lines 5..20
apps/whale-api/src/module.model/transaction.vin.ts on lines 5..20
apps/whale-api/src/module.model/transaction.vout.ts on lines 6..21
apps/whale-api/src/module.model/vault.auction.batch.history.ts on lines 5..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 102.

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

const OracleHistoryMapping: ModelMapping<OracleHistory> = {
  type: 'oracle_history',
  index: {
    oracle_id_sort: {
      name: 'oracle_history_oracle_id_sort',
Severity: Major
Found in apps/whale-api/src/module.model/oracle.history.ts and 12 other locations - About 1 hr to fix
apps/whale-api/src/module.model/oracle.price.active.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.aggregated.interval.ts on lines 12..27
apps/whale-api/src/module.model/oracle.price.aggregated.ts on lines 5..20
apps/whale-api/src/module.model/oracle.price.feed.ts on lines 5..20
apps/whale-api/src/module.model/oracle.token.currency.ts on lines 5..20
apps/whale-api/src/module.model/pool.swap.aggregated.ts on lines 5..20
apps/whale-api/src/module.model/pool.swap.ts on lines 5..20
apps/whale-api/src/module.model/script.activity.ts on lines 5..20
apps/whale-api/src/module.model/script.unspent.ts on lines 5..20
apps/whale-api/src/module.model/transaction.vin.ts on lines 5..20
apps/whale-api/src/module.model/transaction.vout.ts on lines 6..21
apps/whale-api/src/module.model/vault.auction.batch.history.ts on lines 5..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 102.

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

  async accountToUtxos (accountToUtxos: AccountToUtxos, destinationScript: Script): Promise<TransactionSegWit> {
    if (accountToUtxos.balances.length !== 1) {
      throw new TxnBuilderError(TxnBuilderErrorType.INVALID_ACCOUNT_TO_UTXOS_INPUT,
        'Conversion output `accountToUtxos.balances` array length must be one'
      )

    Function listYieldFarming has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      @Get('listyieldfarming')
      async listYieldFarming (
        @Query('network', NetworkValidationPipe) network: SupportedNetwork = 'mainnet'
      ): Promise<LegacyListYieldFarmingData> {
        const api = this.whaleApiClientProvider.getClient(network)
    Severity: Minor
    Found in apps/legacy-api/src/controllers/PoolPairController.ts - About 1 hr to fix

      Function fromAddress has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function fromAddress (address: string, network: NetworkName): DecodedAddress | undefined {
        try {
          const decodedBech32 = fromBech32(address)
      
          const p2wpkh = fromBech32P2WPKH(decodedBech32, network)
      Severity: Minor
      Found in packages/jellyfish-address/src/script/index.ts - About 1 hr to fix

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

          async getFeed (token: string, currency: string, size: number = 30, next?: string): Promise<ApiPagedResponse<PriceFeed>> {
            const key = `${token}-${currency}`
            return await this.client.requestList('GET', `prices/${key}/feed`, size, next)
          }
        Severity: Major
        Found in packages/whale-api-client/src/api/prices.ts and 1 other location - About 1 hr to fix
        packages/whale-api-client/src/api/prices.ts on lines 77..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 101.

        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

          async getOracles (token: string, currency: string, size: number = 30, next?: string): Promise<ApiPagedResponse<PriceOracle>> {
            const key = `${token}-${currency}`
            return await this.client.requestList('GET', `prices/${key}/oracles`, size, next)
          }
        Severity: Major
        Found in packages/whale-api-client/src/api/prices.ts and 1 other location - About 1 hr to fix
        packages/whale-api-client/src/api/prices.ts on lines 58..61

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

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

          async index (block: RawBlock): Promise<void> {
            for (const txn of block.tx) {
              const isEvmTx = checkIfEvmTx(txn)
        
              for (const vin of txn.vin) {
        Severity: Minor
        Found in apps/whale-api/src/module.indexer/model/transaction.vin.ts - About 1 hr 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

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

          composers (umn: UpdateMasternodeData): BufferComposer[] {
            return [
              ComposableBuffer.uInt8(() => umn.updateType, v => umn.updateType = v),
              ComposableBuffer.single<UpdateMasternodeAddress>(() => umn.address, v => umn.address = v, v => new CUpdateMasternodeAddress(v))
            ]
        packages/jellyfish-transaction/src/tx_composer.ts on lines 117..122

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

        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 (vout: Vout): BufferComposer[] {
            return [
              ComposableBuffer.satoshiAsBigNumber(() => vout.value, v => vout.value = v),
              ComposableBuffer.single<Script>(() => vout.script, v => vout.script = v, v => new CScript(v))
            ]
        Severity: Major
        Found in packages/jellyfish-transaction/src/tx_composer.ts and 1 other location - About 1 hr to fix
        packages/jellyfish-transaction/src/script/dftx/dftx_masternode.ts on lines 91..96

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

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

          async index (block: RawBlock): Promise<void> {
            const records: Record<string, ScriptAggregation> = {}
        
            function findScriptAggregation (hex: string, type: string): ScriptAggregation {
              const hid = HexEncoder.asSHA256(hex)
        Severity: Minor
        Found in apps/whale-api/src/module.indexer/model/script.aggregation.ts - About 1 hr to fix

          Function after has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async after (): Promise<void> {
              await this.generate(1)
          
              // separate the dfip2203 setgov as
              // set dfip2203 in the list above will throw
          Severity: Minor
          Found in apps/playground-api/src/setups/setup.gov.ts - About 1 hr to fix

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

              private async cachedGet<T> (field: string, fetch: () => Promise<T>, ttl: number): Promise<T> {
                const object = await this.cache.get(`OracleStatusController.${field}`, fetch, { ttl })
                return requireValue(object, field)
              }
            Severity: Major
            Found in apps/status-api/src/controllers/OracleStatusController.ts and 1 other location - About 1 hr to fix
            apps/whale-api/src/module.api/stats.controller.ts on lines 140..143

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

            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