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;
- Read upRead up
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");
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;
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;
}
- Read upRead up
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] &&
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();
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.
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`
- Read upRead up
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] &&
- Read upRead up
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"