GladysProject/Gladys

View on GitHub

Showing 754 of 2,690 total issues

Function loadDevices has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

async function loadDevices() {
  let listDevices = [];

  if (this.configuration.energyApi || (!this.configuration.energyApi && !this.configuration.weatherApi)) {
    try {
Severity: Minor
Found in server/services/netatmo/lib/netatmo.loadDevices.js - About 4 hrs 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 syncUserCalendars has 102 lines of code (exceeds 25 allowed). Consider refactoring.
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);
Severity: Major
Found in server/services/caldav/lib/calendar/calendar.syncUserCalendars.js - About 4 hrs to fix

    Function createActions has 102 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function createActions(store) {
      const houseActions = createActionsHouse(store);
      const integrationActions = createActionsIntegration(store);
      const actions = {
        async getXiaomiSensors(state) {
    Severity: Major
    Found in front/src/routes/integration/all/xiaomi/actions.js - About 4 hrs to fix

      Function render has 102 lines of code (exceeds 25 allowed). Consider refactoring.
      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;

        Function createActions has 101 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function createActions(store) {
          const integrationActions = createActionsIntegration(store);
          const actions = {
            async getHouses(state) {
              store.setState({
        Severity: Major
        Found in front/src/routes/integration/all/broadlink/device-page/actions.js - About 4 hrs to fix

          File ScheduledTrigger.jsx has 333 lines of code (exceeds 250 allowed). Consider refactoring.
          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';
          Severity: Minor
          Found in front/src/routes/scene/edit-scene/triggers/ScheduledTrigger.jsx - About 4 hrs to fix

            File Feature.jsx has 332 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { Text, Localizer, MarkupText } from 'preact-i18n';
            import { Component } from 'preact';
            import {
              DEVICE_FEATURE_UNITS_BY_CATEGORY,
              DEVICE_FEATURE_CATEGORIES
            Severity: Minor
            Found in front/src/routes/integration/all/mqtt/device-page/setup/Feature.jsx - About 4 hrs to fix

              Function up has 99 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                up: async (queryInterface, Sequelize) => {
                  await queryInterface.createTable('t_user', {
                    id: {
                      allowNull: false,
                      primaryKey: true,
              Severity: Major
              Found in server/migrations/20190205063641-create-user.js - About 3 hrs to fix

                File consts.js has 331 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { DEVICE_FEATURE_CATEGORIES, DEVICE_FEATURE_TYPES } from '../../../server/utils/constants';
                
                export const LoginStatus = {
                  Processing: 'Processing',
                  WrongCredentialsError: 'WrongCredentialsError',
                Severity: Minor
                Found in front/src/utils/consts.js - About 3 hrs to fix

                  Function newValueDuplexWirelessSwitch has 98 lines of code (exceeds 25 allowed). Consider refactoring.
                  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

                      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

                      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
                      Severity: Major
                      Found in server/lib/scene/scene.checkCalendarTriggers.js - About 3 hrs to fix

                        Function get has 97 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        async function get(options) {
                          const optionsWithDefault = { ...DEFAULT_OPTIONS, ...options };
                        
                          const queryParams = {
                            include: [
                        Severity: Major
                        Found in server/lib/device/device.get.js - About 3 hrs to fix

                          Function updateNAMain has 96 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          async function updateNAMain(deviceGladys, deviceNetatmo, externalId) {
                            const { room, dashboard_data: dashboardData } = deviceNetatmo;
                            try {
                              deviceGladys.features
                                .filter((feature) => feature.external_id === `${externalId}:temperature`)
                          Severity: Major
                          Found in server/services/netatmo/lib/update/netatmo.updateNAMain.js - About 3 hrs to fix

                            Function render has 96 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              render(props) {
                                let alertMessage = null;
                            
                                const { connectMqttStatus, mqttConnected, mqttConnectionError } = props;
                                switch (connectMqttStatus) {
                            Severity: Major
                            Found in front/src/routes/integration/all/mqtt/setup-page/SetupTab.jsx - About 3 hrs to fix

                              Function saveStatus has 95 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function saveStatus(status) {
                                logger.debug('Changing status Netatmo ...');
                                try {
                                  switch (status.statusType) {
                                    case STATUS.ERROR.CONNECTING:
                              Severity: Major
                              Found in server/services/netatmo/lib/netatmo.saveStatus.js - About 3 hrs to fix

                                Function create has 95 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                async function create(device) {
                                  // separate object
                                  const features = device.features || [];
                                  const params = device.params || [];
                                  delete device.features;
                                Severity: Major
                                Found in server/lib/device/device.create.js - About 3 hrs to fix

                                  Function render has 95 lines of code (exceeds 25 allowed). Consider refactoring.
                                  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>
                                  Severity: Major
                                  Found in front/src/routes/integration/all/broadlink/device-page/DeviceBox.jsx - About 3 hrs to fix

                                    Function exports has 94 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    module.exports = (sequelize, DataTypes) => {
                                      const calendar = sequelize.define(
                                        't_calendar',
                                        {
                                          id: {
                                    Severity: Major
                                    Found in server/models/calendar.js - About 3 hrs to fix

                                      Function createActions has 94 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                      function createActions(store) {
                                        const actionsProfilePicture = createActionsProfilePicture(store);
                                      
                                        const actions = {
                                          handleRoute(state, e) {
                                      Severity: Major
                                      Found in front/src/actions/main.js - About 3 hrs to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language