so5/ssh-client-wrapper

View on GitHub
lib/sshExec.js

Summary

Maintainability
C
1 day
Test Coverage
A
91%

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 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 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

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

          async function existsMaster (hostInfo, argTimeout) {
            debugVerbose("existsMaster called");
            const args = getSshOption(hostInfo);
            args.push("-Ocheck");
          
          
          Severity: Minor
          Found in lib/sshExec.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