prey/prey-node-client

View on GitHub

Showing 323 of 551 total issues

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,
        folders_removed = [];
    Severity: Minor
    Found in lib/conf/tasks/clear_folders.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

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

            const start = function (type, id, name, opts, cb) {
              // Action with same id is not executed
              if (running[id]) {
                const err = new Error(`Already running: ${running[id].name} with id: ${id}`);
                hooks.emit('error', err);
            Severity: Minor
            Found in lib/agent/actions.js - About 1 hr to fix

              Function update_version_attempt has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              package.update_version_attempt = (old_version, new_version, attempt_plus, set_notified, error, cb) => {
                var create_version = function(version, cb) {
                  // Before creating the registry the table it's cleared
                  storage.do('clear', {type: 'versions'}, (err) => {
                    if (err) return cb(new Error("Unable to edit local database, update cancelled"));
              Severity: Minor
              Found in lib/package.js - About 1 hr to fix

                Function get_tree has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                module.exports.get_tree = function(options, cb) {
                
                  var dir = options.path;
                
                  // We need to run the tree walker script personifying
                Severity: Minor
                Found in lib/agent/providers/files/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 check_and_show has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                exports.check_and_show = function(values, cb) {
                  var force      = values['-f'] === true;
                  var old_config = (values['-c'] || values['--check-file']) && values.positional[0];
                
                  var show = function() {
                Severity: Minor
                Found in lib/conf/gui/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 retryQueuedResponses has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                const retryQueuedResponses = () => {
                  if (exports.responses_queue.length === 0) return;
                
                  exports.responses_queue.forEach((respQueued) => {
                    exports.notify_action(
                Severity: Minor
                Found in lib/agent/control-panel/websockets/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 init has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                var init = function (type, path, cb) {
                  storage_path = path ? path : storage_path ? storage_path : join(config, 'commands.db');
                  backup_path = storage_path;
                  var create_db = () => {
                    db_comm = new sqlite3.Database(storage_path, function (err) {
                Severity: Minor
                Found in lib/agent/utils/storage.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_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 reconnect has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  exports.reconnect = function(done) {
                  
                    var network_service,
                        airport_name = '',
                        providers    = require('./../../agent/providers');
                  Severity: Minor
                  Found in lib/system/mac/airport.js - About 1 hr to fix

                    Function check_zones has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    var check_zones = function() {
                      if (!location || checking) return;
                      checking = true;
                    
                      zones.forEach(function (zone) {
                    Severity: Minor
                    Found in lib/agent/triggers/control-zones/index.js - About 1 hr to fix

                      Function get_status has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      exports.get_status = (cb) => {
                        if (exports.status) {
                          return cb(null, exports.status);
                        }
                        if (!timeoutGetStatus) {
                      Severity: Minor
                      Found in lib/agent/triggers/status/index.js - About 1 hr to fix

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

                        exports.start = function(opts, cb) {
                          hooks.on('geofencing_start', function(fences) {
                            if (!fences) return;
                        
                            zones = fences;
                        Severity: Minor
                        Found in lib/agent/triggers/control-zones/index.js - About 1 hr to fix

                          Function retrieve_file_as_user has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const retrieve_file_as_user = function (options, cb) {
                            if (os_name == 'windows') {
                              path_arg = path.resolve(options.path);
                              name_arg = path.resolve(options.name);
                            } else {
                          Severity: Minor
                          Found in lib/agent/actions/fileretrieval/index.js - About 1 hr to fix

                            Function run has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const run = () => {
                              if (running) return;
                              running = true;
                            
                              // eslint-disable-next-line consistent-return
                            Severity: Minor
                            Found in lib/agent/index.js - About 1 hr to fix

                              Function init has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              var init = function (type, path, cb) {
                                storage_path = path ? path : storage_path ? storage_path : join(config, 'commands.db');
                                backup_path = storage_path;
                                var create_db = () => {
                                  db_comm = new sqlite3.Database(storage_path, function (err) {
                              Severity: Minor
                              Found in lib/agent/utils/storage.js - About 1 hr 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

                                Severity
                                Category
                                Status
                                Source
                                Language