Showing 27 of 33 total issues
Function sanityCheck
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
const sanityCheck = (hostInfo) => {
debug("sanityCheck called", hostInfo);
// keep password, passphrase, and masterPty before validate.
// these properties can have a iellegal value as JSON data
- 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 getSshOption
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
const getSshOption = (hostInfo, withoutDestination) => {
debug("getSshOption called");
const args = [];
if (!withoutDestination) {
- 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 connect
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function connect (hostInfo, timeout = 60) {
debug("connect called");
if (await existsMaster(hostInfo, timeout)) {
debugVerbose("master connection exists");
Function getSshOption
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
const getSshOption = (hostInfo, withoutDestination) => {
debug("getSshOption called");
const args = [];
if (!withoutDestination) {
Function sanityCheck
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
const sanityCheck = (hostInfo) => {
debug("sanityCheck called", hostInfo);
// keep password, passphrase, and masterPty before validate.
// these properties can have a iellegal value as JSON data
Function fork
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function fork (hostInfo, cmd, args, timeout, outputCallback, retryableExitCodes = []) {
return new Promise((resolve, reject) => {
debug(`cmd=${cmd}: args=${args}`);
const ptyProcess = spawn(cmd, args, nodePtyOpt);
let ac = null;
Function send
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function send (hostInfo, argSrc, dst, rsyncOpt, timeout) {
await connect(hostInfo);
const promises = await Promise.allSettled(argSrc.map((e) => {
return glob(e);
}));
Function sshLoginCallback
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
function sshLoginCallback (output, ptyProcess, pw, ph, logger = debugSendPty) {
return new Promise((resolve, reject) => {
if (reNewHostPrompt.test(output)) {
sendPty(ptyProcess, "yes\n", logger, 17);
resolve();
Function p
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
const p = new Promise((resolve, reject) => {
ac = watchDogTimer(timeout, "make connection", () => {
sendPty(hostInfo.masterPty, "\n", debugSendMasterPty, 137);
sendPty(hostInfo.masterPty, "exit\n", debugSendMasterPty, 138);
Function disconnect
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async function disconnect (hostInfo) {
debug("disconnect called");
if (await existsMaster(hostInfo)) {
const args = getSshOption(hostInfo);
- 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 disconnect
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function disconnect (hostInfo) {
debug("disconnect called");
if (await existsMaster(hostInfo)) {
const args = getSshOption(hostInfo);
Function retryWrapper
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function retryWrapper (func, hostInfo, argMaxRetry, argDuration) {
const maxRetry = argMaxRetry || hostInfo.maxRetry || 3;
const duration = argDuration || hostInfo.retryDuration || 1000;
if (maxRetry === 1) {
return func();
Function retryWrapper
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
async function retryWrapper (func, hostInfo, argMaxRetry, argDuration) {
const maxRetry = argMaxRetry || hostInfo.maxRetry || 3;
const duration = argDuration || hostInfo.retryDuration || 1000;
if (maxRetry === 1) {
return func();
- 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 send
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
async function send (hostInfo, argSrc, dst, rsyncOpt, timeout) {
await connect(hostInfo);
const promises = await Promise.allSettled(argSrc.map((e) => {
return glob(e);
}));
- 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 fork
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
async function fork (hostInfo, cmd, args, timeout, outputCallback, retryableExitCodes = []) {
Function recv
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
async function recv (hostInfo, argSrc, dst, rsyncOpt, timeout) {
Function send
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
async function send (hostInfo, argSrc, dst, rsyncOpt, timeout) {
Function sshLoginCallback
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function sshLoginCallback (output, ptyProcess, pw, ph, logger = debugSendPty) {
Function sshExec
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
async function sshExec (hostInfo, cmd, timeout, outputCallback) {
debug("sshExec called");
await connect(hostInfo);
debug("exec", cmd, "on remote server");
const args = getSshOption(hostInfo, false);
- 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
Avoid too many return
statements within this function. Open
return logAndReject("opt must be array of string");