livepeer/livepeerjs

View on GitHub
packages/subgraph/src/mappings/bondingManager_deprecated.ts

Summary

Maintainability
C
1 day
Test Coverage

File bondingManager_deprecated.ts has 312 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Address, BigInt } from "@graphprotocol/graph-ts";

// Import event types from the registrar contract ABIs
import {
  BondingManager,
Severity: Minor
Found in packages/subgraph/src/mappings/bondingManager_deprecated.ts - About 3 hrs to fix

Function bond has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function bond(call: BondCall): void {
  // After LIP11 was deployed (at block 6192000), we no longer have to rely on
  // this call handler to get the amount bonded.
  // https://forum.livepeer.org/t/tributary-release-protocol-upgrade/354
  if (call.block.number.le(BigInt.fromI32(6192000))) {
Severity: Major
Found in packages/subgraph/src/mappings/bondingManager_deprecated.ts - About 3 hrs to fix

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

export function unbond(event: Unbond): void {
  let bondingManager = BondingManager.bind(event.address);
  let delegator = Delegator.load(event.params.delegator.toHex());
  let transcoderAddress = delegator.delegate;
  let round = createOrLoadRound(event.block.number);
Severity: Minor
Found in packages/subgraph/src/mappings/bondingManager_deprecated.ts - About 1 hr to fix

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

export function claimEarnings(call: ClaimEarningsCall): void {
  // The Streamflow release introduced an event emitter for EarningsClaimed, so
  // we can ignore this call handler henceforth after the block in which the
  // protocol was paused prior to the streamflow upgrade
  if (call.block.number.le(BigInt.fromI32(9274414))) {
Severity: Minor
Found in packages/subgraph/src/mappings/bondingManager_deprecated.ts - About 1 hr to fix

Function bond has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export function bond(call: BondCall): void {
  // After LIP11 was deployed (at block 6192000), we no longer have to rely on
  // this call handler to get the amount bonded.
  // https://forum.livepeer.org/t/tributary-release-protocol-upgrade/354
  if (call.block.number.le(BigInt.fromI32(6192000))) {
Severity: Minor
Found in packages/subgraph/src/mappings/bondingManager_deprecated.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 transcoderUpdate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function transcoderUpdate(event: TranscoderUpdate): void {
  let round = createOrLoadRound(event.block.number);
  let transcoder = createOrLoadTranscoder(event.params.transcoder.toHex());

  // Update transcoder
Severity: Minor
Found in packages/subgraph/src/mappings/bondingManager_deprecated.ts - About 1 hr to fix

There are no issues that match your filters.

Category
Status