prey/prey-node-client

View on GitHub

Showing 551 of 551 total issues

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

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 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

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

      const getLocation = (cb) => {
        // eslint-disable-next-line consistent-return
        system.get_os_version((_err, version) => {
          if (version && greaterOrEqual(version, '10.6.0')) {
            socket.writeMessage(nameArray[0], (err, data) => {
      Severity: Minor
      Found in lib/agent/providers/geo/darwin/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

      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

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

        exports.start = (id, opts, cb) => {
          const done = (err = null) => {
            if (err) return cb(err);
            if (!emitter) emitter = new Emitter();
            cb(err, emitter);
        Severity: Minor
        Found in lib/agent/actions/osquery/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

        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

        Avoid deeply nested control flow statements.
        Open

                      if (reqPreyConf[count].possiblevalues) {
                        if (reqPreyConf[count].value && !reqPreyConf[count].value.test(line)) {
                          somethingWrong = true;
                          dataToFix[reqPreyConf[count].name] = false;
                        }
        Severity: Major
        Found in lib/agent/utils/prey-configuration/preyconf.js - About 45 mins to fix

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

          exports.sync = (success, id, err, triggersSync, storedSync, cb) => {
            let triggers = [...triggersSync];
            const stored = [...storedSync];
            const watching = [];
          
          
          Severity: Minor
          Found in lib/agent/actions/triggers/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

          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(nameArray[1], () => {
              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

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

          const linkDevice = (cb) => {
            getDeviceData((err, deviceData) => {
              const data = deviceData;
              if (err) return cb(err);
          
          
          Severity: Minor
          Found in lib/agent/control-panel/setup.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 (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

            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

              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

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

                exports.start = function (opts, cb) {
                  hooks.on('connected', () => {
                    network.get_active_access_point((err, ap) => {
                      if (was_disconnected) {
                        logger.info(`Connection achieved! ${ap ? ap.ssid || '' : ''}`);
                Severity: Minor
                Found in lib/agent/triggers/auto-connect/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

                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 start has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  exports.start = (opts, cb) => {
                    hooks.on('mac_address_changed', () => {
                      fetchLocation('mac-address');
                    });
                  
                  
                  Severity: Minor
                  Found in lib/agent/triggers/location/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

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

                      def __init__(self):
                  
                          button_text = "Close"
                          title = args.title
                  
                  
                  Severity: Minor
                  Found in lib/agent/actions/alert/linux/flash3.py - 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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                    var cpu_info = {
                      model: cpus[0].model.trim(),
                      speed: cpus[0].speed,
                      cores: cpus.length
                    };
                  Severity: Minor
                  Found in lib/system/mac/index.js and 1 other location - About 45 mins to fix
                  lib/agent/providers/hardware/index.js on lines 17..21

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 50.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language