trufflesuite/truffle

View on GitHub
packages/core/lib/command-utils.js

Summary

Maintainability
D
2 days
Test Coverage

Function parseQuotesAndEscapes has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

function parseQuotesAndEscapes(args, escapeCharacters = "\\") {
  const quoteCharacters = "\"'"; //note we will handle the two quote types differently
  let argArray = [];
  let currentArg = "";
  let currentQuote = undefined;
Severity: Minor
Found in packages/core/lib/command-utils.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

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

    Function parseQuotesAndEscapes has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function parseQuotesAndEscapes(args, escapeCharacters = "\\") {
      const quoteCharacters = "\"'"; //note we will handle the two quote types differently
      let argArray = [];
      let currentArg = "";
      let currentQuote = undefined;
    Severity: Major
    Found in packages/core/lib/command-utils.js - About 2 hrs to fix

      Function getCommand has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      const getCommand = ({ inputStrings, options, noAliases }) => {
        if (inputStrings.length === 0) {
          return null;
        }
      
      
      Severity: Minor
      Found in packages/core/lib/command-utils.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 deriveConfigEnvironment has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const deriveConfigEnvironment = function (detectedConfig, network, url) {
        let configuredNetwork;
      
        const configDefinesProvider =
          detectedConfig.networks[network] &&
      Severity: Minor
      Found in packages/core/lib/command-utils.js - About 1 hr to fix

        Function runCommand has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const runCommand = async function (command, options) {
          try {
            // migrate Truffle data to the new location if necessary
            const configMigration = require("./config-migration");
            await configMigration.migrateTruffleDataIfNecessary();
        Severity: Minor
        Found in packages/core/lib/command-utils.js - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                if (!whitespace) {
                  //if we're already on whitespace, we don't need
                  //to do anything, this is just more whitespace.
                  //if however we're transitioning to whitespace, that means we need
                  //to split arguments here.
          Severity: Major
          Found in packages/core/lib/command-utils.js - About 45 mins to fix

            Function prepareOptions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            const prepareOptions = ({ command, inputStrings, options }) => {
              const yargs = require("yargs/yargs")();
              yargs
                .command(require(`./commands/${command.name}/meta`))
                //Turn off yargs' default behavior when handling `truffle --version` & `truffle <cmd> --help`
            Severity: Minor
            Found in packages/core/lib/command-utils.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

            Function deriveConfigEnvironment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            const deriveConfigEnvironment = function (detectedConfig, network, url) {
              let configuredNetwork;
            
              const configDefinesProvider =
                detectedConfig.networks[network] &&
            Severity: Minor
            Found in packages/core/lib/command-utils.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

            There are no issues that match your filters.

            Category
            Status