prey/prey-node-client

View on GitHub

Showing 312 of 527 total issues

Function RemoteDesktop has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var RemoteDesktop = function(options){

    var self = this;
    var options = options || {};

Severity: Major
Found in lib/agent/actions/remote-desktop/index.js - About 2 hrs to fix

    Function start has a Cognitive Complexity of 20 (exceeds 5 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 2 hrs 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 correctPreyConfCallback has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    const correctPreyConfCallback = (callback) => {
      // eslint-disable-next-line consistent-return
      getDataDb('preyconf', (err, data) => {
        if (err || !data) {
          // eslint-disable-next-line consistent-return
    Severity: Minor
    Found in lib/agent/utils/prey-configuration/validationpreyconf.js - About 2 hrs 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 activate_event has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.activate_event = (trigger) => {
      try {
        var event_index = trigger.automation_events.findIndex(
          (obj) => events_list.indexOf(obj.type) > -1
        );
    Severity: Major
    Found in lib/agent/actions/triggers/index.js - About 2 hrs to fix

      Function get_tree has 66 lines of code (exceeds 25 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: Major
      Found in lib/agent/providers/files/index.js - About 2 hrs to fix

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

            def __init__(self):
          
              button_text = "Close"
              title = args.title
          
          
          Severity: Major
          Found in lib/agent/actions/alert/linux/flash.py - About 2 hrs to fix

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

            const needle = require('needle');
            const Emitter = require('events').EventEmitter;
            const https = require('https');
            
            const common = require('../../common');
            Severity: Minor
            Found in lib/agent/control-panel/long-polling/index.js - About 2 hrs to fix

              Function directoryTreeToObj has 61 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              var directoryTreeToObj = function(dir, current_depth, depth, done) {
                var resultsDir  = [],
                    resultsFile = [];
              
                if (os_name == 'windows') dir = dir + '\\';
              Severity: Major
              Found in lib/agent/providers/files/tree.js - About 2 hrs to fix

                Function as_user has a Cognitive Complexity of 18 (exceeds 5 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 2 hrs 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 18 (exceeds 5 allowed). Consider refactoring.
                Open

                exports.start = function(id, opts, cb) {
                  var opts    = opts || {},
                      message = opts.message || opts.alert_message,
                      title   = opts.title,
                      level   = opts.level || 'info',
                Severity: Minor
                Found in lib/agent/actions/alert/index.js - About 2 hrs 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 attach_listeners has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  function attach_listeners(request) {
                    request.on('data', function(data) {
                      logger.info("Data received!");
                
                      try {
                Severity: Major
                Found in lib/conf/long-polling.js - About 2 hrs to fix

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

                  exports.start = function(id, opts, cb) {
                    var opts    = opts || {},
                        message = opts.message || opts.alert_message,
                        title   = opts.title,
                        level   = opts.level || 'info',
                  Severity: Major
                  Found in lib/agent/actions/alert/index.js - About 2 hrs to fix

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

                    exports.start = function (id, options, cb) {
                      const url = `${UPLOAD_SERVER}?uploadID=${options.file_id}`;
                      // Make a call to get the last byte processed by the upload server
                      // in order to resume the upload from that position.
                      needle.request('get', url, null, (err, res) => {
                    Severity: Major
                    Found in lib/agent/actions/fileretrieval/index.js - About 2 hrs to fix

                      Function sync has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      exports.sync = function(id, geofences, cb) {
                        exports.watching = [];
                      
                        if(!geofences || geofences.length == 0) 
                          done(id, cb);
                      Severity: Major
                      Found in lib/agent/actions/geofencing/index.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 RemoteTerminal has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          var RemoteTerminal = function(options) {
                          
                            var self = this;
                            var options = options || {};
                          
                          
                          Severity: Major
                          Found in lib/agent/actions/remote-terminal/index.js - About 2 hrs to fix

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

                              const spawn = () => {
                                const wipeOpts = [
                                  '-token', opts.token,
                                  cloud.toString(),
                                  directories.toString(),
                            Severity: Major
                            Found in lib/agent/actions/wipe/index.js - About 2 hrs to fix

                              Function get_active_access_point has a Cognitive Complexity of 17 (exceeds 5 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 2 hrs 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 gather has a Cognitive Complexity of 17 (exceeds 5 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 2 hrs 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