mylisabox/lisa-box

View on GitHub

Showing 77 of 77 total issues

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 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 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 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

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

          const manageErrors = (app, error) => {
            app.log.error(error)
            if (app.env.NODE_ENV !== 'production') {
              app.log.warn('this payload error is return for development purpose only and will be only log on production')
              return error
          Severity: Major
          Found in api/utils/error.js and 1 other location - About 1 hr to fix
          api/controllers/RoomController.js on lines 4..11

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 71.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

          const manageErrors = (app, error) => {
            app.log.error(error)
            if (app.env.NODE_ENV !== 'production') {
              app.log.warn('this payload error is return for development purpose only and will be only log on production')
              return error
          Severity: Major
          Found in api/controllers/RoomController.js and 1 other location - About 1 hr to fix
          api/utils/error.js on lines 1..8

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 71.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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 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 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 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

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                        const reqStream = request(req.query.url, err => {
                          if (err) {
                            this.log.error(err)
                            res.status(500).end()
                          }
                    Severity: Major
                    Found in api/controllers/CameraController.js and 1 other location - About 1 hr to fix
                    api/controllers/CameraController.js on lines 18..23

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 60.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Identical blocks of code found in 2 locations. Consider refactoring.
                    Open

                        reqStream = request(req.query.url, err => {
                          if (err) {
                            this.log.error(err)
                            res.status(500).end()
                          }
                    Severity: Major
                    Found in api/controllers/CameraController.js and 1 other location - About 1 hr to fix
                    api/controllers/CameraController.js on lines 30..35

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 60.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    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