prey/prey-node-client

View on GitHub

Showing 312 of 527 total issues

Function pre_uninstall has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

exports.pre_uninstall = (values, cb) => {
  const argument = values['-u'] && values.positional[0];
  const updating = argument == 'true' || parseInt(argument) === 1;

  const tasks = [daemon.remove, osHooks.pre_uninstall];
Severity: Minor
Found in lib/conf/tasks/index.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 all has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

storage_fns.all = (opts, cb) => {
  init(opts.type, null, (err, db) => {
    if (err) return cb(err);
    db_comm.all(queries.SELECT(opts.type), function (err, rows) {
      if (err) {
Severity: Minor
Found in lib/agent/utils/storage.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 add_label has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def add_label(self, text, font_name, font_size, x, y, width, height):
Severity: Major
Found in lib/agent/actions/alert/darwin/flash.py - About 50 mins to fix

    Avoid deeply nested control flow statements.
    Open

                if (a) {
                  analyze(a, options.slice(parseInt(i) + 1));
                  break;
    
                } else { 
    Severity: Major
    Found in lib/conf/utils/operetta.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if (!stdoutsiBattery || !stdoutsiBattery.hasBattery) {
                            data.device_type = 'Desktop';
                            callback(null, data);
                          } else {
                            data.device_type = 'Laptop';
      Severity: Major
      Found in lib/agent/providers/hardware/windows.js - About 45 mins to fix

        Function get_battery_status has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        exports.get_battery_status = function(callback){
        
          exec('pmset -g batt', function(err, stdout){
            if (err) return callback(err);
        
        
        Severity: Minor
        Found in lib/agent/providers/indicators/mac.js - About 45 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 notify_action has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        exports.notify_action = function (status, id, name, opts, err, out) {
        Severity: Minor
        Found in lib/agent/control-panel/sender.js - About 45 mins to fix

          Function install has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          exports.install = function (cb) {
            var next = function (err) {
              // EBUSY error is when file is being run. that shouldn't happen normally
              // but for the purposes of setting up the daemon, it doesn't really matter.
              if (err && err.code !== 'EBUSY') return cb(err);
          Severity: Minor
          Found in lib/conf/tasks/daemon.js - About 45 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 as has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          function as(user_type, type, bin, args, opts, cb) {
          Severity: Minor
          Found in lib/system/index.js - About 45 mins to fix

            Function accessPointsFn has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            const accessPointsFn = (cmd, args, cb) => {
              if (common.os_release >= '12.0') {
                sudo(cmd, args, (err, stdout, stderr) => {
                  if (stderr) logger.error(stderr);
                  return cb(err, stdout);
            Severity: Minor
            Found in lib/agent/providers/network/mac.js - About 45 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

            Avoid deeply nested control flow statements.
            Open

                              if (errSetting) logger.error(`Error while setting shouldPreyCFile: ${errSetting}`);
            Severity: Major
            Found in lib/utils/configfile.js - About 45 mins to fix

              Function post_missing has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              exports.post_missing = (opt, cb) => {
                if (!keys.get().api || !keys.get().device)
                  return cb(errors.get('MISSING_KEY'));
              
                if (opt == null || typeof opt != 'boolean')
              Severity: Minor
              Found in lib/agent/control-panel/api/devices.js - About 45 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 send has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              const send = function (attempt, method, path, data, options, cb) {
              Severity: Minor
              Found in lib/agent/control-panel/api/request.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            if (match) {
                              const value = match[1];
                              const matchValue = reqPreyConf[count].possiblevalues.exec(value);
                              if (matchValue) {
                                preyConfData[reqPreyConf[count].name] = value;
                Severity: Major
                Found in lib/agent/utils/prey-configuration/preyconf.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                              if (preyConfDataToWrite) {
                                dataToInsert = preyConfDataToWrite[reqPreyConf[count].name] ? preyConfDataToWrite[reqPreyConf[count].name] : '';
                              } else {
                                dataToInsert = reqPreyConf[count].default
                                || ((typeof reqPreyConf[count].default === 'boolean') && reqPreyConf[count].default === false) ? reqPreyConf[count].default : '';
                  Severity: Major
                  Found in lib/agent/utils/prey-configuration/preyconf.js - About 45 mins to fix

                    Function validate_new_user_fields has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      def validate_new_user_fields(self, name, email, terms, age, passwd, passwd2 = None):
                    Severity: Minor
                    Found in lib/conf/gui/mac/PreyConfig.app/Contents/MacOS/prey-config.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                  if (line.match(reqPreyConf[count].value)) {
                                    if (reqPreyConf[count].word === 'api_key') {
                                      apiKeyValue = true;
                                    } else if (reqPreyConf[count].word === 'device_key') {
                                      deviceKeyValue = true;
                      Severity: Major
                      Found in lib/agent/utils/prey-configuration/preyconf.js - About 45 mins to fix

                        Function reactToCheckLocationPerms has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                        const reactToCheckLocationPerms = (data) => {
                          permissionFile.setData('nativeLocation', data[1].result, () => {
                            network.isWifiPermissionActive((output) => {
                              permissionFile.setData('wifiLocation', stringBooleanOrEmpty(output), () => {
                                // eslint-disable-next-line max-len
                        Severity: Minor
                        Found in lib/agent/socket/listeners.js - About 45 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 drawImage has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                          def drawImage(self, file, width, height, x, y, view):
                        Severity: Minor
                        Found in lib/conf/gui/mac/PreyConfig.app/Contents/MacOS/prey-config.py - About 45 mins to fix

                          Function requestNativePermission has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const requestNativePermission = (cb) => {
                            if (osName.localeCompare('mac') !== 0) return cb(new Error('Action only allowed on MacOS'));
                            // eslint-disable-next-line consistent-return
                            socket.writeMessage(permissionFunction, () => {
                              const permissionNative = permissionFile.getData('nativeLocation');
                          Severity: Minor
                          Found in lib/agent/actions/request_permission/index.js - About 45 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

                          Severity
                          Category
                          Status
                          Source
                          Language