prey/prey-node-client

View on GitHub

Showing 312 of 527 total issues

Avoid too many return statements within this function.
Open

      return False
Severity: Major
Found in lib/conf/gui/linux/prey-config.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

          return False
    Severity: Major
    Found in lib/conf/gui/mac/PreyConfig.app/Contents/MacOS/prey-config.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return False
      Severity: Major
      Found in lib/conf/gui/linux/prey-config3.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return True
        Severity: Major
        Found in lib/conf/gui/linux/prey-config3.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return False
          Severity: Major
          Found in lib/conf/gui/linux/prey-config3.py - About 30 mins to fix

            Function get_admin_user has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            system.get_admin_user = remember((cb) => {
              system.find_admin_user((e, user) => {
                if (e || !user || user.trim() == '') {
                  const err = new Error('No admin user detected.');
                  if (e) err.message += ` ${e.message}`;
            Severity: Minor
            Found in lib/system/index.js - About 25 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 startWebsocket has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.startWebsocket = () => {
              clearAndResetIntervals();
              notifyActionInterval = setInterval(retryQueuedResponses, 5000); // <-revisar el tiempo
              notifyAckInterval = setInterval(retryAckResponses, 4 * 1000);
              getStatusInterval = setInterval(getStatusByInterval, 5 * 60 * 1000);
            Severity: Minor
            Found in lib/agent/control-panel/websockets/index.js - About 25 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 watch_stopped has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            var watch_stopped = function () {
              if (!watching) return;
            
              hooks.on('action', function (event, id) {
                if (event == 'stopped' || event == 'failed') {
            Severity: Minor
            Found in lib/agent/commands.js - About 25 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 retrieve_old_keys has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.retrieve_old_keys = function (file, cb) {
              log(`Reading config keys from file: ${file}`);
            
              fs.readFile(file, (err, data) => {
                if (err) {
            Severity: Minor
            Found in lib/conf/shared/keys.js - About 25 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_logged_user has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            system.get_logged_user = (cb) => {
              system.find_logged_user((e, user) => {
                if (e || !user || user.trim() == '') {
                  const err = new Error('No logged user detected.');
                  if (e) err.message += ` ${e.message}`;
            Severity: Minor
            Found in lib/system/index.js - About 25 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 set_current has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            versions.set_current = function (version, cb) {
              if (!paths.versions)
                return cb();
            
              if (version == 'latest')
            Severity: Minor
            Found in lib/conf/shared/version_manager.js - About 25 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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.update = function (values, cb) {
              const key = values.positional[0];
              const val = values.positional[1];
              const dataFromName = reqPreyConf.filter((item) => item.name === key);
              const dataToSave = (val.toLowerCase() === 'true' || val.toLowerCase() === 'false') ? isBoolean(val) : val;
            Severity: Minor
            Found in lib/conf/settings.js - About 25 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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            const send = function (what, data, opts, cb) {
              var opts = opts || {};
            
              const done = function (err, resp) {
                const str = err ? `Got error: ${err.message}` : `Got ${resp.statusCode} response: ${resp.body}`;
            Severity: Minor
            Found in lib/agent/control-panel/sender.js - About 25 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_stable_version_winsvc has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.get_stable_version_winsvc = function (cb) {
              config.load(() => {
                const releases_host = fetchEnvVar('prey_host_releases') ? fetchEnvVar('prey_host_releases') : 'https://downloads.preyproject.com';
                const releases_url = `${releases_host}/prey-client-releases/winsvc/`;
                const latest_text = 'latest.txt';
            Severity: Minor
            Found in lib/agent/updater.js - About 25 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_screenshot has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.get_screenshot = (callback) => {
              // eslint-disable-next-line consistent-return
              osFunctions.get_screenshot((err, filePath, fileType) => {
                if (err) return callback(err);
            
            
            Severity: Minor
            Found in lib/agent/providers/screenshot/index.js - About 25 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 setEmpty has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.setEmpty = function (values, cb) {
              const key = values.key;
              if (key === 'control-panel') return cb(new Error(`${key} is not able to be empty.`));
              const expReg = /.*/;
              const dataFromName = reqPreyConf.filter((item) => item.name === key);
            Severity: Minor
            Found in lib/conf/settings.js - About 25 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_firmware_info has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            exports.get_firmware_info = function(callback) {
            
              get_system_profiler_data('SPHardwareDataType', function(err, sp_data){
                if (err) return callback(err);
            
            
            Severity: Minor
            Found in lib/agent/providers/hardware/mac.js - About 25 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 a Cognitive Complexity of 6 (exceeds 5 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 25 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 start has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            function start(id, opts, cb) {
              var opts     = opts || {},
                  password = opts.password || opts.unlock_pass || default_pass,
                  message  = opts.lock_message || "";
            
            
            Severity: Minor
            Found in lib/agent/actions/lock/index.js - About 25 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 writeMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            const writeMessage = (functionName, cb) => {
              if (osName !== 'mac') {
                if (typeof cb === 'function') return cb();
                // eslint-disable-next-line consistent-return
                return;
            Severity: Minor
            Found in lib/agent/socket/index.js - About 25 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