trufflesuite/truffle

View on GitHub
packages/core/lib/debug/interpreter.js

Summary

Maintainability
F
1 wk
Test Coverage

Function interpreter has a Cognitive Complexity of 132 (exceeds 5 allowed). Consider refactoring.
Open

  async interpreter(cmd) {
    cmd = cmd.trim();
    let cmdArgs, splitArgs;
    debug("cmd %s", cmd);

Severity: Minor
Found in packages/core/lib/debug/interpreter.js - About 2 days 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 interpreter has 399 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async interpreter(cmd) {
    cmd = cmd.trim();
    let cmdArgs, splitArgs;
    debug("cmd %s", cmd);

Severity: Major
Found in packages/core/lib/debug/interpreter.js - About 1 day to fix

    File interpreter.js has 698 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const debugModule = require("debug");
    const debug = debugModule("lib:debug:interpreter");
    
    const path = require("path");
    const util = require("util");
    Severity: Major
    Found in packages/core/lib/debug/interpreter.js - About 1 day to fix

      Function determineBreakpoints has 126 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        determineBreakpoints(args) {
          const currentLocation = this.session.view(controller.current.location);
      
          const currentStart = currentLocation.sourceRange
            ? currentLocation.sourceRange.start
      Severity: Major
      Found in packages/core/lib/debug/interpreter.js - About 5 hrs to fix

        Function determineBreakpoints has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

          determineBreakpoints(args) {
            const currentLocation = this.session.view(controller.current.location);
        
            const currentStart = currentLocation.sourceRange
              ? currentLocation.sourceRange.start
        Severity: Minor
        Found in packages/core/lib/debug/interpreter.js - About 4 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 setOrClearBreakpointObject has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async setOrClearBreakpointObject(breakpoint, setOrClear) {
            const existingBreakpoints = this.session.view(controller.breakpoints);
            //OK, we've constructed the breakpoint!  But if we're adding, we'll
            //want to adjust to make sure we don't set it on an empty line or
            //anything like that
        Severity: Minor
        Found in packages/core/lib/debug/interpreter.js - About 1 hr to fix

          Function setOrClearBreakpointObject has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            async setOrClearBreakpointObject(breakpoint, setOrClear) {
              const existingBreakpoints = this.session.view(controller.breakpoints);
              //OK, we've constructed the breakpoint!  But if we're adding, we'll
              //want to adjust to make sure we don't set it on an empty line or
              //anything like that
          Severity: Minor
          Found in packages/core/lib/debug/interpreter.js - About 1 hr 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 updatePrintouts has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            updatePrintouts(userArgs, selections, printOuts) {
              let tempPrintouts = new Set();
              for (let argument of userArgs) {
                let fullSelection;
                if (argument[0] === "+" || argument[0] === "-") {
          Severity: Minor
          Found in packages/core/lib/debug/interpreter.js - About 1 hr 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

          Avoid deeply nested control flow statements.
          Open

                  if (
                    matchingSources.some(shortSource =>
                      matchingSources.every(
                        source =>
                          typeof source.sourcePath !== "string" || //just ignore these I guess?
          Severity: Major
          Found in packages/core/lib/debug/interpreter.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                        if (errorIndex !== null) {
                          const stepSpinner = new Spinner(
                            "core:debug:interpreter:step",
                            "Stepping..."
                          );
            Severity: Major
            Found in packages/core/lib/debug/interpreter.js - About 45 mins to fix

              Function parsePrintoutLines has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                parsePrintoutLines(userArgs, currentLines) {
                  let { beforeLines, afterLines } = currentLines;
                  for (const argument of userArgs) {
                    // ignore an option with length less than 2,such as a bare + or -
                    if (argument.length < 2) continue;
              Severity: Minor
              Found in packages/core/lib/debug/interpreter.js - About 45 mins 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 setOrClearBreakpoint has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                async setOrClearBreakpoint(args, setOrClear) {
                  const breakpoints = this.determineBreakpoints(args); //note: not pure, can print
                  if (breakpoints !== null) {
                    for (const breakpoint of breakpoints) {
                      await this.setOrClearBreakpointObject(breakpoint, setOrClear);
              Severity: Minor
              Found in packages/core/lib/debug/interpreter.js - About 35 mins 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

              Avoid too many return statements within this function.
              Open

                      return [];
              Severity: Major
              Found in packages/core/lib/debug/interpreter.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return [];
                Severity: Major
                Found in packages/core/lib/debug/interpreter.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                            return [];
                  Severity: Major
                  Found in packages/core/lib/debug/interpreter.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                          return [
                            {
                              sourceId: currentSourceId,
                              line: line - 1 //adjust for zero-indexing!
                            }
                    Severity: Major
                    Found in packages/core/lib/debug/interpreter.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            return [
                              {
                                sourceId: matchingSources[0].id,
                                line: line - 1 //adjust for zero-indexing!
                              }
                      Severity: Major
                      Found in packages/core/lib/debug/interpreter.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return [
                                {
                                  sourceId: currentSourceId,
                                  line: currentLine + delta
                                }
                        Severity: Major
                        Found in packages/core/lib/debug/interpreter.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return [];
                          Severity: Major
                          Found in packages/core/lib/debug/interpreter.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return [];
                            Severity: Major
                            Found in packages/core/lib/debug/interpreter.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                        return matchingSources.map(source => ({
                                          sourceId: source.id,
                                          line: line - 1 //adjust for breakpoint!
                                        }));
                              Severity: Major
                              Found in packages/core/lib/debug/interpreter.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        return [];
                                Severity: Major
                                Found in packages/core/lib/debug/interpreter.js - About 30 mins to fix

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

                                        if (this.session.view(session.status.loaded)) {
                                          const errorIndex = this.session.view(
                                            stacktrace.current.innerErrorIndex
                                          );
                                          if (errorIndex !== null) {
                                  Severity: Major
                                  Found in packages/core/lib/debug/interpreter.js and 1 other location - About 4 hrs to fix
                                  packages/core/lib/debug/interpreter.js on lines 439..460

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

                                  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 (!this.session.view(evm.current.step.isExceptionalHalting)) {
                                              const errorIndex = this.session.view(
                                                stacktrace.current.innerErrorIndex
                                              );
                                              if (errorIndex !== null) {
                                  Severity: Major
                                  Found in packages/core/lib/debug/interpreter.js and 1 other location - About 4 hrs to fix
                                  packages/core/lib/debug/interpreter.js on lines 472..490

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

                                  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

                                      let sourceNames = Object.assign(
                                        //note: only include user sources
                                        {},
                                        ...Object.entries(sources).map(([id, source]) => ({
                                          [id]: path.basename(source.sourcePath)
                                  Severity: Major
                                  Found in packages/core/lib/debug/interpreter.js and 1 other location - About 1 hr to fix
                                  packages/core/lib/debug/printer.js on lines 337..343

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

                                  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

                                          if (this.session.view(session.status.loaded)) {
                                            this.printer.printAddressesAffected();
                                            this.printer.warnIfNoSteps();
                                            this.printer.printFile();
                                            this.printer.printState();
                                  Severity: Major
                                  Found in packages/core/lib/debug/interpreter.js and 1 other location - About 1 hr to fix
                                  packages/core/lib/debug/interpreter.js on lines 749..757

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

                                  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

                                          if (!loadFailed) {
                                            this.printer.printAddressesAffected();
                                            this.printer.warnIfNoSteps();
                                            this.printer.printFile();
                                            this.printer.printState();
                                  Severity: Major
                                  Found in packages/core/lib/debug/interpreter.js and 1 other location - About 1 hr to fix
                                  packages/core/lib/debug/interpreter.js on lines 741..746

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

                                  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

                                            existingBreakpoint.sourceId === breakpoint.sourceId &&
                                            existingBreakpoint.line === breakpoint.line &&
                                            existingBreakpoint.node === breakpoint.node //may be undefined
                                  Severity: Minor
                                  Found in packages/core/lib/debug/interpreter.js and 1 other location - About 30 mins to fix
                                  packages/debugger/lib/sourcemapping/selectors/index.js on lines 323..325

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

                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                  Refactorings

                                  Further Reading

                                  There are no issues that match your filters.

                                  Category
                                  Status