trufflesuite/truffle

View on GitHub

Showing 1,401 of 1,401 total issues

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

export const { ConstructorDecoding } = createCodecComponent(
  "ConstructorDecoding",
  (data: Codec.ConstructorDecoding) => {
    return (
      <Container
packages/codec-components/src/react/components/codec/event-decoding.tsx on lines 9..30
packages/codec-components/src/react/components/codec/revert-message-decoding.tsx on lines 9..30

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

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

export const { RevertMessageDecoding } = createCodecComponent(
  "RevertMessageDecoding",
  (data: Codec.RevertMessageDecoding) => {
    return (
      <Container
packages/codec-components/src/react/components/codec/constructor-decoding.tsx on lines 9..30
packages/codec-components/src/react/components/codec/event-decoding.tsx on lines 9..30

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

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

module.exports = Contract => ({
  configureNetwork({ networkType, provider } = {}) {
    // otherwise use existing value as default (at most one of these)
    networkType = networkType || this.networkType;
    provider = provider || this.currentProvider;
Severity: Minor
Found in packages/contract/lib/contract/constructorMethods.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

Function updateTransactionLogSaga has 203 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function* updateTransactionLogSaga() {
  const pointer = yield select(txlog.current.pointer); //log pointer, not AST pointer
  const step = yield select(txlog.current.step);
  if (yield select(txlog.current.isHalting)) {
    //note that we process this case first so that it overrides the others!
Severity: Major
Found in packages/debugger/lib/txlog/sagas/index.js - About 1 day to fix

    Function normalize has 201 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static normalize(compilations) {
        let contexts = [];
        let sources = {
          user: {}, //by compilation
          internal: {} //by context
    Severity: Major
    Found in packages/debugger/lib/session/index.js - About 1 day to fix

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

            decoding.kind === "function" &&
            decoding.abi.name === "aggregate3Value" &&
            decoding.abi.inputs.length === 1 &&
            decoding.abi.inputs[0].type === "tuple[]" &&
            decoding.abi.inputs[0].components.length === 4 &&
      Severity: Major
      Found in packages/decoder/lib/decoders.ts and 1 other location - About 7 hrs to fix
      packages/decoder/lib/decoders.ts on lines 1100..1108

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

      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

            decoding.kind === "function" &&
            decoding.abi.name === "aggregate3" &&
            decoding.abi.inputs.length === 1 &&
            decoding.abi.inputs[0].type === "tuple[]" &&
            decoding.abi.inputs[0].components.length === 3 &&
      Severity: Major
      Found in packages/decoder/lib/decoders.ts and 1 other location - About 7 hrs to fix
      packages/decoder/lib/decoders.ts on lines 1128..1136

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

      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

        return (
          // @ts-ignore
          <Box ref={ref} flexDirection="column" borderStyle="round" paddingBottom={1}>
            <Divider
              width={width - 2}
      Severity: Major
      Found in packages/db-kit/src/cli/decodeAddress/Result.tsx and 1 other location - About 7 hrs to fix
      packages/db-kit/src/cli/decodeTransaction/Result.tsx on lines 106..130

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

      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

        return (
          // @ts-ignore
          <Box ref={ref} flexDirection="column" borderStyle="round" paddingBottom={1}>
            <Divider
              width={width - 2}
      Severity: Major
      Found in packages/db-kit/src/cli/decodeTransaction/Result.tsx and 1 other location - About 7 hrs to fix
      packages/db-kit/src/cli/decodeAddress/Result.tsx on lines 110..134

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

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

      function Debugger(): JSX.Element {
        const { classes } = useStyles();
        const [inputValue, setInputValue] = useInputState("");
        const [sessionUpdated, { increment: sessionTick }] = useCounter();
        const {
      Severity: Major
      Found in packages/dashboard/src/components/composed/Debugger/index.tsx - About 7 hrs to fix

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

        export const { BuiltInValueErrorResult } = createCodecComponent(
          "BuiltInValueErrorResult",
          (data: Format.Errors.BuiltInValueErrorResult) =>
            isUintErrorResult(data) ? (
              <UintErrorResult data={data} />
        packages/codec-components/src/react/components/codec/format.errors.read-error.tsx on lines 20..38
        packages/codec-components/src/react/components/codec/format.values.built-in-value-value.tsx on lines 20..38

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

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

        export const { ReadError } = createCodecComponent(
          "ReadError",
          (data: Format.Errors.ReadError) =>
            isUnsupportedConstantError(data) ? (
              <UnsupportedConstantError data={data} />
        packages/codec-components/src/react/components/codec/format.errors.built-in-value-error-result.tsx on lines 20..38
        packages/codec-components/src/react/components/codec/format.values.built-in-value-value.tsx on lines 20..38

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

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

        export const { BuiltInValueValue } = createCodecComponent(
          "BuiltInValueValue",
          (data: Format.Values.BuiltInValueValue) =>
            isUintValue(data) ? (
              <UintValue data={data} />
        packages/codec-components/src/react/components/codec/format.errors.built-in-value-error-result.tsx on lines 20..38
        packages/codec-components/src/react/components/codec/format.errors.read-error.tsx on lines 20..38

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

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

        import debugModule from "debug";
        const debug = debugModule("debugger:evm:selectors");
        
        import { createSelectorTree, createLeaf } from "reselect-tree";
        import BN from "bn.js";
        Severity: Minor
        Found in packages/debugger/lib/evm/selectors/index.js - About 7 hrs to fix

          Function createStepSelectors has 187 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function createStepSelectors(step, state = null) {
            let base = {
              /**
               * .trace
               *
          Severity: Major
          Found in packages/debugger/lib/evm/selectors/index.js - About 7 hrs to fix

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

            import debugModule from "debug";
            const debug = debugModule("debugger:session");
            
            import * as Abi from "@truffle/abi-utils";
            import * as Codec from "@truffle/codec";
            Severity: Minor
            Found in packages/debugger/lib/session/index.js - About 7 hrs to fix

              Function isDesignatedInvalid has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
              Open

                isDesignatedInvalid: function (
                  instructions,
                  index,
                  overlapFunctions,
                  node = undefined
              Severity: Minor
              Found in packages/source-map-utils/index.js - About 6 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 2 locations. Consider refactoring.
              Open

                        if (generatedSources) {
                          sources.internal[contextHash] = [];
                          for (let index in generatedSources) {
                            index = Number(index); //it comes out as a string due to in, so let's fix that
                            const source = generatedSources[index];
              Severity: Major
              Found in packages/debugger/lib/session/index.js and 1 other location - About 6 hrs to fix
              packages/debugger/lib/session/index.js on lines 334..353

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

              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 (deployedGeneratedSources) {
                          sources.internal[contextHash] = [];
                          for (let index in deployedGeneratedSources) {
                            index = Number(index); //it comes out as a string due to in, so let's fix that
                            const source = deployedGeneratedSources[index];
              Severity: Major
              Found in packages/debugger/lib/session/index.js and 1 other location - About 6 hrs to fix
              packages/debugger/lib/session/index.js on lines 284..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 161.

              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 154 lines of code (exceeds 25 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: Major
              Found in packages/core/lib/debug/printer.js - About 6 hrs to fix
                Severity
                Category
                Status
                Source
                Language