prey/prey-node-client

View on GitHub
lib/system/windows/index.js

Summary

Maintainability
C
1 day
Test Coverage

File index.js has 260 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"use strict";
//////////////////////////////////////////
// Prey Node.js Windows Client Functions
// (c) 2011 - Fork Ltd.
// by Tomas Pollak - http://forkhq.com
Severity: Minor
Found in lib/system/windows/index.js - About 2 hrs to fix

    Function get_os_edition has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.get_os_edition = (callback) => {
      if (os_name != "windows") {
        if (typeof callback !== 'function')
          return;
        return callback(new Error('Only for Windows'));
    Severity: Minor
    Found in lib/system/windows/index.js - About 1 hr to fix

      Function find_logged_user has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.find_logged_user = function(callback) {
        var done = function(err, stdout) {
          if (err) {
            if (typeof callback !== 'function')
              return;
      Severity: Minor
      Found in lib/system/windows/index.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 find_logged_user has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.find_logged_user = function(callback) {
        var done = function(err, stdout) {
          if (err) {
            if (typeof callback !== 'function')
              return;
      Severity: Minor
      Found in lib/system/windows/index.js - About 1 hr to fix

        Function check_service has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.check_service = function(data, cb) {
          if (exports.monitoring_service_go) {
            if (typeof cb !== 'function')
              return;
            return cb(null, data);
        Severity: Minor
        Found in lib/system/windows/index.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

        Consider simplifying this complex logical expression.
        Open

          if (data.os_name == 'windows' && gte(os.release().trim(), "10.0.0") &&
              data.os_edition && editions.includes(data.os_edition) &&
              data.winsvc_version && gte(data.winsvc_version, "2.0.0"))
              return true;
        Severity: Major
        Found in lib/system/windows/index.js - About 40 mins to fix

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

          exports.get_os_version = function(cb){
            var release = os.release();
            if (!release || release.trim() == ''){
              if (typeof cb !== 'function')
                return;
          Severity: Minor
          Found in lib/system/windows/index.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 get_current_hostname has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          exports.get_current_hostname = (callback) => {
            exec("hostname", (err, stdout) => {
              if (err) {
                if (typeof callback !== 'function')
                  return;
          Severity: Minor
          Found in lib/system/windows/index.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;
          Severity: Major
          Found in lib/system/windows/index.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return cb(null, out);
            Severity: Major
            Found in lib/system/windows/index.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return;
              Severity: Major
              Found in lib/system/windows/index.js - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status