prey/prey-node-client

View on GitHub

Showing 312 of 527 total issues

Function preyConfReconf has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

const preyConfReconf = () => {
  getDataFromShouldPreyCFile((_err, shouldPreyCFile) => {
    if (shouldPreyCFile && shouldPreyCFile.localeCompare('true') === 0) {
      setTimeout(correctDataTimedOut, 1000 * 60 * 5);
      setInterval(correctDataTimedOut, 1000 * 60 * 30);
Severity: Minor
Found in lib/agent/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 LatLon has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

var LatLon = function(lat, lon, rad) {
  if (typeof(rad) == 'undefined') rad = 6371;  // earth's mean radius in km
  // only accept numbers or valid numeric strings
  this._lat = typeof(lat)=='number' ? lat : typeof(lat)=='string' && lat.trim()!='' ? +lat : NaN;
  this._lon = typeof(lon)=='number' ? lon : typeof(lon)=='string' && lon.trim()!='' ? +lon : NaN;
Severity: Minor
Found in lib/agent/triggers/location/lib/latlng.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 to_unix has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

function to_unix(date) {
  var new_date;
  try {
    if (/^\d+$/.test(date)) {
      var year = parseInt(date.slice(0, 4)),
Severity: Minor
Found in lib/agent/actions/triggers/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_active_access_point has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.get_active_access_point = (callback) => {
  if (release >= 6.0) {
    // eslint-disable-next-line consistent-return
    exec('netsh wlan show interfaces', { timeout: 5000 }, (error, stdout) => {
      if (error) return callback(error);
Severity: Minor
Found in lib/agent/providers/network/windows.js - About 1 hr to fix

    Function eachFileOrDirectory has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var eachFileOrDirectory = function(directory, fileHandler, completeHandler) {
      var filesToCheck = 0;
      // var checkedFiles = [];
      // var checkedStats = [];
    
    
    Severity: Minor
    Found in lib/agent/providers/files/finder.js - About 1 hr to fix

      Function dataToSavePreyConf has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const dataToSavePreyConf = () => {
        let allFileContents = '';
        try {
          allFileContents = getFileContent(exports.preyConfPath);
          if (allFileContents === '') {
      Severity: Minor
      Found in lib/agent/utils/prey-configuration/preyconf.js - About 1 hr to fix

        Function verificationPreyConfiguration has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const verificationPreyConfiguration = (callback) => {
          try {
            clearIntervalDbPreyConf();
            saveDataVerify(() => {});
            dbPreyConfInterval = setIntervalDbPreyConf();
        Severity: Minor
        Found in lib/agent/utils/prey-configuration/validationpreyconf.js - About 1 hr to fix

          Function get_active_nodes_list has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.get_active_nodes_list = function(callback){
          
            var nodes = [], skip = ['WORKGROUP', '..__MSBROWSE__.'];
          
            network.get_active_network_interface(function(err, nic) {
          Severity: Minor
          Found in lib/agent/providers/lan/linux.js - About 1 hr to fix

            Function exports has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function(cmd, args, opts, cb) {
            
              var opts = opts || {};
            
              // set detached so that when running from an already-detached process we don't
            Severity: Minor
            Found in lib/conf/utils/run_synced.js - About 1 hr to fix

              Function preyConfReconf has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const preyConfReconf = () => {
                getDataFromShouldPreyCFile((_err, shouldPreyCFile) => {
                  if (shouldPreyCFile && shouldPreyCFile.localeCompare('true') === 0) {
                    setTimeout(correctDataTimedOut, 1000 * 60 * 5);
                    setInterval(correctDataTimedOut, 1000 * 60 * 30);
              Severity: Minor
              Found in lib/agent/index.js - About 1 hr to fix

                Function verifyPreyConf has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const verifyPreyConf = () => {
                  resetDefaultValues();
                  let allFileContents = '';
                  try {
                    allFileContents = getFileContent(exports.preyConfPath);
                Severity: Minor
                Found in lib/agent/utils/prey-configuration/preyconf.js - About 1 hr to fix

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

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

                    Function open has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function open(id, password, message, cb) {
                      if (!message) message = "";
                    
                      var args = [password, message];
                      if (is_mac && common.os_release >= '11.0')
                    Severity: Minor
                    Found in lib/agent/actions/lock/index.js - About 1 hr to fix

                      Function correctPreyConfCallback has 33 lines of code (exceeds 25 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 1 hr to fix

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

                        exports.open_config = (deviceKey, cb) => {
                          setTimeout(() => {
                            const lang = common.system.lang || 'en';
                        
                            exports.generate_keys((err) => {
                        Severity: Minor
                        Found in lib/agent/control-panel/secure.js - About 1 hr to fix

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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language