prey/prey-node-client

View on GitHub

Showing 323 of 551 total issues

Function start has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.start = function(id, options, cb) {
  var error,
      self     = this,
      returned = 0;

Severity: Minor
Found in lib/agent/actions/alarm/index.js - About 1 hr to fix

    Function get_connection_status has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    exp.get_connection_status = function (cb) {
      const data = config.all();
      const configData = data;
      const proxy = configData.try_proxy;
      const protocol = configData['control-panel.protocol'];
    Severity: Minor
    Found in lib/agent/providers/network/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 readWithoutVerification has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const readWithoutVerification = (cb) => {
      const extractedData = {};
      let nameBefore = '';
      let content = '';
      try {
    Severity: Minor
    Found in lib/agent/utils/prey-configuration/preyconf.js - About 1 hr to fix

      Function getPreyUserVersions has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const getPreyUserVersions = (preyUserVersion, cb) => {
        const successHandler = (foundVersion) => {
          if (foundVersion) {
            compareVersionsDaemon(foundVersion, preyUserVersion, cb);
          } else {
      Severity: Minor
      Found in lib/conf/tasks/prey_owl.js - About 1 hr to fix

        Function generate_keys has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        exports.generate_keys = (cb) => {
          storage.do('all', { type: 'keys' }, (err, values) => {
            if (err || !values) { return cb(new Error('Error reading stored security keys')); }
        
            // Read stored keys if they exists
        Severity: Minor
        Found in lib/agent/control-panel/secure.js - About 1 hr to fix

          Function verifyPreyConfData has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const verifyPreyConfData = (doNotVerifyApiDeviceKey = false) => {
            const dataToFix = {};
            let somethingWrong = false;
            resetDefaultValues();
            let content = '';
          Severity: Minor
          Found in lib/agent/utils/prey-configuration/preyconf.js - About 1 hr to fix

            Function collectFiles has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const collectFiles = (outputFile, cb) => {
              const output = fs.createWriteStream(outputFile);
              const archive = archiver('zip', {
                zlib: { level: 9 },
              });
            Severity: Minor
            Found in lib/agent/actions/logretrieval/index.js - About 1 hr to fix

              Function as_user has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function as_user(options, cb) {
                const { user } = options;
                const { bin } = options;
                const { type } = options;
                const { opts } = options;
              Severity: Minor
              Found in lib/system/index.js - About 1 hr to fix

                Function get_battery_status has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports.get_battery_status = function(cb) {
                
                  var keys = 'Availability,BatteryStatus,EstimatedChargeRemaining,EstimatedRunTime';
                
                  var get_state = function(num) {
                Severity: Minor
                Found in lib/agent/providers/indicators/windows.js - About 1 hr to fix

                  Function start has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  exports.start = function(id, opts, cb) {
                    var os_name = os.platform().replace('darwin', 'mac').replace('win32', 'windows');
                  
                    if (os_name != 'windows')
                      return cb(new Error('Action only allowed on Windows 1O'));
                  Severity: Minor
                  Found in lib/agent/actions/diskencryption/index.js - About 1 hr to fix

                    Function link has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                    exports.link = (data, cb) => {
                      if (!data || Object.keys(data).length == 0)
                        return cb(errors.arguments('Empty data.'));
                    
                      if (keys.get().device)
                    Severity: Minor
                    Found in lib/agent/control-panel/api/devices.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 eachFileOrDirectory has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                    var eachFileOrDirectory = function(directory, fileHandler, completeHandler) {
                      var filesToCheck = 0;
                      // var checkedFiles = [];
                      // var checkedStats = [];
                    
                    
                    Severity: Minor
                    Found in lib/agent/providers/files/finder.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 parse has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                    exports.parse = function (body) {
                      let c;
                      let matches;
                    
                      if ((matches = body.match(/^help\s?(\w+)?/))) c = ['help', matches[1]];
                    Severity: Minor
                    Found in lib/agent/commands.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 unprocessable has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                    exports.unprocessable = function(errors) {
                      if (typeof errors == 'object') {
                        var arr = [];
                        for (var key in errors) {
                          var err_key;
                    Severity: Minor
                    Found in lib/agent/control-panel/api/errors.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 request has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const request = function () {
                      if (current_request) {
                        logger.debug('Already running request');
                        return;
                      }
                    Severity: Minor
                    Found in lib/agent/control-panel/long-polling/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 RemoteTerminal has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                    var RemoteTerminal = function(options) {
                    
                      var self = this;
                      var options = options || {};
                    
                    
                    Severity: Minor
                    Found in lib/agent/actions/remote-terminal/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 start has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                    exports.start = function(id, opts, cb) {
                      var os_name = os.platform().replace('darwin', 'mac').replace('win32', 'windows');
                    
                      if (os_name != 'windows')
                        return cb(new Error('Action only allowed on Windows 1O'));
                    Severity: Minor
                    Found in lib/agent/actions/diskencryption/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 toPrecisionFixed has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                    var toPrecisionFixed = function(number, precision) {
                      if (isNaN(number)) return 'NaN';
                      var numb = number < 0 ? -number : number;  // can't take log of -ve number...
                      var sign = number < 0 ? '-' : '';
                    
                    
                    Severity: Minor
                    Found in lib/agent/triggers/location/lib/latlng.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 get_connection_status has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    exp.get_connection_status = function (cb) {
                      const data = config.all();
                      const configData = data;
                      const proxy = configData.try_proxy;
                      const protocol = configData['control-panel.protocol'];
                    Severity: Minor
                    Found in lib/agent/providers/network/index.js - About 1 hr to fix

                      Function watch_stopped has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const watch_stopped = function () {
                        if (!watching) return;
                      
                        hooks.on('action', (event, id) => {
                          if (event == 'stopped' || event == 'failed') {
                      Severity: Minor
                      Found in lib/agent/commands.js - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language