livepeer/livepeerjs

View on GitHub
packages/explorer-2.0/apollo/resolvers/Mutation.tsx

Summary

Maintainability
F
5 days
Test Coverage

File Mutation.tsx has 361 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { EarningsTree } from "../../lib/earningsTree";
import { utils } from "ethers";
let earningsSnapshot;

if (process.env.NEXT_PUBLIC_NETWORK === "mainnet") {
Severity: Minor
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx - About 4 hrs to fix

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

export async function bond(_obj, _args, _ctx) {
  const {
    amount,
    to,
    oldDelegateNewPosPrev,
Severity: Minor
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx - About 1 hr to fix

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

export async function approve(_obj, _args, _ctx) {
  const { type, amount } = _args;
  let gas;
  let txHash;

Severity: Minor
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx - About 1 hr to fix

Function encodeClaimSnapshotAndStakingAction has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function encodeClaimSnapshotAndStakingAction(_args, stakingAction, _ctx) {
  const { lastClaimRound, delegator } = _args;
  if (!lastClaimRound || lastClaimRound === 0) {
    return null;
  }
Severity: Minor
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx - About 1 hr to fix

Function rebondFromUnbonded has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function rebondFromUnbonded(_obj, _args, _ctx) {
  const { delegate, unbondingLockId, newPosPrev, newPosNext } = _args;

  let data = _ctx.livepeer.rpc.getCalldata(
    "BondingManager",
Severity: Minor
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx - About 1 hr to fix

Function rebond has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function rebond(_obj, _args, _ctx) {
  const { unbondingLockId, newPosPrev, newPosNext } = _args;

  let data = _ctx.livepeer.rpc.getCalldata("BondingManager", "rebondWithHint", [
    unbondingLockId,
Severity: Minor
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx - About 1 hr to fix

Function withdrawFees has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function withdrawFees(_obj, _args, _ctx) {
  let data = _ctx.livepeer.rpc.getCalldata(
    "BondingManager",
    "withdrawFees",
    []
Severity: Minor
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx - About 1 hr to fix

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

export async function unbond(_obj, _args, _ctx) {
  const { amount } = _args;

  let data = _ctx.livepeer.rpc.getCalldata("BondingManager", "unbond", [
    amount,
Severity: Minor
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx - About 1 hr to fix

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

    case "bond":
      gas = await _ctx.livepeer.rpc.estimateGas("LivepeerToken", "approve", [
        _ctx.livepeer.config.contracts.BondingManager.address,
        amount,
      ]);
Severity: Major
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx and 1 other location - About 3 hrs to fix
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 42..58

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

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

    case "createPoll":
      gas = await _ctx.livepeer.rpc.estimateGas("LivepeerToken", "approve", [
        _ctx.livepeer.config.contracts.PollCreator.address,
        amount,
      ]);
Severity: Major
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx and 1 other location - About 3 hrs to fix
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 26..41

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

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

  const txHash = await _ctx.livepeer.rpc.sendTransaction({
    ..._ctx.livepeer.config.defaultTx,
    to: _ctx.livepeer.config.contracts["BondingManager"].address,
    data,
    gas,
Severity: Major
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx and 4 other locations - About 2 hrs to fix
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 148..154
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 190..196
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 305..311
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 349..355

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

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

  const txHash = await _ctx.livepeer.rpc.sendTransaction({
    ..._ctx.livepeer.config.defaultTx,
    to: _ctx.livepeer.config.contracts["BondingManager"].address,
    data,
    gas,
Severity: Major
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx and 4 other locations - About 2 hrs to fix
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 190..196
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 234..240
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 305..311
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 349..355

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

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

  const txHash = await _ctx.livepeer.rpc.sendTransaction({
    ..._ctx.livepeer.config.defaultTx,
    to: _ctx.livepeer.config.contracts["BondingManager"].address,
    data,
    gas,
Severity: Major
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx and 4 other locations - About 2 hrs to fix
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 148..154
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 190..196
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 234..240
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 305..311

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

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

  const txHash = await _ctx.livepeer.rpc.sendTransaction({
    ..._ctx.livepeer.config.defaultTx,
    to: _ctx.livepeer.config.contracts["BondingManager"].address,
    data,
    gas,
Severity: Major
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx and 4 other locations - About 2 hrs to fix
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 148..154
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 190..196
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 234..240
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 349..355

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

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

  const txHash = await _ctx.livepeer.rpc.sendTransaction({
    ..._ctx.livepeer.config.defaultTx,
    to: _ctx.livepeer.config.contracts["BondingManager"].address,
    data,
    gas,
Severity: Major
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx and 4 other locations - About 2 hrs to fix
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 148..154
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 234..240
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 305..311
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 349..355

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

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

  const gas = await _ctx.livepeer.rpc.estimateGasRaw({
    ..._ctx.livepeer.config.defaultTx,
    to: _ctx.livepeer.config.contracts["BondingManager"].address,
    data,
  });
Severity: Major
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx and 4 other locations - About 1 hr to fix
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 184..188
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 228..232
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 299..303
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 343..347

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

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

  const gas = await _ctx.livepeer.rpc.estimateGasRaw({
    ..._ctx.livepeer.config.defaultTx,
    to: _ctx.livepeer.config.contracts["BondingManager"].address,
    data,
  });
Severity: Major
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx and 4 other locations - About 1 hr to fix
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 142..146
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 184..188
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 299..303
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 343..347

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

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

  const gas = await _ctx.livepeer.rpc.estimateGasRaw({
    ..._ctx.livepeer.config.defaultTx,
    to: _ctx.livepeer.config.contracts["BondingManager"].address,
    data,
  });
Severity: Major
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx and 4 other locations - About 1 hr to fix
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 142..146
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 228..232
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 299..303
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 343..347

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

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

  const gas = await _ctx.livepeer.rpc.estimateGasRaw({
    ..._ctx.livepeer.config.defaultTx,
    to: _ctx.livepeer.config.contracts["BondingManager"].address,
    data,
  });
Severity: Major
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx and 4 other locations - About 1 hr to fix
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 142..146
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 184..188
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 228..232
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 343..347

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

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

  const gas = await _ctx.livepeer.rpc.estimateGasRaw({
    ..._ctx.livepeer.config.defaultTx,
    to: _ctx.livepeer.config.contracts["BondingManager"].address,
    data,
  });
Severity: Major
Found in packages/explorer-2.0/apollo/resolvers/Mutation.tsx and 4 other locations - About 1 hr to fix
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 142..146
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 184..188
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 228..232
packages/explorer-2.0/apollo/resolvers/Mutation.tsx on lines 299..303

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

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

There are no issues that match your filters.

Category
Status