trufflesuite/truffle

View on GitHub

Showing 1,401 of 1,401 total issues

Function steps has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

  steps(kind, data) {
    const self = this;
    const reporter = self.reporter;
    const valueUnit = data.valueUnit || "ETH";

Severity: Minor
Found in packages/events/defaultSubscribers/migrate/Messages.js - About 5 hrs 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 DashProvider has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

function DashProvider({ children }: DashProviderProps): JSX.Element {
  const { isConnected, address } = useAccount();
  const { chain } = useNetwork();
  const [state, dispatch] = useReducer(reducer, initialState);
  const initCalled = useRef(false);
Severity: Minor
Found in packages/dashboard/src/contexts/DashContext/DashProvider.tsx - About 5 hrs 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

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

export const { UintValue } = createCodecComponent(
  "UintValue",
  ({ value, type }: Format.Values.UintValue) => {
    const { prefix, content } = useInjectedNode();
    return (
packages/codec-components/src/react/components/codec/format.values.bool-value.tsx on lines 8..20
packages/codec-components/src/react/components/codec/format.values.fixed-value.tsx on lines 8..20
packages/codec-components/src/react/components/codec/format.values.int-value.tsx on lines 8..20
packages/codec-components/src/react/components/codec/format.values.ufixed-value.tsx on lines 8..20

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

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

export const { BoolValue } = createCodecComponent(
  "BoolValue",
  ({ value, type }: Format.Values.BoolValue) => {
    const { prefix, content } = useInjectedNode();
    return (
packages/codec-components/src/react/components/codec/format.values.fixed-value.tsx on lines 8..20
packages/codec-components/src/react/components/codec/format.values.int-value.tsx on lines 8..20
packages/codec-components/src/react/components/codec/format.values.ufixed-value.tsx on lines 8..20
packages/codec-components/src/react/components/codec/format.values.uint-value.tsx on lines 8..20

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

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

export const { UfixedValue } = createCodecComponent(
  "UfixedValue",
  ({ value, type }: Format.Values.UfixedValue) => {
    const { prefix, content } = useInjectedNode();
    return (
packages/codec-components/src/react/components/codec/format.values.bool-value.tsx on lines 8..20
packages/codec-components/src/react/components/codec/format.values.fixed-value.tsx on lines 8..20
packages/codec-components/src/react/components/codec/format.values.int-value.tsx on lines 8..20
packages/codec-components/src/react/components/codec/format.values.uint-value.tsx on lines 8..20

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

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

export const { FixedValue } = createCodecComponent(
  "FixedValue",
  ({ value, type }: Format.Values.FixedValue) => {
    const { prefix, content } = useInjectedNode();
    return (
packages/codec-components/src/react/components/codec/format.values.bool-value.tsx on lines 8..20
packages/codec-components/src/react/components/codec/format.values.int-value.tsx on lines 8..20
packages/codec-components/src/react/components/codec/format.values.ufixed-value.tsx on lines 8..20
packages/codec-components/src/react/components/codec/format.values.uint-value.tsx on lines 8..20

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

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

  {
    type: "codec-interface",
    name: "FunctionDecoding",
    content: (
      <>
Severity: Major
Found in packages/codec-components/src/docs/content.tsx and 1 other location - About 5 hrs to fix
packages/codec-components/src/docs/content.tsx on lines 47..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 143.

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

  {
    type: "codec-interface",
    name: "ConstructorDecoding",
    content: (
      <>
Severity: Major
Found in packages/codec-components/src/docs/content.tsx and 1 other location - About 5 hrs to fix
packages/codec-components/src/docs/content.tsx on lines 86..101

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

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

export const { IntValue } = createCodecComponent(
  "IntValue",
  ({ value, type }: Format.Values.IntValue) => {
    const { prefix, content } = useInjectedNode();
    return (
packages/codec-components/src/react/components/codec/format.values.bool-value.tsx on lines 8..20
packages/codec-components/src/react/components/codec/format.values.fixed-value.tsx on lines 8..20
packages/codec-components/src/react/components/codec/format.values.ufixed-value.tsx on lines 8..20
packages/codec-components/src/react/components/codec/format.values.uint-value.tsx on lines 8..20

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

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

    if (
      decoding.kind === "function" &&
      decoding.abi.name === "multicall" &&
      decoding.abi.inputs.length === 2 &&
      decoding.abi.inputs[0].type === "bytes32" &&
Severity: Major
Found in packages/decoder/lib/decoders.ts and 1 other location - About 5 hrs to fix
packages/decoder/lib/decoders.ts on lines 1293..1323

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

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

    if (
      decoding.kind === "function" &&
      decoding.abi.name === "multicall" &&
      decoding.abi.inputs.length === 2 &&
      decoding.abi.inputs[0].type === "uint256" &&
Severity: Major
Found in packages/decoder/lib/decoders.ts and 1 other location - About 5 hrs to fix
packages/decoder/lib/decoders.ts on lines 1337..1367

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

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 console.js has 388 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const repl = require("repl");
const provision = require("@truffle/provisioner");
const {
  Web3Shim,
  createInterfaceAdapter
Severity: Minor
Found in packages/core/lib/console.js - About 5 hrs to fix

    File execute.js has 385 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const debug = require("debug")("contract:execute");
    const PromiEvent = require("./promievent");
    const EventEmitter = require("events");
    const utils = require("./utils");
    const StatusError = require("./statuserror");
    Severity: Minor
    Found in packages/contract/lib/execute.js - About 5 hrs to fix

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

      const shortCommandReference = {
        "o": "step over",
        "i": "step into",
        "u": "step out",
        "n": "step next",
      Severity: Major
      Found in packages/debug-utils/index.js and 1 other location - About 5 hrs to fix
      packages/debug-utils/index.js on lines 36..63

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

      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

      const commandReference = {
        "o": "step over",
        "i": "step line / step into",
        "u": "step out",
        "n": "step next",
      Severity: Major
      Found in packages/debug-utils/index.js and 1 other location - About 5 hrs to fix
      packages/debug-utils/index.js on lines 65..92

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

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

        async printReturnValue() {
          //note: when printing revert messages, this will do so in a somewhat
          //different way than printRevertMessage does
          const inspectOptions = {
            colors: true,
      Severity: Minor
      Found in packages/core/lib/debug/printer.js - About 5 hrs 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 codex has 127 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function codex(state = DEFAULT_CODEX, action) {
        let newState, topCodex, topCodexNoZero;
      
        const updateFrameStorage = (frame, address, slot, value) => ({
          ...frame,
      Severity: Major
      Found in packages/debugger/lib/evm/reducers.js - About 5 hrs to fix

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

        export const { EnumValue } = createCodecComponent(
          "EnumValue",
          ({ value, type }: Format.Values.EnumValue) => {
            const { prefix, content } = useInjectedNode();
            return (
        packages/codec-components/src/react/components/codec/format.values.address-value.tsx on lines 8..20
        packages/codec-components/src/react/components/codec/format.values.bytes-dynamic-value.tsx on lines 8..20
        packages/codec-components/src/react/components/codec/format.values.bytes-static-value.tsx on lines 8..20

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

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

        export const { BytesDynamicValue } = createCodecComponent(
          "BytesDynamicValue",
          ({ value, type }: Format.Values.BytesDynamicValue) => {
            const { prefix, content } = useInjectedNode();
            return (
        packages/codec-components/src/react/components/codec/format.values.address-value.tsx on lines 8..20
        packages/codec-components/src/react/components/codec/format.values.bytes-static-value.tsx on lines 8..20
        packages/codec-components/src/react/components/codec/format.values.enum-value.tsx on lines 8..20

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

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

        export const { AddressValue } = createCodecComponent(
          "AddressValue",
          ({ value, type }: Format.Values.AddressValue) => {
            const { prefix, content } = useInjectedNode();
            return (
        packages/codec-components/src/react/components/codec/format.values.bytes-dynamic-value.tsx on lines 8..20
        packages/codec-components/src/react/components/codec/format.values.bytes-static-value.tsx on lines 8..20
        packages/codec-components/src/react/components/codec/format.values.enum-value.tsx on lines 8..20

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

        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

        Severity
        Category
        Status
        Source
        Language