prey/prey-node-client

View on GitHub
lib/agent/updater.js

Summary

Maintainability
C
7 hrs
Test Coverage

Function update_client has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const update_client = function (new_version, cb) {
  let child;
  let error;
  const out = [];
  const versions_path = system.paths.versions;
Severity: Major
Found in lib/agent/updater.js - About 2 hrs to fix

    Function check has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.check = function (id, target, opts, cb) {
      function done(err) {
        if (cb && typeof cb === 'function') return cb && cb(err);
      }
    
    
    Severity: Major
    Found in lib/agent/updater.js - About 2 hrs to fix

      Function check has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.check = function (id, target, opts, cb) {
        function done(err) {
          if (cb && typeof cb === 'function') return cb && cb(err);
        }
      
      
      Severity: Minor
      Found in lib/agent/updater.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 check_for_update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      const check_for_update = function (cb) {
        config.load(() => {
          if (!exports.check_enabled || exports.upgrading) {
            if (cb && typeof cb === 'function') return cb();
            return;
      Severity: Minor
      Found in lib/agent/updater.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 get_stable_version_winsvc has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.get_stable_version_winsvc = function (cb) {
        config.load(() => {
          const releases_host = fetchEnvVar('prey_host_releases') ? fetchEnvVar('prey_host_releases') : 'https://downloads.preyproject.com';
          const releases_url = `${releases_host}/prey-client-releases/winsvc/`;
          const latest_text = 'latest.txt';
      Severity: Minor
      Found in lib/agent/updater.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