GladysProject/Gladys

View on GitHub

Showing 754 of 2,690 total issues

Avoid too many return statements within this function.
Open

  return Math.round(((lastValue - firstValue) / Math.abs(firstValue)) * 100);
Severity: Major
Found in front/src/components/boxs/chart/Chart.jsx - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        return 'purple';

      Avoid too many return statements within this function.
      Open

        return 'danger';

        Function mergeDevices has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function mergeDevices(newDevice, existingDevice, updateAttribute = 'updatable') {
          // No existing device
          if (!existingDevice) {
            return newDevice;
          }
        Severity: Minor
        Found in server/utils/device.js - About 25 mins 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 exports has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = (sequelize, DataTypes) => {
          const User = sequelize.define(
            't_user',
            {
              id: {
        Severity: Minor
        Found in server/models/user.js - About 25 mins 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 RoomController has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = function RoomController(gladys) {
          /**
           * @api {post} /api/v1/house/:house_selector/room create
           * @apiName create
           * @apiGroup Room
        Severity: Minor
        Found in server/api/controllers/room.controller.js - About 25 mins 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 scan has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function scan(options) {
          const { singleAddress, firstAddress, lastAddress, username, password } = options;
          if (singleAddress) {
            logger.debug(`Tasmota: HTTP looking for ${singleAddress}`);
            this.status(singleAddress, username, password);
        Severity: Minor
        Found in server/services/tasmota/lib/http/tasmota.http.scan.js - About 25 mins 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 recursiveSearch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        const recursiveSearch = (message, callback, key = undefined) => {
          Object.keys(message).forEach((subKey) => {
            const currentObj = message[subKey];
            const fullKey = `${key ? `${key}.` : ''}${subKey}`;
        
        
        Severity: Minor
        Found in server/services/tasmota/lib/features/index.js - About 25 mins 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 updateValues has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        async function updateValues(deviceGladys, deviceNetatmo, externalId) {
          const [prefix, topic] = externalId.split(':');
          const { reachable } = deviceNetatmo;
          if (prefix !== 'netatmo') {
            throw new BadParameters(`Netatmo device external_id is invalid: "${externalId}" should starts with "netatmo:"`);
        Severity: Minor
        Found in server/services/netatmo/lib/netatmo.updateValues.js - About 25 mins 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 saveConfiguration has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        async function saveConfiguration(configuration = {}) {
          const { presenceScanner = {} } = configuration;
        
          // Check and store presence scanner frequency
          if (presenceScanner.frequency !== undefined) {
        Severity: Minor
        Found in server/services/bluetooth/lib/config/bluetooth.saveConfiguration.js - About 25 mins 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 buildAccessory has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function buildAccessory(device) {
          const categories = device.features.reduce((previousValue, currentValue) => {
            if (!mappings[currentValue.category] || !mappings[currentValue.category].capabilities[currentValue.type]) {
              return {
                ...previousValue,
        Severity: Minor
        Found in server/services/homekit/lib/buildAccessory.js - About 25 mins 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 connect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        async function connect() {
          this.configured = false;
          this.connected = false;
        
          const email = await this.gladys.variable.getValue(EWELINK_EMAIL_KEY, this.serviceId);
        Severity: Minor
        Found in server/services/ewelink/lib/device/connect.js - About 25 mins 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 readValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          readValue: (expose, value) => {
            const { [expose.name]: mapping = {} } = names;
            const reversed = mapping.reversedValue || false;
        
            switch (value) {
        Severity: Minor
        Found in server/services/zigbee2mqtt/exposes/binaryType.js - About 25 mins 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 discoverDevices has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        async function discoverDevices() {
          logger.debug('Looking for Netatmo devices...');
          if (this.status !== STATUS.CONNECTED) {
            await this.saveStatus({ statusType: this.status, message: null });
            throw new ServiceNotConfiguredError('Unable to discover Netatmo devices until service is not well configured');
        Severity: Minor
        Found in server/services/netatmo/lib/netatmo.discoverDevices.js - About 25 mins 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 checkForContainerUpdates has a Cognitive Complexity of 6 (exceeds 5 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 25 mins 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 recursiveSearch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        const recursiveSearch = (expose, type, search) => {
          const { property, features = [] } = expose;
          if (property === search) {
            return expose;
          }
        Severity: Minor
        Found in server/services/zigbee2mqtt/lib/findMatchingExpose.js - About 25 mins 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 config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        async function config(userId) {
          const CALDAV_URL = await this.gladys.variable.getValue('CALDAV_URL', this.serviceId, userId);
          const CALDAV_USERNAME = await this.gladys.variable.getValue('CALDAV_USERNAME', this.serviceId, userId);
          const CALDAV_PASSWORD = await this.gladys.variable.getValue('CALDAV_PASSWORD', this.serviceId, userId);
        
        
        Severity: Minor
        Found in server/services/caldav/lib/config/index.js - About 25 mins 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 loadDeviceDetails has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        async function loadDeviceDetails(homeData) {
          const { rooms: roomsHomeData, modules: modulesHomeData, id: homeId } = homeData;
          let listDevices = [];
        
          logger.debug('loading devices details in home id: ', homeId, '...');
        Severity: Minor
        Found in server/services/netatmo/lib/netatmo.loadDeviceDetails.js - About 25 mins 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 setValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        async function setValue(device, deviceFeature, value) {
          const deviceUuid = device.external_id.split(':')[1];
          const sonosDevice = this.manager.Devices.find((d) => d.uuid === deviceUuid);
          if (deviceFeature.type === DEVICE_FEATURE_TYPES.MUSIC.PLAY) {
            await sonosDevice.Play();
        Severity: Minor
        Found in server/services/sonos/lib/sonos.setValue.js - About 25 mins 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 notifyChange has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function notifyChange(accessories, event) {
          if (event.type !== EVENTS.DEVICE.NEW_STATE) {
            return;
          }
        
        
        Severity: Minor
        Found in server/services/homekit/lib/notifyChange.js - About 25 mins 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

        Severity
        Category
        Status
        Source
        Language