File netatmo.js
has 579 lines of code (exceeds 250 allowed). Consider refactoring.
* Module: MMM-Netatmo
*
* By Christopher Fenner https://github.com/CFenner
* MIT Licensed.
Function getModule
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
getModule (module, stationName) {
const result = {}
result.name = module.module_name
if (this.config.showStationName) {
Function getModule
has 119 lines of code (exceeds 25 allowed). Consider refactoring.
getModule (module, stationName) {
const result = {}
result.name = module.module_name
if (this.config.showStationName) {
`` has 30 functions (exceeds 20 allowed). Consider refactoring.
Module.register('netatmo', {
defaults: {
initialDelay: 0,
updateInterval: 3,
Function getDirection
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
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'
Function updateModuleList
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
updateModuleList (stationList) {
let moduleList = []
for (const station of stationList) {
moduleList.push(this.getModule(station, station.home_name))
Function convertToBeaufort
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
convertToBeaufort (value) {
if (value < 1) return 0
if (value <= 5) return 1
if (value <= 11) return 2
if (value <= 19) return 3
Function getValue
has 31 lines of code (exceeds 25 allowed). Consider refactoring.
getValue (measurement, value) {
if (!value) { return value }
switch (measurement) {
case this.measurement.CO2:
return value.toFixed(0)
Function getUnit
has 27 lines of code (exceeds 25 allowed). Consider refactoring.
getUnit (measurement) {
switch (measurement) {
case this.measurement.CO2:
return 'ppm'
case this.measurement.NOISE:
Function socketNotificationReceived
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
socketNotificationReceived (notification, payload) {
Log.debug(`Netatmo: received ${notification}`)
switch (notification) {
case this.notifications.AUTH_RESPONSE:
if (payload.status === 'OK') {
Avoid too many return
statements within this function.
if (value <= 61) return 7
Avoid too many return
statements within this function.
if (value <= 49) return 6
Avoid too many return
statements within this function.
if (value < 168.75) return 'SSE'
Avoid too many return
statements within this function.
if (value < 303.75) return 'WNW'
Avoid too many return
statements within this function.
return 'N'
Avoid too many return
statements within this function.
if (value < 101.25) return 'E'
Avoid too many return
statements within this function.
if (value < 281.25) return 'W'
Avoid too many return
statements within this function.
if (value < 326.25) return 'NW'
Avoid too many return
statements within this function.
if (value <= 88) return 9
Avoid too many return
statements within this function.
return 12
Avoid too many return
statements within this function.
if (value <= 74) return 8
Avoid too many return
statements within this function.
return 'fa-battery-empty flash red'
Avoid too many return
statements within this function.
if (value <= 28) return 4
Avoid too many return
statements within this function.
if (value < 123.75) return 'ESE'
Avoid too many return
statements within this function.
if (value <= 38) return 5
Avoid too many return
statements within this function.
if (value < 191.25) return 'S'
Avoid too many return
statements within this function.
if (value < 258.75) return 'WSW'
Avoid too many return
statements within this function.
if (value <= 117) return 11
Avoid too many return
statements within this function.
if (value < 348.75) return 'NNW'
Avoid too many return
statements within this function.
if (value < 213.75) return 'SSW'
Avoid too many return
statements within this function.
if (value <= 102) return 10
Avoid too many return
statements within this function.
if (value < 146.25) return 'SE'
Avoid too many return
statements within this function.
if (value < 236.25) return 'SW'
Similar blocks of code found in 2 locations. Consider refactoring.
if (this.config.design === 'bubbles') {
primaryType = this.measurement.TEMPERATURE
primaryValue = module.dashboard_data ? module.dashboard_data[primaryType] : ''
result.primary = {
value: this.getValue(primaryType, primaryValue),
Similar blocks of code found in 2 locations. Consider refactoring.
if (this.config.design === 'bubbles') {
primaryType = this.measurement.RAIN
primaryValue = module.dashboard_data ? module.dashboard_data[primaryType] : ''
result.primary = {
value: this.getValue(primaryType, primaryValue),
Similar blocks of code found in 3 locations. Consider refactoring.
if (this.config.unitOfMeasurementWind === '') {
this.config.unitOfMeasurementWind = this.convertNetatmoWindUnit(userPreferences.windunit)
console.log('Using user-preferred unit of measurement for wind values %o', this.config.unitOfMeasurementWind)
}
Similar blocks of code found in 3 locations. Consider refactoring.
if (this.config.unitOfMeasurement === '') {
this.config.unitOfMeasurement = this.convertNetatmoUnit(userPreferences.unit)
console.log('Using user-preferred unit of measurement for temp/rain values %o', this.config.unitOfMeasurement)
}
Similar blocks of code found in 3 locations. Consider refactoring.
if (this.config.unitOfMeasurementPressure === '') {
this.config.unitOfMeasurementPressure = this.convertNetatmoPressureUnit(userPreferences.pressureunit)
console.log('Using user-preferred unit of measurement for pressure values %o', this.config.unitOfMeasurementPressure)
}
Similar blocks of code found in 2 locations. Consider refactoring.
if (this.config.showTrend) { result.measurementList.push(this.getMeasurement(module, this.measurement.PRESSURE_TREND)) }
Similar blocks of code found in 2 locations. Consider refactoring.
if (this.config.showTrend) { result.measurementList.push(this.getMeasurement(module, this.measurement.TEMPERATURE_TREND)) }
There are no issues that match your filters.