so5/ssh-client-wrapper

View on GitHub

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
Severity: Minor
Found in lib/util.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 getSshOption has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

const getSshOption = (hostInfo, withoutDestination) => {
  debug("getSshOption called");
  const args = [];

  if (!withoutDestination) {
Severity: Minor
Found in lib/util.js - About 2 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 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");
Severity: Major
Found in lib/sshExec.js - About 2 hrs to fix

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

    const getSshOption = (hostInfo, withoutDestination) => {
      debug("getSshOption called");
      const args = [];
    
      if (!withoutDestination) {
    Severity: Major
    Found in lib/util.js - About 2 hrs to fix

      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
      Severity: Major
      Found in lib/util.js - About 2 hrs to fix

        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;
        Severity: Minor
        Found in lib/fork.js - About 2 hrs to fix

          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);
            }));
          Severity: Minor
          Found in lib/rsyncExec.js - About 1 hr to fix

            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();
            Severity: Minor
            Found in lib/fork.js - About 1 hr to fix

              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);
              
              
              Severity: Minor
              Found in lib/sshExec.js - About 1 hr to fix

                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);
                Severity: Minor
                Found in lib/sshExec.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 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);
                Severity: Minor
                Found in lib/sshExec.js - About 1 hr to fix

                  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();
                  Severity: Minor
                  Found in lib/sshExec.js - About 1 hr to fix

                    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();
                    Severity: Minor
                    Found in lib/sshExec.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 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);
                      }));
                    Severity: Minor
                    Found in lib/rsyncExec.js - About 55 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 fork has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    async function fork (hostInfo, cmd, args, timeout, outputCallback, retryableExitCodes = []) {
                    Severity: Minor
                    Found in lib/fork.js - About 45 mins to fix

                      Function recv has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      async function recv (hostInfo, argSrc, dst, rsyncOpt, timeout) {
                      Severity: Minor
                      Found in lib/rsyncExec.js - About 35 mins to fix

                        Function send has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        async function send (hostInfo, argSrc, dst, rsyncOpt, timeout) {
                        Severity: Minor
                        Found in lib/rsyncExec.js - About 35 mins to fix

                          Function sshLoginCallback has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          function sshLoginCallback (output, ptyProcess, pw, ph, logger = debugSendPty) {
                          Severity: Minor
                          Found in lib/fork.js - About 35 mins to fix

                            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);
                            Severity: Minor
                            Found in lib/sshExec.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 logAndReject("opt must be array of string");
                            Severity: Major
                            Found in lib/index.js - About 30 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language