Showing 754 of 2,690 total issues
Avoid too many return
statements within this function. Open
return Math.round(((lastValue - firstValue) / Math.abs(firstValue)) * 100);
Avoid too many return
statements within this function. Open
return 'purple';
Avoid too many return
statements within this function. Open
return 'danger';
Function mergeDevices
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function mergeDevices(newDevice, existingDevice, updateAttribute = 'updatable') {
// No existing device
if (!existingDevice) {
return newDevice;
}
- 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 exports
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
module.exports = (sequelize, DataTypes) => {
const User = sequelize.define(
't_user',
{
id: {
- 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 RoomController
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function RoomController(gladys) {
/**
* @api {post} /api/v1/house/:house_selector/room create
* @apiName create
* @apiGroup Room
- 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 scan
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function scan(options) {
const { singleAddress, firstAddress, lastAddress, username, password } = options;
if (singleAddress) {
logger.debug(`Tasmota: HTTP looking for ${singleAddress}`);
this.status(singleAddress, username, password);
- 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 recursiveSearch
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const recursiveSearch = (message, callback, key = undefined) => {
Object.keys(message).forEach((subKey) => {
const currentObj = message[subKey];
const fullKey = `${key ? `${key}.` : ''}${subKey}`;
- 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 updateValues
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
async function updateValues(deviceGladys, deviceNetatmo, externalId) {
const [prefix, topic] = externalId.split(':');
const { reachable } = deviceNetatmo;
if (prefix !== 'netatmo') {
throw new BadParameters(`Netatmo device external_id is invalid: "${externalId}" should starts with "netatmo:"`);
- 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 saveConfiguration
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
async function saveConfiguration(configuration = {}) {
const { presenceScanner = {} } = configuration;
// Check and store presence scanner frequency
if (presenceScanner.frequency !== undefined) {
- 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 buildAccessory
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function buildAccessory(device) {
const categories = device.features.reduce((previousValue, currentValue) => {
if (!mappings[currentValue.category] || !mappings[currentValue.category].capabilities[currentValue.type]) {
return {
...previousValue,
- 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 connect
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
async function connect() {
this.configured = false;
this.connected = false;
const email = await this.gladys.variable.getValue(EWELINK_EMAIL_KEY, this.serviceId);
- 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 readValue
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
readValue: (expose, value) => {
const { [expose.name]: mapping = {} } = names;
const reversed = mapping.reversedValue || false;
switch (value) {
- 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 discoverDevices
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
async function discoverDevices() {
logger.debug('Looking for Netatmo devices...');
if (this.status !== STATUS.CONNECTED) {
await this.saveStatus({ statusType: this.status, message: null });
throw new ServiceNotConfiguredError('Unable to discover Netatmo devices until service is not well configured');
- 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 checkForContainerUpdates
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
async function checkForContainerUpdates(config) {
logger.info('Checking for current installed versions and required updates...');
// Check for MQTT container version
if (config.dockerMqttVersion !== DEFAULT.DOCKER_MQTT_VERSION) {
- 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 recursiveSearch
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const recursiveSearch = (expose, type, search) => {
const { property, features = [] } = expose;
if (property === search) {
return expose;
}
- 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 config
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
async function config(userId) {
const CALDAV_URL = await this.gladys.variable.getValue('CALDAV_URL', this.serviceId, userId);
const CALDAV_USERNAME = await this.gladys.variable.getValue('CALDAV_USERNAME', this.serviceId, userId);
const CALDAV_PASSWORD = await this.gladys.variable.getValue('CALDAV_PASSWORD', this.serviceId, userId);
- 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 loadDeviceDetails
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
async function loadDeviceDetails(homeData) {
const { rooms: roomsHomeData, modules: modulesHomeData, id: homeId } = homeData;
let listDevices = [];
logger.debug('loading devices details in home id: ', homeId, '...');
- 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 setValue
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
async function setValue(device, deviceFeature, value) {
const deviceUuid = device.external_id.split(':')[1];
const sonosDevice = this.manager.Devices.find((d) => d.uuid === deviceUuid);
if (deviceFeature.type === DEVICE_FEATURE_TYPES.MUSIC.PLAY) {
await sonosDevice.Play();
- 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 notifyChange
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function notifyChange(accessories, event) {
if (event.type !== EVENTS.DEVICE.NEW_STATE) {
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"