prey/prey-node-client

View on GitHub

Showing 323 of 551 total issues

Function send has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.send = (err, cb) => {
  const { release } = require('os');
  const { version } = require('./common');
  const keys = require('./agent/control-panel/api/keys');
  // prevent exceptions from being sent when running tests
Severity: Minor
Found in lib/exceptions.js - About 1 hr to fix

    Function get_ram_module_list has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.get_ram_module_list = (cb) => {
      const list = [];
      if (system.is_m1_or_m2()) {
        si.mem((stdoutsi) => {
          list.push({
    Severity: Minor
    Found in lib/agent/providers/hardware/mac.js - About 1 hr to fix

      Function trap_signals has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function trap_signals() {
        process.on('exit', (code) => {
          shutdown(code);
        });
      
      
      Severity: Minor
      Found in lib/agent/cli.js - About 1 hr to fix

        Function getDeviceData has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const getDeviceData = (callback) => {
          let e;
          let count = 3;
          const data = {};
          const done = (err, newData) => {
        Severity: Minor
        Found in lib/agent/control-panel/setup.js - About 1 hr to fix

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

          const gather = (what, cb) => {
            let dirs;
            if (Array.isArray(what)) dirs = what;
            else dirs = paths[what];
          
          
          Severity: Minor
          Found in lib/agent/actions/wipe/wipe.js - About 1 hr to fix

            Function main has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def main():
              app = NSApplication.sharedApplication()
              app.activateIgnoringOtherApps_(True)
            
              # set app icon and draw menu
            Severity: Minor
            Found in lib/agent/actions/alert/darwin/flash.py - About 1 hr to fix

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

              Operetta.prototype.start = function(callback) {
                var operetta = this;
              
                // if has subcommands and none was passed, show options
                if (this.args.length == 0 && Object.keys(this.commands).length > 0)
              Severity: Minor
              Found in lib/conf/utils/operetta.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 update_settings has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              const update_settings = (obj) => {
                logger.debug('Syncing settings.');
              
                function process(values, locals = false) {
                  Object.keys(values).forEach((key) => {
              Severity: Minor
              Found in lib/agent/control-panel/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 get_access_points_list has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              exports.get_access_points_list = (callback) => {
                let cmd;
                let parser;
                let list = [];
              
              
              Severity: Minor
              Found in lib/agent/providers/network/windows.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 find_logged_user has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              exports.find_logged_user = function(callback) {
                var done = function(err, stdout) {
                  if (err) {
                    if (typeof callback !== 'function')
                      return;
              Severity: Minor
              Found in lib/system/windows/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 download_verify has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              releases.download_verify = function(version, cb) {
                if (os_name === 'mac'){
                  cp.exec('sysctl sysctl.proc_translated', (err, stdout) => {
                    if(err) {
                      download_file(version, arch, cb);
              Severity: Minor
              Found in lib/package.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 format_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              var format_data = function(data, cb) {
                var body = [],
                    attachments = [];
              
                for (var key in data) {
              Severity: Minor
              Found in lib/agent/transports/smtp/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 get_battery_status has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              exports.get_battery_status = function(callback){
              
                var cmd = 'upower --dump';
              
                exec(cmd, function(err, stdout) {
              Severity: Minor
              Found in lib/agent/providers/indicators/linux.js - About 1 hr to fix

                Function cp has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  var cp = run_as_user(opts, function(err, out) {
                    if (err) return cb(err);
                
                    try {
                      var files = JSON.parse(out);
                Severity: Minor
                Found in lib/agent/providers/files/index.js - About 1 hr to fix

                  Function fetch has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    const fetch = (key, section, value) => {
                      wmic.get_value(section, value, null, (err, resp) => {
                        let res = resp;
                        if (key === 'device_type') {
                          res = err ? 'Desktop' : 'Laptop';
                  Severity: Minor
                  Found in lib/agent/providers/hardware/windows.js - About 1 hr to fix

                    Function compareField has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      const compareField = (current, storedToCompare) => {
                        const stored = storedToCompare;
                        if (stored instanceof Array) {
                          if (!current || (current.length > stored.length)) {
                            diffCount += 1;
                    Severity: Minor
                    Found in lib/agent/providers/hardware/index.js - About 1 hr to fix

                      Function saveDataToDb has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const saveDataToDb = (dataToSave, cb) => {
                        try {
                          // eslint-disable-next-line consistent-return
                          getDataDb('preyconf', (err, stored) => {
                            if (err) {
                      Severity: Minor
                      Found in lib/agent/utils/prey-configuration/preyconf.js - About 1 hr to fix

                        Function install has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        package.install = function(zip, dest, cb) {
                        
                          if (!zip.match(/prey-(\w+)-([\d\.]+)/))
                            return cb(new Error("This doesn't look like a Prey package: " + zip));
                        
                        
                        Severity: Minor
                        Found in lib/package.js - About 1 hr to fix

                          Function tryToSendNew has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const tryToSendNew = () => {
                            // eslint-disable-next-line array-callback-return, consistent-return
                            messagesData = messagesData.reduce((acc, element) => {
                              const timeObj = element.time;
                              if (((new Date()).getTime() - timeObj) >= element.timeLimitPerMessage) {
                          Severity: Minor
                          Found in lib/agent/socket/index.js - About 1 hr to fix

                            Function getRestartsPreyconf has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const getRestartsPreyconf = (callback) => {
                              try {
                                // eslint-disable-next-line consistent-return
                                getDataDb('restarts_preyconf', (err, stored) => {
                                  if (err) {
                            Severity: Minor
                            Found in lib/agent/utils/prey-configuration/validationpreyconf.js - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language