GladysProject/Gladys

View on GitHub

Showing 754 of 2,690 total issues

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

  render(props, { loading, error }) {
    return (
      <Layout>
        <div class="container mt-4">
          <div class="row">
Severity: Major
Found in front/src/routes/integration/all/alexa-gateway/index.js - About 3 hrs to fix

    Function init has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    async function init(setupMode = false) {
      // Reset status
      this.usbConfigured = false;
      this.mqttExist = false;
      this.mqttRunning = false;
    Severity: Major
    Found in server/services/zigbee2mqtt/lib/init.js - About 3 hrs to fix

      Function backup has 86 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function backup(jobId) {
        const encryptKey = await this.variable.getValue('GLADYS_GATEWAY_BACKUP_KEY');
        if (encryptKey === null) {
          throw new NotFoundError('GLADYS_GATEWAY_BACKUP_KEY_NOT_FOUND');
        }
      Severity: Major
      Found in server/lib/gateway/gateway.backup.js - About 3 hrs to fix

        File HttpRequest.jsx has 310 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { Component } from 'preact';
        import { connect } from 'unistore/preact';
        import { Text, Localizer } from 'preact-i18n';
        import cx from 'classnames';
        import update from 'immutability-helper';
        Severity: Minor
        Found in front/src/routes/scene/edit-scene/actions/HttpRequest.jsx - About 3 hrs to fix

          Function init has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

          async function init(setupMode = false) {
            // Reset status
            this.usbConfigured = false;
            this.mqttExist = false;
            this.mqttRunning = false;
          Severity: Minor
          Found in server/services/zigbee2mqtt/lib/init.js - About 3 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 convertToGladysDevice has 85 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const convertToGladysDevice = (serviceId, device) => {
            return {
              name: device.name,
              external_id: `sonos:${device.uuid}`,
              service_id: serviceId,
          Severity: Major
          Found in server/services/sonos/utils/convertToGladysDevice.js - About 3 hrs to fix

            Function saveHouse has 85 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                async saveHouse(state, houseIndex) {
                  store.setState({
                    houseUpdateStatus: RequestStatus.Getting
                  });
                  const house = state.houses[houseIndex];
            Severity: Major
            Found in front/src/actions/house.js - About 3 hrs to fix

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

                render(
                  { disabled },
                  { z2mDriverPath, usbPorts, loadUsbPortsStatus, z2mDongleName, zigbeeAdapters, loadZigbeeAdaptersStatus, z2mTcpPort }
                ) {
                  return (

                File house.js has 307 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { RequestStatus } from '../utils/consts';
                import update, { extend } from 'immutability-helper';
                
                extend('$auto', (value, object) => {
                  return object ? update(object, value) : update({}, value);
                Severity: Minor
                Found in front/src/actions/house.js - About 3 hrs to fix

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

                  function createActions(store) {
                    const actions = {
                      checkErrors(state) {
                        let newSceneErrors = {};
                        if (!state.newScene.name) {
                  Severity: Major
                  Found in front/src/actions/createScene.js - About 3 hrs to fix

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

                      render(props, state) {
                        let discoverable = false;
                        if (state.searchByRange) {
                          discoverable =
                            IP_PATTERN.test(state.firstAddress) &&
                    Severity: Major
                    Found in front/src/routes/integration/all/tasmota/discover-http/SearchForm.jsx - About 3 hrs to fix

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

                        render() {
                          const language = get(this.props, 'user.language');
                          const localeSet = language === 'fr' ? fr : 'en';
                          const before = this.props.action.before
                            ? new Date().setHours(this.props.action.before.substr(0, 2), this.props.action.before.substr(3, 2))
                      Severity: Major
                      Found in front/src/routes/scene/edit-scene/actions/CheckTime.jsx - About 3 hrs to fix

                        actionsFunc has 28 functions (exceeds 20 allowed). Consider refactoring.
                        Open

                        const actionsFunc = {
                          [ACTIONS.DEVICE.SET_VALUE]: async (self, action, scope, columnIndex, rowIndex) => {
                            let device;
                            let deviceFeature;
                            if (action.device_feature) {
                        Severity: Minor
                        Found in server/lib/scene/scene.actions.js - About 3 hrs to fix

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

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

                            Function installMqttContainer has 83 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            async function installMqttContainer(config) {
                              let dockerContainers = await this.gladys.system.getContainers({
                                all: true,
                                filters: { name: [containerDescriptor.name] },
                              });
                            Severity: Major
                            Found in server/services/zigbee2mqtt/lib/installMqttContainer.js - About 3 hrs to fix

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

                                render({ device, houses }, { batteryLevel, loading, tooMuchStatesError, statesNumber }) {
                                  return (
                                    <div class="col-md-6">
                                      <div class="card">
                                        <div class="card-header">

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

                                  render(props, { batteryLevel, loading, tooMuchStatesError, statesNumber }) {
                                    return (
                                      <div class="col-md-4">
                                        <div class="card">
                                          <div class="card-header">
                                Severity: Major
                                Found in front/src/routes/integration/all/xiaomi/Device.jsx - About 3 hrs to fix

                                  Function NetatmoController has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  module.exports = function NetatmoController(netatmoHandler) {
                                    /**
                                     * @api {get} /api/v1/service/netatmo/configuration Get Netatmo Configuration.
                                     * @apiName getConfiguration
                                     * @apiGroup Netatmo
                                  Severity: Major
                                  Found in server/services/netatmo/api/netatmo.controller.js - About 3 hrs to fix

                                    Function handleNewMessage has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                    async function handleNewMessage(data, rawMessage, cb) {
                                      if (data.type === 'gladys-api-call') {
                                        const rsaPublicKey = await this.gladysGatewayClient.generateFingerprint(rawMessage.rsaPublicKeyRaw);
                                        const ecdsaPublicKey = await this.gladysGatewayClient.generateFingerprint(rawMessage.ecdsaPublicKeyRaw);
                                        const found = this.usersKeys.find(
                                    Severity: Minor
                                    Found in server/lib/gateway/gateway.handleNewMessage.js - About 3 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 render has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      render(props, {}) {
                                        const boxData = get(props, `${DASHBOARD_BOX_DATA_KEY}Weather.${props.x}_${props.y}`);
                                        const boxStatus = get(props, `${DASHBOARD_BOX_STATUS_KEY}Weather.${props.x}_${props.y}`);
                                        const weatherObject = get(boxData, 'weather');
                                        const displayMode = this.props.box.modes || {};
                                    Severity: Major
                                    Found in front/src/components/boxs/weather/WeatherBox.jsx - About 3 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language