GladysProject/Gladys

View on GitHub

Showing 754 of 2,690 total issues

Function DeviceManager has 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

  eventManager,
  messageManager,
  stateManager,
  serviceManager,
  roomManager,
Severity: Major
Found in server/lib/device/index.js - About 1 hr to fix

    Function convertDevice has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function convertDevice(melCloudDevice) {
      const externalId = `melcloud:${melCloudDevice.DeviceID}`;
    
      const gladysDevice = {
        name: melCloudDevice.DeviceName,
    Severity: Minor
    Found in server/services/melcloud/lib/device/melcloud.convertDevice.js - About 1 hr to fix

      Function ServiceController has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function ServiceController(gladys) {
        /**
         * @api {post} /api/v1/service/:service_name/start start
         * @apiName start
         * @apiGroup Service
      Severity: Minor
      Found in server/api/controllers/service.controller.js - About 1 hr to fix

        Function MELCloudService has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function MELCloudService(gladys, serviceId) {
          const axios = require('axios');
        
          const client = axios.create({
            baseURL: MELCLOUD_ENDPOINT,
        Severity: Minor
        Found in server/services/melcloud/index.js - About 1 hr to fix

          Function setTabletMode has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          async function setTabletMode(userId, sessionId, tabletMode, houseSelector) {
            const session = await db.Session.findOne({
              attributes: ['id'],
              where: {
                id: sessionId,
          Severity: Minor
          Found in server/lib/session/session.setTabletMode.js - About 1 hr to fix

            Function mapUnit has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function mapUnit(deviceUnit, featureUnit) {
              switch (deviceUnit) {
                case '%':
                  return DEVICE_FEATURE_UNITS.PERCENT;
                case 'hPa':
            Severity: Minor
            Found in server/services/zigbee2mqtt/utils/features/mapUnit.js - About 1 hr to fix

              Function setValue has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              async function setValue(broadlinkDevice, gladysDevice, deviceFeature, value) {
                const { type } = deviceFeature;
                const valueStr = value.toString();
              
                // Check for valued code
              Severity: Minor
              Found in server/services/broadlink/lib/commands/features/broadlink.remote.js - About 1 hr to fix

                Function learn has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                async function learn(peripheralIdentifier) {
                  logger.debug(`Broalink entering learn mode with ${peripheralIdentifier}`);
                  let peripheral;
                
                  try {
                Severity: Minor
                Found in server/services/broadlink/lib/learn/broadlink.learn.js - About 1 hr to fix

                  Function SceneManager has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const SceneManager = function SceneManager(
                    stateManager,
                    event,
                    device,
                    message,
                  Severity: Minor
                  Found in server/lib/scene/index.js - About 1 hr to fix

                    Function waitForRestoreToFinish has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        async waitForRestoreToFinish(state) {
                          try {
                            const restoreStatus = await state.httpClient.get('/api/v1/gateway/backup/restore/status');
                            if (restoreStatus.restore_in_progress) {
                              setTimeout(() => {
                    Severity: Minor
                    Found in front/src/actions/gateway.js - About 1 hr to fix

                      Function componentWillMount has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        async componentWillMount() {
                          this.props.getHouses();
                          this.getDeviceFeaturesOptions();
                          await this.props.getIntegrationByName('mqtt');
                      
                      
                      Severity: Minor
                      Found in front/src/routes/integration/all/mqtt/device-page/setup/index.js - About 1 hr to fix

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

                          render({}, { numberOfHoursBeforeStateIsOutdated }) {
                            return (
                              <div class="card">
                                <h4 class="card-header">
                                  <Text id="systemSettings.numberOfHoursBeforeStateIsOutdated" />

                          Function connectBridge has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async connectBridge(state, bridge) {
                              store.setState({
                                philipsHueCreateDeviceStatus: RequestStatus.Getting
                              });
                              try {
                          Severity: Minor
                          Found in front/src/routes/integration/all/philips-hue/setup-page/actions.js - About 1 hr to fix

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

                              render(props, {}) {
                                let temperature_min = this.props.box.temperature_min;
                                let temperature_max = this.props.box.temperature_max;
                            
                                const unit = this.props.user.temperature_unit_preference;

                              Function newValueDuplexWirelessSwitch has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                              function newValueDuplexWirelessSwitch(message, data) {
                                const { sid } = message;
                                logger.debug(`Xiaomi : New value duplex wireless switch, sid = ${sid}`);
                                const EXTERNAL_ID_CHANNEL_0_BUTTON = `xiaomi:${sid}:duplex-wireless-switch:channel-0:button`;
                                const EXTERNAL_ID_CHANNEL_1_BUTTON = `xiaomi:${sid}:duplex-wireless-switch:channel-1:button`;

                              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 request has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                              function request(url, dataCallback, authErrorCallback, errorCallback) {
                                logger.debug(`Tasmota: HTTP looking for ${url}`);
                                const req = http.get(url, (res) => {
                                  logger.debug(`Tasmota: HTTP response for ${url}: ${res.statusCode}`);
                              
                              
                              Severity: Minor
                              Found in server/services/tasmota/lib/http/tasmota.http.request.js - About 1 hr 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 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                              async function scan() {
                                if (!this.configured) {
                                  throw new ServiceNotConfiguredError();
                                } else if (this.scanning) {
                                  logger.warn(`LANManager already scanning for devices...`);
                              Severity: Minor
                              Found in server/services/lan-manager/lib/lan-manager.scan.js - About 1 hr 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 poll has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                              async function poll(device) {
                                if (!this.connected) {
                                  await this.connect();
                                }
                              
                              
                              Severity: Minor
                              Found in server/services/ewelink/lib/device/poll.js - About 1 hr 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 pollBinary has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                                pollBinary: (eWeLinkDevice, feature) => {
                                  const { deviceId, channel } = parseExternalId(feature.external_id);
                                  let state = (eWeLinkDevice.params && eWeLinkDevice.params.switch) || false;
                                  const switches = (eWeLinkDevice.params && eWeLinkDevice.params.switches) || false;
                                  if (state || switches) {
                              Severity: Minor
                              Found in server/services/ewelink/lib/features/binary.js - About 1 hr 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 handleMqttMessage has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                              async function handleMqttMessage(topic, message) {
                                // Limit events only on status changes
                                if (!this.zigbee2mqttConnected) {
                                  this.zigbee2mqttConnected = true;
                                  this.zigbee2mqttRunning = true;
                              Severity: Minor
                              Found in server/services/zigbee2mqtt/lib/handleMqttMessage.js - About 1 hr 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