prey/prey-node-client

View on GitHub

Showing 313 of 528 total issues

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 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 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 collect_files has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const collect_files = (output_file, cb) => {
            const output = fs.createWriteStream(output_file);
            const archive = archiver('zip', {
              zlib: { level: 9 },
            });
          Severity: Minor
          Found in lib/agent/actions/logretrieval/index.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 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 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 parse has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

              exports.parse = function (body) {
                var c;
                var 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 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 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 start has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports.start = function (cb) {
                
                  var count,
                    last_err,
                    folders_removed = [];
                Severity: Minor
                Found in lib/conf/tasks/clear_folders.js - About 1 hr to fix

                  Function get_active_access_point has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  exports.get_active_access_point = (callback) => {
                    exports.isWifiPermissionActive((itWorks) => {
                      if (itWorks) {
                        const processActiveAp = (stdout) => {
                          if (stdout.includes('AirPort: Off') || !stdout.includes('SSID')) {
                  Severity: Minor
                  Found in lib/agent/providers/network/mac.js - About 1 hr to fix

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

                    exports.start = function (cb) {
                    
                      var count,
                        last_err,
                        files_removed = [];
                    Severity: Minor
                    Found in lib/conf/tasks/clear_files_prey_temp.js - About 1 hr to fix

                      Function gather has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const gather = (reportName, list, cb) => {
                        const data = {};
                        let gathered = false;
                        let count = list.length;
                        let listReports = [...list];
                      Severity: Minor
                      Found in lib/agent/reports.js - About 1 hr to fix

                        Function correctPreyConf has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const correctPreyConf = (preyConfDataToWrite, callback) => {
                          let allFileContents = '';
                        
                          allFileContents = getFileContent(join(__dirname, '../../../../prey.conf.default'));
                          if (allFileContents === '') {
                        Severity: Minor
                        Found in lib/agent/utils/prey-configuration/preyconf.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language