DeFiCh/jellyfish

View on GitHub

Showing 358 of 388 total issues

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

  async query (key: string, limit: number, lt?: string, gt?: string): Promise<PoolSwap[]> {
    return await this.database.query(PoolSwapMapping.index.key_sort, {
      partitionKey: key,
      limit: limit,
      order: SortOrder.DESC,
Severity: Major
Found in apps/whale-api/src/module.model/pool.swap.ts and 1 other location - About 1 hr to fix
apps/whale-api/src/module.model/vault.auction.batch.history.ts on lines 36..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 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

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

  async query (key: string, limit: number, lt?: string, gt?: string): Promise<VaultAuctionBatchHistory[]> {
    return await this.database.query(VaultAuctionHistoryMapping.index.vault_auction_history_key_sort, {
      partitionKey: key,
      limit: limit,
      order: SortOrder.DESC,
apps/whale-api/src/module.model/pool.swap.ts on lines 27..35

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

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(`StatsController.${field}`, fetch, { ttl })
    return requireValue(object, field)
  }
Severity: Major
Found in apps/whale-api/src/module.api/stats.controller.ts and 1 other location - About 1 hr to fix
apps/status-api/src/controllers/OracleStatusController.ts on lines 85..88

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

Function run has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  @Interval(6000)
  async run (): Promise<void> {
    if (this.vaultId === undefined) {
      this.vaultId = await this.client.loan.createVault({
        loanSchemeId: 'MIN150',
Severity: Minor
Found in apps/playground-api/src/bots/VaultBot.ts - About 1 hr to fix

    Function shouldQueryPartitionSortPagination has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export async function shouldQueryPartitionSortPagination (database: Database): Promise<void> {
      const window43 = await database.query(PartitionSortMapping.index.composite_a, {
        partitionKey: '1000',
        limit: 2,
        order: SortOrder.DESC
    Severity: Minor
    Found in apps/whale-api/src/module.database/database.spec/specifications.ts - About 1 hr to fix

      Function listAccountHistory has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        @Get('/history')
        async listAccountHistory (
          @Param('address') address: string,
            @Query() query: PaginationQuery): Promise<ApiPagedResponse<AddressHistory>> {
          if (address === 'mine') {
      Severity: Minor
      Found in apps/whale-api/src/module.api/address.controller.ts - About 1 hr to fix

        Function mapPriceAggregated has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private async mapPriceAggregated (block: RawBlock, token: string, currency: string): Promise<OraclePriceAggregated | undefined> {
            const oracles = await this.tokenCurrencyMapper.query(`${token}-${currency}`, Number.MAX_SAFE_INTEGER)
        
            const aggregated = {
              total: new BigNumber(0),
        Severity: Minor
        Found in apps/whale-api/src/module.indexer/model/dftx/set.oracle.data.ts - About 1 hr to fix

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

            tokenB: {
              id: string
              name: string
              symbol: string
              displaySymbol: string
          Severity: Major
          Found in packages/whale-api-client/src/api/poolpairs.ts and 1 other location - About 1 hr to fix
          packages/whale-api-client/src/api/poolpairs.ts on lines 113..125

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

          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

            tokenA: {
              id: string
              name: string
              symbol: string
              displaySymbol: string
          Severity: Major
          Found in packages/whale-api-client/src/api/poolpairs.ts and 1 other location - About 1 hr to fix
          packages/whale-api-client/src/api/poolpairs.ts on lines 126..138

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

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

            async put<M extends Model> (mapping: ModelMapping<M>, model: M): Promise<void> {
              const indexes = Object.values(mapping.index)
              const persisted = await this.get(mapping, model.id) as M
          
              if (persisted !== undefined) {
          Severity: Minor
          Found in apps/whale-api/src/module.database/provider.level/level.database.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

          Function getStats has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async getStats (jsonPath?: string): Promise<LegacyStats | any> {
              const stats: StatsData = await this.api.stats.get()
          
              // Fire async requests at the same time and await results
              const [
          Severity: Minor
          Found in apps/legacy-api/src/controllers/stats/LegacyStatsProvider.ts - About 1 hr to fix

            Function shouldQueryWithAscDesc has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export async function shouldQueryWithAscDesc (database: Database): Promise<void> {
              const partitionADesc = await database.query(PartitionMapping.index.partition_a, {
                limit: 100,
                order: SortOrder.DESC
              })
            Severity: Minor
            Found in apps/whale-api/src/module.database/database.spec/specifications.ts - About 1 hr to fix

              Function fromScript has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function fromScript (script: Script, network: NetworkName): DecodedAddress | undefined {
                const p2wpkh = fromScriptP2WPKH(script, network)
                if (p2wpkh !== undefined) {
                  return {
                    type: AddressType.P2WPKH,
              Severity: Minor
              Found in packages/jellyfish-address/src/script/index.ts - About 1 hr to fix

                Function getBestPath has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async getBestPath (fromTokenId: string, toTokenId: string): Promise<BestSwapPathResult> {
                    const {
                      fromToken,
                      toToken,
                      paths
                Severity: Minor
                Found in apps/whale-api/src/module.api/poolswap.pathfinding.service.ts - About 1 hr to fix

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

                    async createVault (createVault: CreateVault, changeScript: Script): Promise<TransactionSegWit> {
                      const creationFee = this.network.name === 'mainnet' ? new BigNumber('2') : new BigNumber('1')
                  
                      return await super.createDeFiTx(
                        OP_CODES.OP_DEFI_TX_CREATE_VAULT(createVault),
                  packages/jellyfish-transaction-builder/src/txn/txn_builder_loans.ts on lines 115..123

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

                  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 createVault (createVault: CreateVault, changeScript: Script): Promise<TransactionSegWit> {
                      const creationFee = this.network.name === 'mainnet' ? new BigNumber('2') : new BigNumber('1')
                  
                      return await super.createDeFiTx(
                        OP_CODES.OP_DEFI_TX_CREATE_VAULT(createVault),
                  packages/jellyfish-transaction-builder/src/txn/txn_builder_vault.ts on lines 21..29

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

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

                    protected getCmd (opts: StartOptions): string[] {
                      const cmds = [...super.getCmd(opts),
                        '-regtest=1',
                        '-jellyfish_regtest=1',
                        '-txnotokens=0',
                  Severity: Minor
                  Found in packages/testcontainers/src/containers/RegTestContainer/index.ts - About 1 hr to fix

                    Function parse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                      async parse (txn: defid.Transaction): Promise<string[]> {
                        const result: string[] = []
                    
                        for (const vin of txn.vin) {
                          result.push(...(await this.utxo.extractFromVin(vin)))
                    Severity: Minor
                    Found in packages/rich-list-core/src/saga/AddressParser/index.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

                    Function getDfTxTransactions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                      private getDfTxTransactions (block: RawBlock): Array<DfTxTransaction<any>> {
                        const transactions: Array<DfTxTransaction<any>> = []
                    
                        for (let i = 0; i < block.tx.length; i++) {
                          const txn = block.tx[i]
                    Severity: Minor
                    Found in apps/whale-api/src/module.indexer/model/dftx.indexer.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

                    Function invalidate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                      async invalidate (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/script.activity.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

                    Severity
                    Category
                    Status
                    Source
                    Language