GladysProject/Gladys

View on GitHub

Showing 742 of 2,674 total issues

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

async function connect(configuration) {
  const { username, password } = configuration;

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

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

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

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

      async function discoverDevices() {
        logger.debug('Looking for MELCloud devices...');
        if (this.status !== STATUS.CONNECTED) {
          this.gladys.event.emit(EVENTS.WEBSOCKET.SEND_ALL, {
            type: WEBSOCKET_MESSAGE_TYPES.MELCLOUD.STATUS,
      Severity: Minor
      Found in server/services/melcloud/lib/melcloud.discoverDevices.js - About 1 hr to fix

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

        function setupRoutes(gladys) {
          const router = express.Router();
          const routes = getRoutes(gladys);
          const authMiddleware = AuthMiddleware('dashboard:write', gladys);
          const isInstanceConfiguredMiddleware = IsInstanceConfiguredMiddleware(gladys);
        Severity: Minor
        Found in server/api/setupRoutes.js - About 1 hr to fix

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

          async function handleAlexaMessage(data, rawMessage, cb) {
            try {
              const service = this.serviceManager.getService('alexa');
              const body = {
                ...data.data,
          Severity: Minor
          Found in server/lib/gateway/gateway.handleAlexaMessage.js - About 1 hr to fix

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

            async function getHumidityInRoom(roomId, options) {
              logger.debug(`Getting average humidity in room ${roomId}`);
              const optionsWithDefault = { ...DEFAULT_PARAMETERS, ...options };
            
              const oneHourAgo = new Date(new Date().getTime() - 1 * 60 * 60 * 1000);

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

              async function getBySelector(selector, options) {
                const optionsWithDefault = { ...DEFAULT_OPTIONS, ...options };
                const include = [];
                if (optionsWithDefault.expand.includes('devices')) {
                  include.push({
              Severity: Minor
              Found in server/lib/room/room.getBySelector.js - About 1 hr to fix

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

                async function update(selector, scene) {
                  const existingScene = await db.Scene.findOne({
                    where: {
                      selector,
                    },
                Severity: Minor
                Found in server/lib/scene/scene.update.js - About 1 hr to fix

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

                      async checkStatus(state) {
                        let zigbee2mqttStatus = {
                          usbConfigured: false,
                          mqttExist: false,
                          mqttRunning: false,
                  Severity: Minor
                  Found in front/src/routes/integration/all/zigbee2mqtt/setup-page/actions.js - About 1 hr to fix

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

                      connect() {
                        const websocketUrl = config.webSocketUrl || window.location.origin.replace('http', 'ws');
                        if (this.ws && this.ws.close) {
                          this.ws.close();
                        }
                    Severity: Minor
                    Found in front/src/utils/Session.js - About 1 hr to fix

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

                          async saveHouse(state) {
                            // validate new house
                            let errored = false;
                            const errors = {};
                            if (!state.signupNewHouseName || state.signupNewHouseName.length === 0) {
                      Severity: Minor
                      Found in front/src/actions/signup/signupConfigureHouse.js - About 1 hr to fix

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

                          render(props, {}) {
                            return (
                              <div>
                                <p>
                                  <Text id="editScene.actionsCard.delay.label" />
                        Severity: Minor
                        Found in front/src/routes/scene/edit-scene/actions/DelayActionParams.jsx - About 1 hr to fix

                          Function action.devices.commands.ColorAbsolute has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                              'action.devices.commands.ColorAbsolute': (device, params) => {
                                const events = [];
                                const { color = {} } = params;
                                const { temperature, spectrumRGB } = color;
                          
                          

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

                          module.exports = function AuthMiddleware(scope, gladys) {
                            return asyncMiddleware(async (req, res, next) => {
                              try {
                                const authHeader = req.headers.authorization;
                                let userId;
                          Severity: Minor
                          Found in server/api/middlewares/authMiddleware.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 createActions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const createActions = store => {
                            const integrationActions = createActionsIntegration(store);
                            const actions = {
                              async checkStatus(state) {
                                let zigbee2mqttStatus = {
                          Severity: Minor
                          Found in front/src/routes/integration/all/zigbee2mqtt/setup-page/actions.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 actions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const actions = store => ({
                            async getBridges(state) {
                              store.setState({
                                philipsHueGetBridgesStatus: RequestStatus.Getting
                              });
                          Severity: Minor
                          Found in front/src/routes/integration/all/philips-hue/setup-page/actions.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 CheckStatus has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const CheckStatus = ({
                            nodeRedEnabled,
                            nodeRedExist,
                            nodeRedRunning,
                            dockerBased,
                          Severity: Minor
                          Found in front/src/routes/integration/all/node-red/setup-page/CheckStatus.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 up has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

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

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

                            function getGladysDeviceFeatures(externalId, melCloudDevice) {
                              return [
                                {
                                  name: 'Power',
                                  external_id: `${externalId}:power`,
                            Severity: Minor
                            Found in server/services/melcloud/lib/device/air-to-air.device.js - About 1 hr to fix

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

                                up: async (queryInterface, Sequelize) => {
                                  await queryInterface.createTable('t_scene', {
                                    id: {
                                      allowNull: false,
                                      primaryKey: true,
                              Severity: Minor
                              Found in server/migrations/20190211045110-create-scene.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language