DeFiCh/jellyfish

View on GitHub

Showing 358 of 388 total issues

Function maxPriceAsBigNumber has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  static maxPriceAsBigNumber (getter: () => BigNumber, setter: (data: BigNumber) => void): BufferComposer {
    return {
      fromBuffer: (buffer: SmartBuffer): void => {
        const integer = readBigNumberUInt64(buffer)
        const fraction = readBigNumberUInt64(buffer)
Severity: Minor
Found in packages/jellyfish-buffer/src/Composer.ts - About 1 hr to fix

    Function pushToAssetBreakdownInfo has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private pushToAssetBreakdownInfo (assetBreakdownInfo: AssetBreakdownInfo[], memberId: string, memberDetail: MemberDetail, tokenId: string, tokens: TokenInfoWithId[]): void {
        const backingAddresses: string[] = memberDetail.backingId.length > 0 ? memberDetail.backingId.split(',').map(a => a.trim()) : []
    
        const member: MemberWithTokenInfo = {
          id: memberId,
    Severity: Minor
    Found in apps/whale-api/src/module.api/consortium.service.ts - About 1 hr to fix

      Function readiness has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async readiness (): Promise<HealthIndicatorResult> {
          let highest: Block
          let index: number | undefined
          let defid: number | undefined
      
      
      Severity: Minor
      Found in apps/whale-api/src/module.model/_model.probes.ts - About 1 hr to fix

        Function findSwap has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private async findSwap (network: NetworkName, poolSwap: PoolSwap, transaction: Transaction): Promise<LegacySubgraphSwap | undefined> {
            const fromAddress = fromScript(poolSwap.fromScript, network)?.address
            const toAddress = fromScript(poolSwap.toScript, network)?.address
        
            if (
        Severity: Minor
        Found in apps/whale-api/src/module.api/legacy.subgraph.service.ts - About 1 hr to fix

          Function from has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function from<T extends Address> (net: NetworkName, address: string): T {
            const network = getNetwork(net)
            const possible: Map<AddressTypeDeprecated, Address> = new Map()
            possible.set('Unknown', new UnknownTypeAddress(network, address))
            possible.set('P2PKH', Base58Address.fromAddress<P2PKH>(network, address, P2PKH))
          Severity: Minor
          Found in packages/jellyfish-address/src/index.ts - About 1 hr to fix

            Function getUSDVolume has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              public async getUSDVolume (id: string): Promise<PoolPairData['volume'] | undefined> {
                return await this.cache.get<PoolPairData['volume']>(`POOLPAIR_VOLUME_${id}`, async () => {
                  const gatherAmount = async (interval: PoolSwapAggregatedInterval, count: number): Promise<number> => {
                    const aggregated: Record<string, number> = {}
                    const swaps = await this.poolSwapAggregatedMapper.query(`${id}-${interval as number}`, count)
            Severity: Minor
            Found in apps/whale-api/src/module.api/poolpair.service.ts - About 1 hr to fix

              Function indexSwap has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async indexSwap (block: RawBlock, transaction: DfTxTransaction<any>, poolPairId: string, fromTokenId: number, fromAmount: BigNumber): Promise<void> {
                  await this.poolSwapMapper.put({
                    id: `${poolPairId}-${transaction.txn.txid}`,
                    txid: transaction.txn.txid,
                    txno: transaction.txnNo,
              Severity: Minor
              Found in apps/whale-api/src/module.indexer/model/dftx/pool.swap.ts - About 1 hr to fix

                Function getUSD_PER_DFI has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async getUSD_PER_DFI (): Promise<BigNumber | undefined> {
                    return await this.cache.get<BigNumber>('USD_PER_DFI', async () => {
                      const usdt = await this.getPoolPair('DFI', 'USDT')
                      const usdc = await this.getPoolPair('DFI', 'USDC')
                      // const dusd = await this.getPoolPair('DFI', 'DUSD')
                Severity: Minor
                Found in apps/whale-api/src/module.api/poolpair.service.ts - About 1 hr to fix

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

                    async invalidate (block: RawBlock): Promise<void> {
                      for (const txn of block.tx) {
                        for (const vout of txn.vout) {
                          await this.mapper.delete(this.mapId(txn, vout))
                        }
                  apps/whale-api/src/module.indexer/model/transaction.vin.ts on lines 41..47
                  apps/whale-api/src/module.indexer/model/transaction.vout.ts on lines 12..18

                  Duplicated Code

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

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

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

                  Tuning

                  This issue has a mass of 85.

                  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

                    async index (block: RawBlock): Promise<void> {
                      for (const txn of block.tx) {
                        for (const vout of txn.vout) {
                          await this.mapper.put(this.map(txn, vout))
                        }
                  apps/whale-api/src/module.indexer/model/transaction.vin.ts on lines 41..47
                  apps/whale-api/src/module.indexer/model/transaction.vout.ts on lines 20..26

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

                  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 class CSetDefaultLoanScheme extends ComposableBuffer<SetDefaultLoanScheme> {
                    static OP_CODE = 0x64 // 'd'
                    static OP_NAME = 'OP_DEFI_TX_SET_DEFAULT_LOAN_SCHEME'
                  
                    composers (sdls: SetDefaultLoanScheme): BufferComposer[] {
                  packages/jellyfish-transaction/src/script/dftx/dftx_evmtx.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 85.

                  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 class CEvmTx extends ComposableBuffer<EvmTx> {
                    static OP_CODE = 0x39 // '9'
                    static OP_NAME = 'OP_DEFI_TX_EVM_TX'
                  
                    composers (e: EvmTx): BufferComposer[] {
                  packages/jellyfish-transaction/src/script/dftx/dftx_loans.ts on lines 71..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 85.

                  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

                    async invalidate (block: RawBlock): Promise<void> {
                      for (const txn of block.tx) {
                        for (const vin of txn.vin) {
                          await this.vinMapper.delete(this.mapId(txn, vin))
                        }
                  Severity: Major
                  Found in apps/whale-api/src/module.indexer/model/transaction.vin.ts and 2 other locations - About 1 hr to fix
                  apps/whale-api/src/module.indexer/model/transaction.vout.ts on lines 12..18
                  apps/whale-api/src/module.indexer/model/transaction.vout.ts on lines 20..26

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

                  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

                    async placeAuctionBid (placeAuctionBid: PlaceAuctionBid, utxos: UTXO[] = []): Promise<string> {
                      return await this.client.call(
                        'placeauctionbid',
                        [placeAuctionBid.vaultId, placeAuctionBid.index, placeAuctionBid.from, placeAuctionBid.amount, utxos],
                        'number'
                  Severity: Major
                  Found in packages/jellyfish-api-core/src/category/vault.ts and 2 other locations - About 55 mins to fix
                  packages/jellyfish-api-core/src/category/loan.ts on lines 64..66
                  packages/jellyfish-api-core/src/category/loan.ts on lines 433..439

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

                  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

                    async placeAuctionBid (placeAuctionBid: PlaceAuctionBid, utxos: UTXO[] = []): Promise<string> {
                      return await this.client.call(
                        'placeauctionbid',
                        [placeAuctionBid.vaultId, placeAuctionBid.index, placeAuctionBid.from, placeAuctionBid.amount, utxos],
                        'number'
                  Severity: Major
                  Found in packages/jellyfish-api-core/src/category/loan.ts and 2 other locations - About 55 mins to fix
                  packages/jellyfish-api-core/src/category/loan.ts on lines 64..66
                  packages/jellyfish-api-core/src/category/vault.ts on lines 154..160

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

                  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

                    async updateLoanScheme (scheme: UpdateLoanScheme, utxos: UTXO[] = []): Promise<string> {
                      return await this.client.call('updateloanscheme', [scheme.minColRatio, scheme.interestRate, scheme.id, scheme.activateAfterBlock, utxos], 'number')
                    }
                  Severity: Major
                  Found in packages/jellyfish-api-core/src/category/loan.ts and 2 other locations - About 55 mins to fix
                  packages/jellyfish-api-core/src/category/loan.ts on lines 433..439
                  packages/jellyfish-api-core/src/category/vault.ts on lines 154..160

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

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

                    static maxPriceAsBigNumber (getter: () => BigNumber, setter: (data: BigNumber) => void): BufferComposer {
                      return {
                        fromBuffer: (buffer: SmartBuffer): void => {
                          const integer = readBigNumberUInt64(buffer)
                          const fraction = readBigNumberUInt64(buffer)
                  Severity: Minor
                  Found in packages/jellyfish-buffer/src/Composer.ts - About 55 mins 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 addTokensAndConnectionsToGraph has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    private async addTokensAndConnectionsToGraph (poolPairList: PoolPairInfoWithId[]): Promise<void> {
                      for (const poolPair of poolPairList) {
                        if (await this.isPoolPairIgnored(poolPair)) {
                          continue
                        }
                  Severity: Minor
                  Found in apps/whale-api/src/module.api/poolswap.pathfinding.service.ts - About 55 mins 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 computePathsBetweenTokens has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    private async computePathsBetweenTokens (
                      fromTokenId: string,
                      toTokenId: string
                    ): Promise<SwapPathPoolPair[][]> {
                      const poolPairPaths: SwapPathPoolPair[][] = []
                  Severity: Minor
                  Found in apps/whale-api/src/module.api/poolswap.pathfinding.service.ts - About 55 mins 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 index has a Cognitive Complexity of 9 (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/script.unspent.ts - About 55 mins 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