mylisabox/lisa-box

View on GitHub

Showing 35 of 77 total issues

Function exports has 228 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = (function () {
  //private
  let app

  /**
Severity: Major
Found in lisa.js - About 1 day to fix

    Function exports has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = (function () {
      //private
      let app
    
      /**
    Severity: Minor
    Found in lisa.js - About 4 hrs 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 interact has 75 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      interact(infos) {
        if (infos.action === 'UNKNOWN') {
          return Promise.resolve(infos)
        }
        else {
    Severity: Major
    Found in api/services/PluginService.js - About 3 hrs to fix

      Function schema has 70 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        static schema(app, Sequelize) {
          return {
            name: {
              type: Sequelize.STRING,
              allowNull: false
      Severity: Major
      Found in api/models/Device.js - About 2 hrs to fix

        Function schema has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          static schema(app, Sequelize) {
            const sEnum = Sequelize.ENUM
            const schema = {
              title: {
                type: Sequelize.STRING,
        Severity: Major
        Found in api/models/Notification.js - About 2 hrs to fix

          Function createOrUpdateDevices has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              createOrUpdateDevices(device, criteria) {
                const plugin = getCurrentPlugin()
                //app.log.debug(plugin)
                let promise
          
          
          Severity: Major
          Found in lisa.js - About 2 hrs to fix

            Function startVoiceCommands has 54 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              startVoiceCommands() {
                if (this.voiceCommand) {
                  this.voiceCommand.stop();
                }
            
            
            Severity: Major
            Found in api/services/VoiceCommandsService.js - About 2 hrs to fix

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

                setValue(deviceId, data) {
                  if (process.env.DEMO_MODE) {
                    return this.app.orm.Device.findById(deviceId).then(device => {
                      if (device) {
                        const key = data.key
              Severity: Minor
              Found in api/services/PluginService.js - About 1 hr to fix

                Function getAdditionalGroupDevice has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  getAdditionalGroupDevice(roomId, devices, wantedType) {
                    const groupDevices = []
                    if (!wantedType || wantedType === this.app.lisa.DEVICE_TYPE.LIGHT) {
                      const lights = devices.filter(devices => devices.type === this.app.lisa.DEVICE_TYPE.LIGHT)
                      if (roomId && lights.length > 1) {
                Severity: Minor
                Found in api/services/DashboardService.js - About 1 hr to fix

                  Function getStorePlugins has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async getStorePlugins(req, res) {
                      const footprintService = this.app.services.FootprintService
                      const installedPlugins = await footprintService.find('plugin', {}, {})
                      const plugins = [
                        {
                  Severity: Minor
                  Found in api/controllers/PluginController.js - About 1 hr to fix

                    Function protect has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      protect(req, res, next) {
                        const header = req.headers['device-id']
                        const nextPolicy = () => this.app.policies['Passport'].jwt(req, res, next)
                        const checkHeaderKnownDevice = () => {
                          return this.app.orm.Device.findAll({
                    Severity: Minor
                    Found in api/policies/AuthTokenPolicy.js - About 1 hr to fix

                      Function config has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        static config() {
                          return {
                            options: {
                              instanceMethods: {
                                toJSON: function () {
                      Severity: Minor
                      Found in api/models/Device.js - About 1 hr to fix

                        Function schema has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                          static schema(app, Sequelize) {
                            return {
                              name: {
                                type: Sequelize.STRING,
                                allowNull: false
                        Severity: Minor
                        Found in api/models/Device.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 _translateSettings has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                          _translateSettings(lang, settings) {
                            const translatedSettings = ['labelText', 'text', 'hintText', 'errorText', 'counterText', 'helperText', 'prefixText', 'suffixText']
                            if (settings) {
                              for (const setting in settings) {
                                if(typeof settings[setting] === 'object') {
                        Severity: Minor
                        Found in api/services/PluginService.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 findAssociation has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          findAssociation(req, res) {
                            const footprintService = this.app.services.FootprintService
                            const favoritesService = this.app.services.FavoritesService
                            const options = this.app.packs.express.getOptionsFromQuery(req.query)
                            const criteria = this.app.packs.express.getCriteriaFromQuery(req.query)
                        Severity: Minor
                        Found in api/controllers/RoomController.js - About 1 hr to fix

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

                            static config (app, Sequelize) {
                              return {
                                options: {
                                  classMethods: {
                                    associate: (models) => {
                          Severity: Minor
                          Found in api/models/Plugin.js - About 1 hr to fix

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

                              getOrderedDeviceForRoom(roomId, userId) {
                                const promises = [
                                  this.app.orm.Dashboard.find({
                                    where: {
                                      roomId: roomId,
                            Severity: Minor
                            Found in api/services/DashboardService.js - About 1 hr to fix

                              Function checkHeaderKnownDevice has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  const checkHeaderKnownDevice = () => {
                                    return this.app.orm.Device.findAll({
                                      where: {
                                        pluginName: 'lisa-plugin-voice'
                                      }
                              Severity: Minor
                              Found in api/policies/AuthTokenPolicy.js - About 1 hr to fix

                                Function saveDevicesOrderForRoom has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  saveDevicesOrderForRoom(roomId, userId, widgetsOrder) {
                                    return this.app.orm.Dashboard.find({
                                      where: {
                                        roomId: roomId,
                                        userId: userId
                                Severity: Minor
                                Found in api/services/DashboardService.js - About 1 hr to fix

                                  Function config has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    static config(app, Sequelize) {
                                      return {
                                        options: {
                                          hooks: {
                                            afterCreate: (values, options, fn) => {
                                  Severity: Minor
                                  Found in api/models/Notification.js - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language