GladysProject/Gladys

View on GitHub

Showing 2,655 of 2,655 total issues

Function connect has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function connect(configuration) {
  const { baseUrl, accessKey, secretKey } = configuration;

  if (!baseUrl || !accessKey || !secretKey) {
    this.status = STATUS.NOT_INITIALIZED;
Severity: Minor
Found in server/services/tuya/lib/tuya.connect.js - About 1 hr to fix

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

      up: async (queryInterface, Sequelize) => {
        await queryInterface.createTable('t_script', {
          id: {
            allowNull: false,
            primaryKey: true,
    Severity: Minor
    Found in server/migrations/20190211044205-create-script.js - About 1 hr to fix

      Function AreaController has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function AreaController(gladys) {
        /**
         * @api {post} /api/v1/area create
         * @apiName create
         * @apiGroup Area
      Severity: Minor
      Found in server/api/controllers/area.controller.js - About 1 hr to fix

        Function determineTypeAndTraits has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function determineTypeAndTraits(device) {
          const featureCategoryTypes = {};
          let type;
          const traits = [];
          let attributes = {};

          Function poll has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          async function poll(device) {
            const externalId = device.external_id;
            const [prefix, topic] = device.external_id.split(':');
          
            if (prefix !== 'tuya') {
          Severity: Minor
          Found in server/services/tuya/lib/tuya.poll.js - About 1 hr to fix

            Function EwelinkController has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function EwelinkController(eweLinkHandler) {
              /**
               * @api {post} /api/v1/service/ewelink/connect Connect to eWeLink cloud account.
               * @apiName save
               * @apiGroup Ewelink
            Severity: Minor
            Found in server/services/ewelink/api/ewelink.controller.js - About 1 hr to fix

              Function getAccessToken has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              async function getAccessToken(refreshToken, scope) {
                if (!refreshToken || refreshToken.length === 0) {
                  throw new BadParameters();
                }
                const refreshTokenHash = hashRefreshToken(refreshToken);
              Severity: Minor
              Found in server/lib/session/session.getAccessToken.js - About 1 hr to fix

                Function checkForContainerUpdates has 29 lines of code (exceeds 25 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) {
                Severity: Minor
                Found in server/services/zigbee2mqtt/lib/checkForContainerUpdates.js - About 1 hr to fix

                  Function throwErrorIfNeeded has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  async function throwErrorIfNeeded(response, emit = false, config = false) {
                    if (response.error) {
                      if (response.error === 406) {
                        this.connected = false;
                        this.accessToken = '';
                  Severity: Minor
                  Found in server/services/ewelink/lib/device/index.js - About 1 hr to fix

                    Function command has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    async function command(message, classification, context) {
                      const cameraImages = [];
                    
                      const roomEntity = classification.entities.find((entity) => entity.entity === 'room');
                      const deviceEntity = classification.entities.find((entity) => entity.entity === 'device');
                    Severity: Minor
                    Found in server/lib/device/camera/camera.command.js - About 1 hr to fix

                      Function promise has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        const promise = new Promise((resolve, reject) => {
                          let err = '';
                          const childProcess = spawn('node', [SCRIPT_PATH, JSON.stringify(params)]);
                      
                          childProcess.stdout.on('data', async (data) => {
                      Severity: Minor
                      Found in server/lib/device/device.calculateAggregate.js - About 1 hr to fix

                        Function getEventsInRange has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            async getEventsInRange(state, from, to) {
                              store.setState({
                                DeviceGetStatus: CalendarGetEventsStatus.Getting
                              });
                              try {
                        Severity: Minor
                        Found in front/src/actions/calendar.js - About 1 hr to fix

                          Function disarm has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          async function disarm(selector) {
                            // In case there is a timeout to arm this house, we clear it
                            clearTimeout(this.armingHouseTimeout.get(selector));
                            if (this.armingHouseTimeout.get(selector)) {
                              this.armingHouseTimeout.delete(selector);
                          Severity: Minor
                          Found in server/lib/house/house.disarm.js - About 1 hr to fix

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

                            function createActions(store) {
                              const actions = {
                                async loadProfilePicture(state) {
                                  // if a profile picture already exist
                                  if (state.profilePicture) {
                            Severity: Minor
                            Found in front/src/actions/profilePicture.js - About 1 hr to fix

                              Function saveNextcloudTalkSettings has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                async saveNextcloudTalkSettings(state) {
                                  store.setState({
                                    nextcloudTalkSaveSettingsStatus: RequestStatus.Getting
                                  });
                                  try {
                              Severity: Minor
                              Found in front/src/routes/integration/all/nextcloud-talk/actions.js - About 1 hr to fix

                                Function saveCaldavSettings has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  async saveCaldavSettings(state) {
                                    store.setState({
                                      caldavSaveSyncStatus: CalDAVStatus.Getting
                                    });
                                    try {
                                Severity: Minor
                                Found in front/src/routes/integration/all/caldav/sync-page/actions.js - About 1 hr to fix

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

                                    render(
                                      props,
                                      { name, color, radius, latitude, longitude, houses, loading, createAreaError, deleteAreaError, getAreaError }
                                    ) {
                                      return (
                                  Severity: Minor
                                  Found in front/src/routes/map/NewArea.jsx - About 1 hr to fix

                                    Similar blocks of code found in 12 locations. Consider refactoring.
                                    Open

                                      updateBoxUseCustomValue = e => {
                                        this.props.updateBoxConfig(this.props.x, this.props.y, {
                                          humidity_use_custom_value: e.target.checked
                                        });
                                      };
                                    front/src/components/boxs/alarm/EditAlarm.jsx on lines 8..12
                                    front/src/components/boxs/alarm/EditAlarm.jsx on lines 14..18
                                    front/src/components/boxs/camera/EditCamera.jsx on lines 87..91
                                    front/src/components/boxs/camera/EditCamera.jsx on lines 93..97
                                    front/src/components/boxs/camera/EditCamera.jsx on lines 99..103
                                    front/src/components/boxs/chart/EditChart.jsx on lines 61..63
                                    front/src/components/boxs/clock/EditClock.jsx on lines 8..10
                                    front/src/components/boxs/device-in-room/EditDevices.jsx on lines 19..23
                                    front/src/components/boxs/room-temperature/EditRoomTemperatureBox.jsx on lines 72..76
                                    front/src/components/boxs/scene/EditSceneBox.jsx on lines 19..23
                                    front/src/components/boxs/weather/EditWeatherBox.jsx on lines 57..61

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 58.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 12 locations. Consider refactoring.
                                    Open

                                      updateBoxName = e => {
                                        this.props.updateBoxConfig(this.props.x, this.props.y, {
                                          name: e.target.value
                                        });
                                      };
                                    Severity: Major
                                    Found in front/src/components/boxs/alarm/EditAlarm.jsx and 11 other locations - About 1 hr to fix
                                    front/src/components/boxs/alarm/EditAlarm.jsx on lines 8..12
                                    front/src/components/boxs/camera/EditCamera.jsx on lines 87..91
                                    front/src/components/boxs/camera/EditCamera.jsx on lines 93..97
                                    front/src/components/boxs/camera/EditCamera.jsx on lines 99..103
                                    front/src/components/boxs/chart/EditChart.jsx on lines 61..63
                                    front/src/components/boxs/clock/EditClock.jsx on lines 8..10
                                    front/src/components/boxs/device-in-room/EditDevices.jsx on lines 19..23
                                    front/src/components/boxs/room-humidity/EditRoomHumidityBox.jsx on lines 64..68
                                    front/src/components/boxs/room-temperature/EditRoomTemperatureBox.jsx on lines 72..76
                                    front/src/components/boxs/scene/EditSceneBox.jsx on lines 19..23
                                    front/src/components/boxs/weather/EditWeatherBox.jsx on lines 57..61

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 58.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 12 locations. Consider refactoring.
                                    Open

                                      updateBoxTitle = e => {
                                        this.props.updateBoxConfig(this.props.x, this.props.y, { title: e.target.value });
                                      };
                                    Severity: Major
                                    Found in front/src/components/boxs/chart/EditChart.jsx and 11 other locations - About 1 hr to fix
                                    front/src/components/boxs/alarm/EditAlarm.jsx on lines 8..12
                                    front/src/components/boxs/alarm/EditAlarm.jsx on lines 14..18
                                    front/src/components/boxs/camera/EditCamera.jsx on lines 87..91
                                    front/src/components/boxs/camera/EditCamera.jsx on lines 93..97
                                    front/src/components/boxs/camera/EditCamera.jsx on lines 99..103
                                    front/src/components/boxs/clock/EditClock.jsx on lines 8..10
                                    front/src/components/boxs/device-in-room/EditDevices.jsx on lines 19..23
                                    front/src/components/boxs/room-humidity/EditRoomHumidityBox.jsx on lines 64..68
                                    front/src/components/boxs/room-temperature/EditRoomTemperatureBox.jsx on lines 72..76
                                    front/src/components/boxs/scene/EditSceneBox.jsx on lines 19..23
                                    front/src/components/boxs/weather/EditWeatherBox.jsx on lines 57..61

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 58.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language