Showing 323 of 551 total issues
Function track_hardware_changes
has 98 lines of code (exceeds 25 allowed). Consider refactoring. Open
exp.track_hardware_changes = (dataTrack) => {
const removeKeysFromObjectImmutable = (obj, keys) => Object.keys(obj).reduce((acc, key) => {
if (!keys.includes(key)) {
acc[key] = obj[key];
}
Function start
has 98 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.start = (id, opts, cb) => {
const osName = os.platform().replace('darwin', 'mac').replace('win32', 'windows');
if (osName !== 'windows') {
const error = new Error('Action only allowed on Windows 1O');
error.code = 3;
Function getPreyUserVersions
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
const getPreyUserVersions = (preyUserVersion, cb) => {
const successHandler = (foundVersion) => {
if (foundVersion) {
compareVersionsDaemon(foundVersion, preyUserVersion, cb);
} else {
- 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
PreyConfigurator
has 31 functions (exceeds 20 allowed). Consider refactoring. Open
class PreyConfigurator(object):
################################################
# helper functions
################################################
PreyConfigurator
has 31 functions (exceeds 20 allowed). Consider refactoring. Open
class PreyConfigurator(object):
################################################
# helper functions
################################################
Function perform
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.perform = function (command) {
if (!command) return handle_error(new Error('No command received'));
if (typeof command.options === 'string') {
try {
Function activate
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.activate = (trigger) => {
let index;
let info;
let opts;
try {
Function sendData
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
const sendData = (list, cb) => {
logger.debug('Sending AP data to location service');
if (!(list && Array.isArray(list) && list.length > 1)) return cb(new Error('No access points found.'));
list.sort((a, b) => a.signal_strength - b.signal_strength);
// eslint-disable-next-line no-bitwise
Function get_firmware_info
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.get_firmware_info = (callback) => {
let data = {};
const fetch = (key, section, value) => {
wmic.get_value(section, value, null, (err, resp) => {
let res = resp;
Function recover_db
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
var recover_db = function (db, cb) {
var get_tables = (cb) => {
db.all(queries.TABLES(), (err, data) => {
let tables = data.map((x) => x.name);
tables = tables.filter((x) => {
Function request
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
var request = function() {
var status_code,
request_start,
response_delay,
resp_timeout;
File commands.js
has 309 lines of code (exceeds 250 allowed). Consider refactoring. Open
const common = require('./common');
const hooks = require('./hooks');
const actions = require('./actions');
const triggers = require('./triggers');
const providers = require('./providers');
Function attach_listeners
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
function attach_listeners(request) {
request.on('data', (data) => {
if (Buffer.isBuffer(data)) { //
if (data.toString() == '\n' || data.toString() == '') return;
try {
Function notify_action
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
exports.notify_action = function (status, id, name, opts, err, out) {
if (name === 'geofencing' || name === 'triggers') return; // geofencing and triggers needs to send custom notification
let body = {
command: 'start',
- 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 check_battery_status
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
var check_battery_status = (first) => {
providers.get('battery_status', (err, current) => {
if (err || !emitter) 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
File windows.js
has 298 lines of code (exceeds 250 allowed). Consider refactoring. Open
const { exec } = require('child_process');
const { join } = require('path');
const wmic = require('wmic');
const si = require('systeminformation');
const system = require('../../../system/windows');
Function notify_action
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.notify_action = (status, id, action, opts, err, out, time, respId, retries = 0) => {
if (!id || id === 'report' || action === 'triggers' || action === 'geofencing') return;
if (retries >= retriesMax) {
storage.do('del', { type: 'responses', id: respId });
exports.responses_queue = exports.responses_queue.filter((x) => x.id !== respId);
File prey-config3.py
has 295 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python3
################################################
# Prey Configurator for Linux
# By Tomas Pollak
# (c) 2012-2014 - Fork Ltd. (usefork.com)
Function __init__
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
def __init__(self):
button_text = "Close"
title = args.title
Function Operetta
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Operetta = function(args, scope) {
if (args) {
this.args = args;
} else {
if (process.argv[0].match(/node(\.exe)?$/))