mylisabox/lisa-box

View on GitHub

Showing 77 of 77 total issues

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

  aggregateDevicesData(devices) {
    const pluginService = this.app.services.PluginService
    const fullData = []

    const devicesByPlugin = this._sortDevicesByPlugin(devices)
Severity: Minor
Found in api/services/DeviceService.js - About 1 hr to fix

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

          get: function () {
            let data = null
            if (this.getDataValue('context')) {
              data = JSON.parse(this.getDataValue('context'))
            }
    Severity: Major
    Found in api/models/ChatBot.js and 1 other location - About 1 hr to fix
    api/models/ChatBotParamList.js on lines 24..30

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

    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

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

      destroyFavorite(userId, deviceId) {
        return this.app.orm.User.findById(userId).then(user => {
          return user.removeFavorite(deviceId)
        })
      }
    Severity: Major
    Found in api/services/FavoritesService.js and 1 other location - About 1 hr to fix
    api/services/FavoritesService.js on lines 35..39

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

    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

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

      putFavorite(userId, deviceId) {
        return this.app.orm.User.findById(userId).then(user => {
          return user.addFavorite(deviceId)
        })
      }
    Severity: Major
    Found in api/services/FavoritesService.js and 1 other location - About 1 hr to fix
    api/services/FavoritesService.js on lines 41..45

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

    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

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

            get: function () {
              let data = null
              if (this.getDataValue('values')) {
                data = JSON.parse(this.getDataValue('values'))
              }
    Severity: Major
    Found in api/models/ChatBotParamList.js and 1 other location - About 1 hr to fix
    api/models/ChatBot.js on lines 35..41

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

    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 dispatchNotification has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      dispatchNotification(notification) {
        return this.app.orm.Notification.create(notification).then(notification => {
          this.sendWebNotification(notification)
    
          if (notification.userId) {
    Severity: Minor
    Found in api/services/NotificationService.js - About 1 hr to fix

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

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

        Function getAdditionalGroupDevice has a Cognitive Complexity of 10 (exceeds 5 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

        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 log has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            get log() {
              const getArguments = (args) => {
                const plugin = getCurrentPlugin()
                const mainArguments = Array.prototype.slice.call(args)
                return [plugin + ':'].concat(mainArguments)
        Severity: Minor
        Found in lisa.js - About 1 hr to fix

          Function updateProfile has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            updateProfile(req, res) {
              req.app.multerAvatar.single('avatar')(req, res, err => {
                if (err) {
                  res.serverError(err)
                }
          Severity: Minor
          Found in api/controllers/UserController.js - About 1 hr to fix

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

              static schema(app, Sequelize) {
                return {
                  name: {
                    type: Sequelize.STRING,
                    allowNull: false,
            Severity: Minor
            Found in api/models/ChatBotParamList.js - About 1 hr to fix

              Function dispatchNotification has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                dispatchNotification(notification) {
                  return this.app.orm.Notification.create(notification).then(notification => {
                    this.sendWebNotification(notification)
              
                    if (notification.userId) {
              Severity: Minor
              Found in api/services/NotificationService.js - About 55 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

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

                start(req, res) {
                  this.app.services.IRService.start(req.params.remoteName)
                  res.send({})
                }
              Severity: Minor
              Found in api/controllers/IRController.js and 1 other location - About 55 mins to fix
              api/controllers/IRController.js on lines 20..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 53.

              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

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

                button(req, res) {
                  this.app.services.IRService.setButtonName(req.params.button)
                  res.send({})
                }
              Severity: Minor
              Found in api/controllers/IRController.js and 1 other location - About 55 mins to fix
              api/controllers/IRController.js on lines 10..13

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

              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

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

                          models.ChatBot.belongsTo(models.Plugin, {
                            as: 'plugin',
                            onDelete: 'CASCADE',
                            allowNull: true,
                            foreignKey: {
              Severity: Minor
              Found in api/models/ChatBot.js and 1 other location - About 50 mins to fix
              api/models/Plugin.js on lines 32..40

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

              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

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

                          models.Plugin.hasMany(models.ChatBot, {
                            as: 'chatbots',
                            onDelete: 'CASCADE',
                            allowNull: true,
                            foreignKey: {
              Severity: Minor
              Found in api/models/Plugin.js and 1 other location - About 50 mins to fix
              api/models/ChatBot.js on lines 16..24

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

              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

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

                  else {
                    response = footprintService.findAssociation(parentModel,
                      parentId, childAttribute, criteria, options)
                      .then(devices => favoritesService.populateFavorite(req.user.id, devices))
                  }
              Severity: Minor
              Found in api/controllers/RoomController.js and 1 other location - About 50 mins to fix
              api/controllers/RoomController.js on lines 28..32

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

              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

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

                  if (childId) {
                    response = footprintService.findAssociation(parentModel,
                      parentId, childAttribute, childId, options)
                      .then(devices => favoritesService.populateFavorite(req.user.id, devices))
                  }
              Severity: Minor
              Found in api/controllers/RoomController.js and 1 other location - About 50 mins to fix
              api/controllers/RoomController.js on lines 33..37

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

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

                interact(infos) {
                  if (infos.action === 'UNKNOWN') {
                    return Promise.resolve(infos)
                  }
                  else {
              Severity: Minor
              Found in api/services/PluginService.js - About 45 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 updateProfile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                updateProfile(req, res) {
                  req.app.multerAvatar.single('avatar')(req, res, err => {
                    if (err) {
                      res.serverError(err)
                    }
              Severity: Minor
              Found in api/controllers/UserController.js - About 45 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