Showing 312 of 527 total issues
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, target, locals = false) {
Object.keys(values).forEach((key) => {
- Read upRead up
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;
- Read upRead up
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 = [];
- Read upRead up
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) {
- Read upRead up
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);
- Read upRead up
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 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';
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) {
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);
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;
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) {
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));
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) {
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) >= timeLimitPerMessage) {
Function return_status
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function return_status(err, res) {
function disconnected(err) {
logger.debug('Device cannot connect to host');
if (err) {
logger.error(`Connection error: ${err}`);
Function exports
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function(cmd, opts, cb) {
var out = '',
err = '',
args = Array.isArray(cmd) ? cmd : cmd.split(' '),
bin = args.shift();
Function versionPromise
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
const versionPromise = new Promise((resolve, reject) => {
exec(exports.cmdExistInstallPreyUser, (_parentError, parentStdout) => {
if (parentStdout && parentStdout.trim() !== '') {
exec(exports.cmdInstallPreyUserVersion, (error, preyUserVersionInstall) => {
if (error) {
Function get_outbound_connections_list
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.get_outbound_connections_list = function(callback) {
var connections = [],
command = 'netstat -ano';
Function try_connecting_to
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.try_connecting_to = function(list, cb) {
var array = [];
list.forEach(function(ap) {
array.push(
function(callback) {
Function create_server
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
var create_server = (cb) => {
os_name = os.platform().replace('darwin', 'mac').replace('win32', 'windows');
if (os_name == 'linux') return cb(new Error('Service only available for mac and windows'));
check_service((valid) => {
Function find_logged_user
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.find_logged_user = function(callback) {
var done = function(err, stdout) {
if (err) {
if (typeof callback !== 'function')
return;