trufflesuite/truffle

View on GitHub

Showing 1,401 of 1,401 total issues

Function processTarget has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

async function processTarget(target, cwd, logger) {
  const usesPath = target.path != undefined;
  const usesCommand = target.command != undefined;
  const usesStdin = target.stdin || target.stdin == undefined; // default true
  const usesProperties = target.properties || target.fileProperties;
Severity: Minor
Found in packages/external-compile/index.js - About 3 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 interpret has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  async interpret(input, context, filename, callback) {
    const processedInput = processInput(input);
    if (validTruffleConsoleCommands.includes(processedInput.split(/\s+/)[0])) {
      try {
        parseQuotesAndEscapes(processedInput); //we're just doing this to see
Severity: Minor
Found in packages/core/lib/console.js - About 3 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 resolveAllSources has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

export async function resolveAllSources({
  resolve,
  paths,
  shouldIncludePath,
  parseImports
Severity: Minor
Found in packages/profiler/src/resolveAllSources.ts - About 3 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

    ...(!transactionHash || receipt
      ? []
      : [
          <Box key="receipt">
            <Box paddingLeft={1} paddingRight={1}>
Severity: Major
Found in packages/db-kit/src/cli/decodeTransaction/Inputs.tsx and 1 other location - About 3 hrs to fix
packages/db-kit/src/cli/decodeTransaction/Inputs.tsx on lines 39..50

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

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

    ...(!transactionHash || transaction
      ? []
      : [
          <Box key="transaction">
            <Box paddingLeft={1} paddingRight={1}>
Severity: Major
Found in packages/db-kit/src/cli/decodeTransaction/Inputs.tsx and 1 other location - About 3 hrs to fix
packages/db-kit/src/cli/decodeTransaction/Inputs.tsx on lines 51..62

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

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

function* decodeMappingKeyCore(indexDefinition, keyDefinition) {
  const scopes = yield select(data.current.scopes.inlined);
  const compilationId = yield select(data.current.compilationId);
  const internalFor = yield select(data.current.internalSourceFor); //should be null, but...
  const currentAssignments = yield select(data.proc.assignments);
Severity: Major
Found in packages/debugger/lib/data/sagas/index.js - About 3 hrs to fix

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

      getFunctionsByProgramCounter: function (
        instructions,
        asts,
        overlapFunctions,
        compilationId
    Severity: Major
    Found in packages/source-map-utils/index.js - About 3 hrs to fix

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

      import debugModule from "debug";
      const debug = debugModule("debugger:txlog:sagas");
      
      import { put, takeEvery, select } from "redux-saga/effects";
      import { prefixName } from "lib/helpers";
      Severity: Minor
      Found in packages/debugger/lib/txlog/sagas/index.js - About 3 hrs to fix

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

          @validStates([State.Active])
          @transitionToState(State.Done)
          async *resolve({ resolution, payload }: Options.Resolve = {}) {
            yield this.emit<Events.Resolve>({
              type: "resolve",
        packages/preserve/lib/control/controllers/StepsController.ts on lines 74..82

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

        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

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

                inputs: fc.array(Parameter(), { maxLength: 10 }).filter(inputs => {
                  // names that are not blank should be unique
                  const names = inputs
                    .map(({ name }) => name)
                    .filter(name => name !== "");
        Severity: Major
        Found in packages/abi-utils/lib/arbitrary.ts and 1 other location - About 3 hrs to fix
        packages/abi-utils/lib/arbitrary.ts on lines 48..52

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

        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

          @validStates([State.Active])
          @transitionToState(State.Done)
          async *succeed({ result, message }: Options.Succeed = {}) {
            yield this.emit<Events.Succeed>({
              type: "succeed",
        Severity: Major
        Found in packages/preserve/lib/control/controllers/StepsController.ts and 1 other location - About 3 hrs to fix
        packages/preserve/lib/control/controllers/ValueResolutionController.ts on lines 53..61

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

        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

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

            inputs: fc.array(Parameter(), { maxLength: 10 }).filter(inputs => {
              // names that are not blank should be unique
              const names = inputs.map(({ name }) => name).filter(name => name !== "");
              return names.length === new Set(names).size;
            })
        Severity: Major
        Found in packages/abi-utils/lib/arbitrary.ts and 1 other location - About 3 hrs to fix
        packages/abi-utils/lib/arbitrary.ts on lines 148..154

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

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

          formatStacktrace: function (stacktrace, indent = 2) {
            //get message or panic code from stacktrace
            const { message, panic, custom } = stacktrace[0];
            //we want to print inner to outer, so first, let's
            //reverse
        Severity: Major
        Found in packages/debug-utils/index.js - About 3 hrs to fix

          Function printRevertMessage has 79 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async printRevertMessage() {
              this.config.logger.log(
                DebugUtils.truffleColors.red("Transaction halted with a RUNTIME ERROR.")
              );
              this.config.logger.log("");
          Severity: Major
          Found in packages/core/lib/debug/printer.js - About 3 hrs to fix

            Function decodeLiteral has 79 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function* decodeLiteral(
              dataType: Format.Types.Type,
              pointer: Pointer.StackLiteralPointer,
              info: Evm.EvmInfo
            ): Generator<DecoderRequest, Format.Values.Result, Uint8Array | null> {
            Severity: Major
            Found in packages/codec/lib/stack/decode/index.ts - About 3 hrs to fix

              File command-utils.js has 298 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              const { bundled, core } = require("../lib/version").info();
              const OS = require("os");
              const analytics = require("../lib/services/analytics");
              const { extractFlags } = require("./utils/utils"); // contains utility methods
              const globalCommandOptions = require("./global-command-options");
              Severity: Minor
              Found in packages/core/lib/command-utils.js - About 3 hrs to fix

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

                export const { InternalUseError } = createCodecComponent(
                  "InternalUseError",
                  (data: Format.Errors.InternalUseError) =>
                    isOverlongArrayOrStringStrictModeError(data) ? (
                      <OverlongArrayOrStringStrictModeError data={data} />
                packages/codec-components/src/react/components/codec/format.errors.enum-error.tsx on lines 9..19
                packages/codec-components/src/react/components/codec/format.errors.generic-error.tsx on lines 12..22
                packages/codec-components/src/react/components/codec/format.values.function-external-value-info.tsx on lines 12..22
                packages/codec-components/src/react/components/codec/format.values.function-internal-value-info.tsx on lines 12..22

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

                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

                  } else if (yield select(evm.current.step.isLoad)) {
                    let storageAddress = (yield select(evm.current.call)).storageAddress;
                    let slot = yield select(evm.current.step.storageAffected);
                    let loadedValue = yield select(evm.current.step.valueLoaded);
                    yield put(actions.load(storageAddress, slot, loadedValue));
                Severity: Major
                Found in packages/debugger/lib/evm/sagas/index.js and 1 other location - About 3 hrs to fix
                packages/debugger/lib/evm/sagas/index.js on lines 267..277

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

                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 { FunctionInternalValueInfo } = createCodecComponent(
                  "FunctionInternalValueInfo",
                  (data: Format.Values.FunctionInternalValueInfo) =>
                    isFunctionInternalValueInfoKnown(data) ? (
                      <FunctionInternalValueInfoKnown data={data} />
                packages/codec-components/src/react/components/codec/format.errors.enum-error.tsx on lines 9..19
                packages/codec-components/src/react/components/codec/format.errors.generic-error.tsx on lines 12..22
                packages/codec-components/src/react/components/codec/format.errors.internal-use-error.tsx on lines 12..22
                packages/codec-components/src/react/components/codec/format.values.function-external-value-info.tsx on lines 12..22

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

                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 { EnumError } = createCodecComponent(
                  "EnumError",
                  (data: Format.Errors.EnumError) =>
                    isEnumOutOfRangeError(data) ? (
                      <EnumOutOfRangeError data={data} />
                packages/codec-components/src/react/components/codec/format.errors.generic-error.tsx on lines 12..22
                packages/codec-components/src/react/components/codec/format.errors.internal-use-error.tsx on lines 12..22
                packages/codec-components/src/react/components/codec/format.values.function-external-value-info.tsx on lines 12..22
                packages/codec-components/src/react/components/codec/format.values.function-internal-value-info.tsx on lines 12..22

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

                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