CFenner/MMM-Netatmo

View on GitHub

Showing 36 of 793 total issues

File netatmo.js has 579 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* MagicMirror²
* Module: MMM-Netatmo
*
* By Christopher Fenner https://github.com/CFenner
* MIT Licensed.
Severity: Major
Found in netatmo.js - About 1 day to fix

    Function getModule has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
    Open

    getModule (module, stationName) {
    const result = {}
     
    result.name = module.module_name
    if (this.config.showStationName) {
    Severity: Minor
    Found in netatmo.js - About 7 hrs to fix

    Function getModule has 119 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    getModule (module, stationName) {
    const result = {}
     
    result.name = module.module_name
    if (this.config.showStationName) {
    Severity: Major
    Found in netatmo.js - About 4 hrs to fix

      `` has 30 functions (exceeds 20 allowed). Consider refactoring.
      Open

      Module.register('netatmo', {
      // default config
      defaults: {
      initialDelay: 0,
      updateInterval: 3, // every 3 minutes, refresh interval on netatmo is 10 minutes
      Severity: Minor
      Found in netatmo.js - About 3 hrs to fix

        Function getDirection has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        getDirection (value) {
        if (value < 11.25) return 'N'
        if (value < 33.75) return 'NNE'
        if (value < 56.25) return 'NE'
        if (value < 78.75) return 'ENE'
        Severity: Minor
        Found in netatmo.js - About 2 hrs to fix

        Function updateModuleList has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        updateModuleList (stationList) {
        let moduleList = []
         
        for (const station of stationList) {
        moduleList.push(this.getModule(station, station.home_name))
        Severity: Minor
        Found in netatmo.js - About 1 hr to fix

        Function loadData has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        async loadData () {
        if (this.config.mockData === true) {
        this.sendSocketNotification(this.notifications.DATA_RESPONSE, {
        payloadReturn: this.mockData(),
        status: 'OK',
        Severity: Minor
        Found in helper.js - About 1 hr to fix

          Function authenticateRefresh has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          async authenticateRefresh (refreshToken) {
          console.log('Netatmo: Refresh Token')
          const params = new URLSearchParams()
          params.append('grant_type', 'refresh_token')
          params.append('refresh_token', refreshToken)
          Severity: Minor
          Found in helper.js - About 1 hr to fix

            Function convertToBeaufort has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            convertToBeaufort (value) {
            if (value < 1) return 0
            if (value <= 5) return 1
            if (value <= 11) return 2
            if (value <= 19) return 3
            Severity: Minor
            Found in netatmo.js - About 1 hr to fix

            Function authenticate has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            async authenticate () {
            const params = new URLSearchParams()
            params.append('grant_type', 'refresh_token')
            params.append('refresh_token', this.refreshToken)
            params.append('client_id', this.clientId)
            Severity: Minor
            Found in helper.js - About 1 hr to fix

              Function getValue has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              getValue (measurement, value) {
              if (!value) { return value }
              switch (measurement) {
              case this.measurement.CO2:
              return value.toFixed(0)// + '&nbsp;ppm'
              Severity: Minor
              Found in netatmo.js - About 1 hr to fix

                Function getUnit has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                getUnit (measurement) {
                switch (measurement) {
                case this.measurement.CO2:
                return 'ppm'
                case this.measurement.NOISE:
                Severity: Minor
                Found in netatmo.js - About 1 hr to fix

                  Function socketNotificationReceived has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  socketNotificationReceived (notification, payload) {
                  Log.debug(`Netatmo: received ${notification}`)
                  switch (notification) {
                  case this.notifications.AUTH_RESPONSE:
                  if (payload.status === 'OK') {
                  Severity: Minor
                  Found in netatmo.js - About 45 mins to fix

                  Avoid too many return statements within this function.
                  Open

                  if (value <= 61) return 7
                  Severity: Major
                  Found in netatmo.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                    if (value <= 49) return 6
                    Severity: Major
                    Found in netatmo.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                      if (value < 168.75) return 'SSE'
                      Severity: Major
                      Found in netatmo.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                        if (value < 303.75) return 'WNW'
                        Severity: Major
                        Found in netatmo.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                          return 'N'
                          Severity: Major
                          Found in netatmo.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                            if (value < 101.25) return 'E'
                            Severity: Major
                            Found in netatmo.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                              if (value < 281.25) return 'W'
                              Severity: Major
                              Found in netatmo.js - About 30 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language