trufflesuite/truffle

View on GitHub
packages/source-map-utils/index.js

Summary

Maintainability
F
3 days
Test Coverage

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

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

const debug = require("debug")("source-map-utils");
const CodeUtils = require("@truffle/code-utils");
const Codec = require("@truffle/codec");
const Web3Utils = require("web3-utils");
const jsonpointer = require("json-pointer");
Severity: Minor
Found in packages/source-map-utils/index.js - About 5 hrs to fix

    Function isDesignatedInvalid has 111 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      isDesignatedInvalid: function (
        instructions,
        index,
        overlapFunctions,
        node = undefined
    Severity: Major
    Found in packages/source-map-utils/index.js - About 4 hrs to fix

      Function getFunctionsByProgramCounter has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

        getFunctionsByProgramCounter: function (
          instructions,
          asts,
          overlapFunctions,
          compilationId
      Severity: Minor
      Found in packages/source-map-utils/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 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

        Function getProcessedInstructionsForBinary has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          getProcessedInstructionsForBinary: function (sources, binary, sourceMap) {
            if (!sources || !binary) {
              return [];
            }
            debug("sourceMap: %O", sourceMap);
        Severity: Major
        Found in packages/source-map-utils/index.js - About 2 hrs to fix

          Function getHumanReadableSourceMap has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            getHumanReadableSourceMap: function (sourceMap) {
              const instructions = sourceMap.split(";");
          
              let processedInstruction = {
                start: 0,
          Severity: Minor
          Found in packages/source-map-utils/index.js - About 1 hr to fix

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

              getHumanReadableSourceMap: function (sourceMap) {
                const instructions = sourceMap.split(";");
            
                let processedInstruction = {
                  start: 0,
            Severity: Minor
            Found in packages/source-map-utils/index.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 too many return statements within this function.
            Open

                    return null;
            Severity: Major
            Found in packages/source-map-utils/index.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return false;
              Severity: Major
              Found in packages/source-map-utils/index.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return parseInt(instructions[index].pushData);
                Severity: Major
                Found in packages/source-map-utils/index.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                            return {
                              [instruction.pc]: {
                                sourceIndex,
                                compilationId,
                                //note: we're assuming that functions in generated sources are never pointed to
                  Severity: Major
                  Found in packages/source-map-utils/index.js - About 30 mins to fix

                    Function getProcessedInstructionsForBinary has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      getProcessedInstructionsForBinary: function (sources, binary, sourceMap) {
                        if (!sources || !binary) {
                          return [];
                        }
                        debug("sourceMap: %O", sourceMap);
                    Severity: Minor
                    Found in packages/source-map-utils/index.js - About 25 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 rangeNodes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      rangeNodes: function (node, pointer = "") {
                        if (node instanceof Array) {
                          return [].concat(
                            ...node.map((sub, i) =>
                              SourceMapUtils.rangeNodes(sub, `${pointer}/${i}`)
                    Severity: Minor
                    Found in packages/source-map-utils/index.js - About 25 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

                    There are no issues that match your filters.

                    Category
                    Status