OpenC3/cosmos

View on GitHub
openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/Widget.js

Summary

Maintainability
F
3 days
Test Coverage

Function applySetting has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    applySetting(style, setting) {
      switch (setting[0]) {
        case 'TEXTALIGN':
          style['text-align'] = setting[1].toLowerCase() + ' !important'
          style['--text-align'] = setting[1].toLowerCase()

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

        setHeight(height, units = 'px', defaultHeight = '20') {
          // Don't set the height if someone has already set it
          let foundSetting = null
          if (this.widgetIndex !== null) {
            foundSetting = this.settings.find(

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

          setWidth(width, units = 'px', defaultWidth = '120') {
            // Don't set the width if someone has already set it
            // This is important in PacketViewer which uses the value-widget
            // and passes an explicit width setting to use
            let foundSetting = null

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

              if (foundSetting) {
                return foundSetting['HEIGHT']
              } else {
                if (height) {
                  let setting = ['HEIGHT', `${height}${units}`]
        openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/Widget.js on lines 201..220

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

        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 (foundSetting) {
                return foundSetting['WIDTH']
              } else {
                if (width) {
                  let setting = ['WIDTH', `${width}${units}`]
        openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/Widget.js on lines 233..252

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

        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 (this.widgetIndex !== null) {
                foundSetting = this.settings.find(
                  (setting) =>
                    parseInt(setting[0]) === this.widgetIndex && setting[1] === 'WIDTH'
                )
        openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/Widget.js on lines 225..232

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

        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 (this.widgetIndex !== null) {
                foundSetting = this.settings.find(
                  (setting) =>
                    parseInt(setting[0]) === this.widgetIndex && setting[1] === 'HEIGHT'
                )
        openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/Widget.js on lines 193..200

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

        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 4 locations. Consider refactoring.
        Open

                case 'WIDTH':
                  if (!isNaN(Number(setting[1]))) {
                    setting[1] += 'px'
                  }
                  style['width'] = setting[1] + ' !important'
        openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/Widget.js on lines 115..120
        openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/Widget.js on lines 121..126
        openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/Widget.js on lines 146..151

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

        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 4 locations. Consider refactoring.
        Open

                case 'MARGIN':
                  if (!isNaN(Number(setting[1]))) {
                    setting[1] += 'px'
                  }
                  style['margin'] = setting[1] + ' !important'
        openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/Widget.js on lines 115..120
        openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/Widget.js on lines 140..145
        openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/Widget.js on lines 146..151

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

        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 4 locations. Consider refactoring.
        Open

                case 'PADDING':
                  if (!isNaN(Number(setting[1]))) {
                    setting[1] += 'px'
                  }
                  style['padding'] = setting[1] + ' !important'
        openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/Widget.js on lines 121..126
        openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/Widget.js on lines 140..145
        openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/Widget.js on lines 146..151

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

        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 4 locations. Consider refactoring.
        Open

                case 'HEIGHT':
                  if (!isNaN(Number(setting[1]))) {
                    setting[1] += 'px'
                  }
                  style['height'] = setting[1] + ' !important'
        openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/Widget.js on lines 115..120
        openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/Widget.js on lines 121..126
        openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/Widget.js on lines 140..145

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

        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

        There are no issues that match your filters.

        Category
        Status