livepeer/livepeerjs

View on GitHub

Showing 398 of 407 total issues

Function createLivepeerSDK has 791 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function createLivepeerSDK(
  opts: LivepeerSDKOptions
): Promise<LivepeerSDK> {
  const { ens, events, ...config } = await initContracts(opts);
  const {
Severity: Major
Found in packages/sdk/src/index.js - About 3 days to fix

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

export function reserveFunded(event: ReserveFunded): void {
  let round = createOrLoadRound(event.block.number);
  let broadcaster = Broadcaster.load(event.params.reserveHolder.toHex());

  if (broadcaster == null) {
Severity: Major
Found in packages/subgraph/src/mappings/ticketBroker.ts and 1 other location - About 3 days to fix
packages/subgraph/src/mappings/ticketBroker.ts on lines 130..165

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

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 function depositFunded(event: DepositFunded): void {
  let round = createOrLoadRound(event.block.number);
  let broadcaster = Broadcaster.load(event.params.sender.toHex());

  if (broadcaster == null) {
Severity: Major
Found in packages/subgraph/src/mappings/ticketBroker.ts and 1 other location - About 3 days to fix
packages/subgraph/src/mappings/ticketBroker.ts on lines 167..202

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

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

File index.js has 1163 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Eth from "ethjs";
import SignerProvider from "ethjs-provider-signer";
import EthereumTx from "ethereumjs-tx";
import {
  decodeParams,
Severity: Major
Found in packages/sdk/src/index.js - About 2 days to fix

Function renderSwitch has 495 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function renderSwitch(event: any, i: number) {
  switch (event.__typename) {
    case "BondEvent":
      return (
        <ListItem
Severity: Major
Found in packages/explorer-2.0/components/HistoryView/index.tsx - About 2 days to fix

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

    case "RebondEvent":
      return (
        <ListItem
          css={{
            cursor: "pointer",
Severity: Major
Found in packages/explorer-2.0/components/HistoryView/index.tsx and 1 other location - About 2 days to fix
packages/explorer-2.0/components/HistoryView/index.tsx on lines 254..297

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

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 "UnbondEvent":
      return (
        <ListItem
          css={{
            cursor: "pointer",
Severity: Major
Found in packages/explorer-2.0/components/HistoryView/index.tsx and 1 other location - About 2 days to fix
packages/explorer-2.0/components/HistoryView/index.tsx on lines 210..253

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

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 function pause(event: Pause): void {
  let round = createOrLoadRound(event.block.number);
  let protocol = Protocol.load("0");
  protocol.paused = true;
  protocol.save();
Severity: Major
Found in packages/subgraph/src/mappings/controller.ts and 1 other location - About 2 days to fix
packages/subgraph/src/mappings/controller.ts on lines 36..60

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

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 function unpause(event: Unpause): void {
  let round = createOrLoadRound(event.block.number);
  let protocol = Protocol.load("0");
  protocol.paused = false;
  protocol.save();
Severity: Major
Found in packages/subgraph/src/mappings/controller.ts and 1 other location - About 2 days to fix
packages/subgraph/src/mappings/controller.ts on lines 10..34

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

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

    case "WithdrawStakeEvent":
      return (
        <ListItem
          css={{
            cursor: "pointer",
Severity: Major
Found in packages/explorer-2.0/components/HistoryView/index.tsx and 4 other locations - About 1 day to fix
packages/explorer-2.0/components/HistoryView/index.tsx on lines 298..340
packages/explorer-2.0/components/HistoryView/index.tsx on lines 435..477
packages/explorer-2.0/components/HistoryView/index.tsx on lines 478..520
packages/explorer-2.0/components/HistoryView/index.tsx on lines 521..563

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

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

    case "WinningTicketRedeemedEvent":
      return (
        <ListItem
          css={{
            cursor: "pointer",
Severity: Major
Found in packages/explorer-2.0/components/HistoryView/index.tsx and 4 other locations - About 1 day to fix
packages/explorer-2.0/components/HistoryView/index.tsx on lines 298..340
packages/explorer-2.0/components/HistoryView/index.tsx on lines 392..434
packages/explorer-2.0/components/HistoryView/index.tsx on lines 435..477
packages/explorer-2.0/components/HistoryView/index.tsx on lines 521..563

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

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

    case "RewardEvent":
      return (
        <ListItem
          css={{
            cursor: "pointer",
Severity: Major
Found in packages/explorer-2.0/components/HistoryView/index.tsx and 4 other locations - About 1 day to fix
packages/explorer-2.0/components/HistoryView/index.tsx on lines 392..434
packages/explorer-2.0/components/HistoryView/index.tsx on lines 435..477
packages/explorer-2.0/components/HistoryView/index.tsx on lines 478..520
packages/explorer-2.0/components/HistoryView/index.tsx on lines 521..563

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

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

    case "WithdrawFeesEvent":
      return (
        <ListItem
          css={{
            cursor: "pointer",
Severity: Major
Found in packages/explorer-2.0/components/HistoryView/index.tsx and 4 other locations - About 1 day to fix
packages/explorer-2.0/components/HistoryView/index.tsx on lines 298..340
packages/explorer-2.0/components/HistoryView/index.tsx on lines 392..434
packages/explorer-2.0/components/HistoryView/index.tsx on lines 478..520
packages/explorer-2.0/components/HistoryView/index.tsx on lines 521..563

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

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

    case "DepositFundedEvent":
      return (
        <ListItem
          css={{
            cursor: "pointer",
Severity: Major
Found in packages/explorer-2.0/components/HistoryView/index.tsx and 4 other locations - About 1 day to fix
packages/explorer-2.0/components/HistoryView/index.tsx on lines 298..340
packages/explorer-2.0/components/HistoryView/index.tsx on lines 392..434
packages/explorer-2.0/components/HistoryView/index.tsx on lines 435..477
packages/explorer-2.0/components/HistoryView/index.tsx on lines 478..520

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

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

const Poll = () => {
  const router = useRouter();
  const context = useWeb3React();
  const client = useApolloClient();
  const { width } = useWindowSize();
Severity: Major
Found in packages/explorer-2.0/pages/voting/[poll].tsx - About 1 day to fix

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

      <Flex
        css={{
          py: "$4",
          alignItems: "center",
          justifyContent: "center",
packages/explorer-2.0/components/Orchestrators/PerformanceTable.tsx on lines 439..479

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

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

      <Flex
        css={{
          py: "$4",
          alignItems: "center",
          justifyContent: "center",
packages/explorer-2.0/components/Orchestrators/StakingTable.tsx on lines 468..508

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

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

const createSchema = async () => {
  const executor = async ({ document, variables }) => {
    const query = print(document);
    const fetchResult = await fetch(process.env.NEXT_PUBLIC_SUBGRAPH, {
      method: "POST",
Severity: Major
Found in packages/explorer-2.0/apollo/createSchema.ts - About 1 day to fix

Function createLivepeerSDK has a Cognitive Complexity of 87 (exceeds 5 allowed). Consider refactoring.
Open

export async function createLivepeerSDK(
  opts: LivepeerSDKOptions
): Promise<LivepeerSDK> {
  const { ens, events, ...config } = await initContracts(opts);
  const {
Severity: Minor
Found in packages/sdk/src/index.js - About 1 day 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

File StakingTable.tsx has 684 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Box from "../Box";
import Flex from "../Flex";
import { useMemo, useState, forwardRef } from "react";
import { useTable, useFilters, useSortBy, usePagination } from "react-table";
import { abbreviateNumber, expandedPriceLabels } from "../../lib/utils";
Severity: Major
Found in packages/explorer-2.0/components/Orchestrators/StakingTable.tsx - About 1 day to fix
Severity
Category
Status
Source
Language