GladysProject/Gladys

View on GitHub

Showing 754 of 2,690 total issues

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

function createActions(store) {
  const houseActions = createActionsHouse(store);
  const actions = {
    async getZWaveDevices(state) {
      store.setState({
Severity: Major
Found in front/src/routes/integration/all/zwave/node-page/actions.js - About 3 hrs to fix

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

      render({ disabled }, { mqttMode, mqttUrl, mqttUsername, mqttPassword, showPassword }) {
        return (
          <div>
            <p>
              <Text id="integration.zigbee2mqtt.setup.modes.remote.detailsDescription" />

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

      function createActions(store) {
        const houseActions = createActionsHouse(store);
        const actions = {
          async getLANManagerDevices(state) {
            store.setState({
      Severity: Major
      Found in front/src/routes/integration/all/lan-manager/device-page/actions.js - About 3 hrs to fix

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

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

          Function newValueMotionSensor has 77 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function newValueMotionSensor(message, data) {
            const { sid } = message;
            logger.debug(`Xiaomi : New value motion sensor, sid = ${sid}`);
            const newSensor = {
              service_id: this.serviceId,
          Severity: Major
          Found in server/services/xiaomi/lib/event/xiaomi.newValueMotionSensor.js - About 3 hrs to fix

            Function updateNAModule4 has 77 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

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

              Function purgeStatesByFeatureId has 77 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              async function purgeStatesByFeatureId(deviceFeatureId, jobId) {
                logger.info(`Purging states of device feature ${deviceFeatureId}`);
              
                const numberOfDeviceFeatureStateToDelete = await db.DeviceFeatureState.count({
                  where: {
              Severity: Major
              Found in server/lib/device/device.purgeStatesByFeatureId.js - About 3 hrs to fix

                File index.js has 295 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { Component } from 'preact';
                import { connect } from 'unistore/preact';
                import { route } from 'preact-router';
                import SetupTab from './SetupTab';
                import NetatmoPage from '../NetatmoPage';
                Severity: Minor
                Found in front/src/routes/integration/all/netatmo/setup-page/index.js - About 3 hrs to fix

                  Function GatewayController has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports = function GatewayController(gladys) {
                    /**
                     * @api {get} /api/v1/gateway/status
                     * @apiName getStatus
                     * @apiGroup Gateway
                  Severity: Major
                  Found in server/api/controllers/gateway.controller.js - About 3 hrs to fix

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

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

                      Function convertDeviceEnergy has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function convertDeviceEnergy(netatmoDevice) {
                        const { home, name, type: model, room = {}, plug = {} } = netatmoDevice;
                        const id = netatmoDevice.id || netatmoDevice._id;
                        const homeId = home || netatmoDevice.home_id;
                        const nameDevice = name || netatmoDevice.module_name;
                      Severity: Major
                      Found in server/services/netatmo/lib/device/netatmo.convertDeviceEnergy.js - About 3 hrs to fix

                        Function updateNAModule2 has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

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

                          Function getDeviceFeaturesAggregates has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          async function getDeviceFeaturesAggregates(selector, intervalInMinutes, maxStates = 100) {
                            const deviceFeature = this.stateManager.get('deviceFeature', selector);
                            if (deviceFeature === null) {
                              throw new NotFoundError('DeviceFeature not found');
                            }
                          Severity: Major
                          Found in server/lib/device/device.getDeviceFeaturesAggregates.js - About 3 hrs to fix

                            Function formatRecurringEvents has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function formatRecurringEvents(event, gladysCalendar) {
                              const { tz } = event.start;
                              let startDate = this.dayjs.tz(this.dayjs(event.start).format('YYYY-MM-DDTHH:mm:ss'), tz);
                              let endDate;
                            
                            
                            Severity: Major
                            Found in server/services/caldav/lib/calendar/calendar.formaters.js - About 3 hrs to fix

                              File RemoteFeatureEditionPanel.jsx has 290 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              import { Component } from 'preact';
                              import { MarkupText, Text, translate } from 'preact-i18n';
                              
                              import { WEBSOCKET_MESSAGE_TYPES } from '../../../../../../../server/utils/constants';
                              
                              

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

                                  render({ ...props }) {
                                    return (
                                      <div>
                                        <div class="form-group">
                                          <label class="form-label" for="deviceName">
                                Severity: Major
                                Found in front/src/routes/integration/all/mqtt/device-page/DeviceForm.jsx - About 2 hrs to fix

                                  Function ACTIONS.CONDITION.CHECK_TIME has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                    [ACTIONS.CONDITION.CHECK_TIME]: async (self, action, scope) => {
                                      const now = dayjs.tz(dayjs(), self.timezone);
                                      let beforeDate;
                                      let afterDate;
                                      let isBeforeCondition = true;
                                  Severity: Minor
                                  Found in server/lib/scene/scene.actions.js - About 2 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 createActions has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  function createActions(store) {
                                    const integrationActions = createActionsIntegration(store);
                                    const actions = {
                                      async loadProps(state) {
                                        let eweLinkUsername;
                                  Severity: Minor
                                  Found in front/src/routes/integration/all/ewelink/actions.js - About 2 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 CalDAVService has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  module.exports = function CalDAVService(gladys, serviceId) {
                                    const ical = require('ical');
                                    const dav = require('dav-request');
                                    const dayjs = require('dayjs');
                                    const objectSupport = require('dayjs/plugin/objectSupport');
                                  Severity: Major
                                  Found in server/services/caldav/index.js - About 2 hrs to fix

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

                                      render(props, state) {
                                        return (
                                          <div class="card">
                                            <div class="card-header">
                                              <h1 class="card-title">
                                    Severity: Major
                                    Found in front/src/routes/integration/all/melcloud/setup-page/SetupTab.jsx - About 2 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language