Showing 742 of 2,674 total issues
Function loadDevices
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
Open
async function loadDevices() {
let listDevices = [];
if (this.configuration.energyApi || (!this.configuration.energyApi && !this.configuration.weatherApi)) {
try {
- 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 syncUserCalendars
has 102 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function syncUserCalendars(userId) {
const CALDAV_HOST = await this.gladys.variable.getValue('CALDAV_HOST', this.serviceId, userId);
const CALDAV_HOME_URL = await this.gladys.variable.getValue('CALDAV_HOME_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);
Function createActions
has 102 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function createActions(store) {
const houseActions = createActionsHouse(store);
const integrationActions = createActionsIntegration(store);
const actions = {
async getXiaomiSensors(state) {
Function render
has 102 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render({ peripheral, housesWithRooms = [] }) {
const { device, connectable, name, mac, address, model } = peripheral;
const editable = connectable && !!device && !device.created_at;
const alreadyCreated = connectable && !!device && !!device.created_at;
const remotePeripheral = connectable && !device;
File index.js
has 336 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { Component } from 'preact';
import { connect } from 'unistore/preact';
import { route } from 'preact-router';
import update from 'immutability-helper';
import EditDashboardPage from './EditDashboard';
Function createActions
has 101 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function createActions(store) {
const integrationActions = createActionsIntegration(store);
const actions = {
async getHouses(state) {
store.setState({
File ScheduledTrigger.jsx
has 333 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { Component } from 'preact';
import { connect } from 'unistore/preact';
import DatePicker from 'react-datepicker';
import get from 'get-value';
import { Text, Localizer } from 'preact-i18n';
Function up
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('t_user', {
id: {
allowNull: false,
primaryKey: true,
Function newValueDuplexWirelessSwitch
has 98 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function newValueDuplexWirelessSwitch(message, data) {
const { sid } = message;
logger.debug(`Xiaomi : New value duplex wireless switch, sid = ${sid}`);
const EXTERNAL_ID_CHANNEL_0_BUTTON = `xiaomi:${sid}:duplex-wireless-switch:channel-0:button`;
const EXTERNAL_ID_CHANNEL_1_BUTTON = `xiaomi:${sid}:duplex-wireless-switch:channel-1:button`;
Function render
has 98 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render({ device, houses }, { loading, tooMuchStatesError, statesNumber }) {
const manufacturer = device.params.find(param => param.name === PARAMS.MANUFACTURER);
const macAddress = device.params.find(param => param.name === PARAMS.MAC);
const orginalName = device.params.find(param => param.name === PARAMS.NAME);
Function checkCalendarTriggers
has 97 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function checkCalendarTriggers() {
// getting a fixed value for now, as soon as possible in the function
const now = dayjs.tz(dayjs(), this.timezone);
logger.info(`Checking calendar triggers at ${now}`);
// First, we try to constitute a list of triggers
Function get
has 97 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function get(options) {
const optionsWithDefault = { ...DEFAULT_OPTIONS, ...options };
const queryParams = {
include: [
File consts.js
has 328 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { DEVICE_FEATURE_CATEGORIES, DEVICE_FEATURE_TYPES } from '../../../server/utils/constants';
export const LoginStatus = {
Processing: 'Processing',
WrongCredentialsError: 'WrongCredentialsError',
Function updateNAMain
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function updateNAMain(deviceGladys, deviceNetatmo, externalId) {
const { room, dashboard_data: dashboardData } = deviceNetatmo;
try {
deviceGladys.features
.filter((feature) => feature.external_id === `${externalId}:temperature`)
Function render
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render(props) {
let alertMessage = null;
const { connectMqttStatus, mqttConnected, mqttConnectionError } = props;
switch (connectMqttStatus) {
Function saveStatus
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function saveStatus(status) {
logger.debug('Changing status Netatmo ...');
try {
switch (status.statusType) {
case STATUS.ERROR.CONNECTING:
Function render
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render({ deviceIndex, device, housesWithRooms = [] }, { loading, saveError, tooMuchStatesError, statesNumber }) {
return (
<div class="col-md-6">
<div class="card" data-cy="device-card">
<div class="card-header">{device.name}</div>
Function exports
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = (sequelize, DataTypes) => {
const calendar = sequelize.define(
't_calendar',
{
id: {
Function createActions
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function createActions(store) {
const actionsProfilePicture = createActionsProfilePicture(store);
const actions = {
handleRoute(state, e) {
Function newValuePlug
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function newValuePlug(message, data) {
const { sid } = message;
logger.debug(`Xiaomi : New value plug, sid = ${sid}`);
const newSensor = {
service_id: this.serviceId,