DeFiCh/jellyfish

View on GitHub

Showing 137 of 388 total issues

Function byteLength has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function byteLength (num: number): number {
  validateUInt53(num)
  return num < 0xfd ? 1 : num <= 0xffff ? 3 : num <= 0xffffffff ? 5 : 9
}
Severity: Minor
Found in packages/jellyfish-buffer/src/CompactSize.ts - About 25 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 readiness has a Cognitive Complexity of 6 (exceeds 5 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 25 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 writeVarInt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function writeVarInt (value: number, buffer: SmartBuffer): void {
  let n = new BN(value)
  validateMaxSafeInteger(n)

  const tmp = []
Severity: Minor
Found in packages/jellyfish-buffer/src/VarInt.ts - About 25 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 getGovernanceProposal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  async getGovernanceProposal (id: string): Promise<GovernanceProposal> {
    try {
      const proposal = await this.client.governance.getGovProposal(id)
      return this.mapGovernanceProposal(proposal)
    } catch (err) {
Severity: Minor
Found in apps/whale-api/src/module.api/governance.service.ts - About 25 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 calculateNext has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  async calculateNext (queuedAddressLimit = 5000): Promise<void> {
    const tokens = await this.listTokenIds()
    let updatedBalances = await this.getActiveAddressBalances(tokens, queuedAddressLimit)

    while (Object.keys(updatedBalances).length > 0) {
Severity: Minor
Found in packages/rich-list-core/src/RichListCore.ts - About 25 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 test has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  @Post('/test')
  @HttpCode(200)
  async test (@Body(ValidationPipe) tx: RawTxDto): Promise<void> {
    const maxFeeRate = this.getMaxFeeRate(tx)
    try {
Severity: Minor
Found in apps/whale-api/src/module.api/rawtx.controller.ts - About 25 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 fromAddress has a Cognitive Complexity of 6 (exceeds 5 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 25 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 invalidateTransaction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  async invalidateTransaction (block: RawBlock, transaction: DfTxTransaction<SetOracleData>): Promise<void> {
    const feeds = mapPriceFeeds(block, [transaction])
    const pairs = new Set<[string, string]>()

    for (const feed of feeds) {
Severity: Minor
Found in apps/whale-api/src/module.indexer/model/dftx/set.oracle.data.interval.ts - About 25 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 listAuction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  async listAuction (query: PaginationQuery): Promise<ApiPagedResponse<LoanVaultLiquidated>> {
    const next = query.next !== undefined ? String(query.next) : undefined
    const size = query.size > 30 ? 30 : query.size
    let pagination: AuctionPagination

Severity: Minor
Found in apps/whale-api/src/module.api/loan.vault.service.ts - About 25 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 closeAllOpenOffers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  async closeAllOpenOffers (): Promise<void> {
    const orders = await this.testing.rpc.icxorderbook.listOrders()
    for (const orderTx of Object.keys(orders).splice(1)) {
      const offers = await this.testing.rpc.icxorderbook.listOrders({ orderTx: orderTx })
      for (const offerTx of Object.keys(offers).splice(1)) {
Severity: Minor
Found in packages/jellyfish-testing/src/icxorderbook.ts - About 25 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 optionalHex has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  static optionalHex (length: number, getter: () => string | undefined, setter: (data: string | undefined) => void): BufferComposer {
    return {
      fromBuffer: (buffer: SmartBuffer): void => {
        const buff = Buffer.from(buffer.readBuffer(length))
        if (buff.length > 0) {
Severity: Minor
Found in packages/jellyfish-buffer/src/Composer.ts - About 25 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 getUpdates has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  private getUpdates (transaction: DfTxTransaction<UpdateMasternode>): { owner?: string, operator?: string } {
    const updates: { owner?: string, operator?: string } = {}

    for (const update of transaction.dftx.data.updates) {
      if (update.address !== undefined && update.updateType === 0x01) {
Severity: Minor
Found in apps/whale-api/src/module.indexer/model/dftx/update.masternode.ts - About 25 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 generate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  async generate (nblocks: number, address?: string | undefined, maxTries: number = 1000000): Promise<void> {
    if (address == null && this.sncc instanceof StartedNativeChainContainer) {
      address = this.sncc.masterNodeKey?.operator.address
    }
    if (address == null && this.sncc instanceof MasterNodeRegTestContainer) {
Severity: Minor
Found in packages/testcontainers/src/containers/NativeChainRpc.ts - About 25 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 asPrivKey has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

async function asPrivKey (data: string[] | string | EllipticPair | EllipticPair[]): Promise<string[]> {
  if (typeof data === 'string') {
    return [data]
  }
  if ((data as EllipticPair).privateKey !== undefined) {
Severity: Minor
Found in packages/jellyfish-testing/src/rawtx.ts - About 25 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 fromHash160 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function fromHash160 (data: string | Buffer, prefix: number): string {
  if (typeof data === 'string') {
    // 40 hex char string only
    if (data.length !== 40) {
      throw new Error('InvalidDataLength')
Severity: Minor
Found in packages/jellyfish-crypto/src/bs58.ts - About 25 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 toObject has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  toObject (): any {
    function toObject (value: any): any {
      if (value instanceof ComposableBuffer) {
        return value.toObject()
      }
Severity: Minor
Found in packages/jellyfish-buffer/src/Composer.ts - About 25 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 synchronize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  private async synchronize (): Promise<boolean> {
    const indexed = await this.blockMapper.getHighest()
    if (indexed === undefined) {
      return await this.indexGenesis()
    }
Severity: Minor
Found in apps/whale-api/src/module.indexer/rpc.block.provider.ts - About 25 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