DeflatedPickle/FAOSDance

View on GitHub

Showing 178 of 178 total issues

File GlobalValues.kt has 499 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package com.deflatedpickle.faosdance.util

import com.deflatedpickle.faosdance.*
import com.deflatedpickle.faosdance.backend.Direction
import com.deflatedpickle.faosdance.backend.NestedHashMap
Severity: Minor
Found in src/main/kotlin/com/deflatedpickle/faosdance/util/GlobalValues.kt - About 1 day to fix

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

            yScaleWidgets = GlobalValues.addComponentSliderSpinner<Double>(
                this,
                this.layout as GridBagLayout,
                JLabel("${Lang.bundle.getString("settings.size.height")}:"),
                GlobalValues.optionsMap.getMap("sprite")!!.getMap("size")!!.getOption<Double>("height")!!,
    src/main/kotlin/com/deflatedpickle/faosdance/gui/settings/general/ScaleCategory.kt on lines 39..52

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

    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

            xScaleWidgets = GlobalValues.addComponentSliderSpinner<Double>(
                this,
                this.layout as GridBagLayout,
                JLabel("${Lang.bundle.getString("settings.size.width")}:"),
                GlobalValues.optionsMap.getMap("sprite")!!.getMap("size")!!.getOption<Double>("width")!!,
    src/main/kotlin/com/deflatedpickle/faosdance/gui/settings/general/ScaleCategory.kt on lines 57..70

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

    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

            fadeHeightWidgets = GlobalValues.addComponentSliderSpinner<Double>(
                this,
                this.layout as GridBagLayout,
                JLabel("${Lang.bundle.getString("settings.reflection.fade.height")}:"),
                GlobalValues.optionsMap.getMap("reflection")!!.getMap("fade")!!.getOption<Double>("height")!!,
    src/main/kotlin/com/deflatedpickle/faosdance/gui/settings/general/FadeCategory.kt on lines 37..49

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

    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

            fadeOpacityWidgets = GlobalValues.addComponentSliderSpinner<Double>(
                this,
                this.layout as GridBagLayout,
                JLabel("${Lang.bundle.getString("settings.reflection.fade.opacity")}:"),
                GlobalValues.optionsMap.getMap("reflection")!!.getMap("fade")!!.getOption<Double>("opacity")!!,
    src/main/kotlin/com/deflatedpickle/faosdance/gui/settings/general/FadeCategory.kt on lines 20..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 471.

    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

    Method paintComponent has 112 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        override fun paintComponent(g: Graphics) {
            super.paintComponent(g)
    
            if (GlobalValues.sheet == null) return
    
    
    Severity: Major
    Found in src/main/kotlin/com/deflatedpickle/faosdance/gui/SpritePanel.kt - About 4 hrs to fix

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

                      GlobalValues.optionsMap.getMap("sprite")!!.getMap("rotation")!!.setOption("z", when {
                          (it.source as JSpinner).model.value is Int -> (it.source as JSpinner).model.value as Int
                          (it.source as JSpinner).model.value is Double -> ((it.source as JSpinner).model.value as Double).roundToInt()
                          else -> 0
                      })
      src/main/kotlin/com/deflatedpickle/faosdance/gui/settings/general/AnimationCategory.kt on lines 61..65
      src/main/kotlin/com/deflatedpickle/faosdance/gui/settings/general/AnimationCategory.kt on lines 105..109

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

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

                      GlobalValues.optionsMap.getMap("sprite")!!.getMap("animation")!!.setOption("frame", when {
                          (it.source as JSpinner).model.value is Int -> (it.source as JSpinner).model.value as Int
                          (it.source as JSpinner).model.value is Double -> ((it.source as JSpinner).model.value as Double).roundToInt()
                          else -> 0
                      })
      src/main/kotlin/com/deflatedpickle/faosdance/gui/settings/general/AnimationCategory.kt on lines 61..65
      src/main/kotlin/com/deflatedpickle/faosdance/gui/settings/general/RotationCategory.kt on lines 30..34

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

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

                      GlobalValues.optionsMap.getMap("sprite")!!.getMap("animation")!!.setOption("fps", when {
                          (it.source as JSpinner).model.value is Int -> (it.source as JSpinner).model.value as Int
                          (it.source as JSpinner).model.value is Double -> ((it.source as JSpinner).model.value as Double).roundToInt()
                          else -> 0
                      })
      src/main/kotlin/com/deflatedpickle/faosdance/gui/settings/general/AnimationCategory.kt on lines 105..109
      src/main/kotlin/com/deflatedpickle/faosdance/gui/settings/general/RotationCategory.kt on lines 30..34

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

      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

      Method addComponentRangeSliderSpinner has 101 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          inline fun <reified T : Number> addComponentRangeSliderSpinner(
              parent: Container,
              gridBagLayout: GridBagLayout,
              component: JComponent,
              highValue: Number,
      Severity: Major
      Found in src/main/kotlin/com/deflatedpickle/faosdance/util/GlobalValues.kt - About 4 hrs to fix

        Method paintComponent has a Cognitive Complexity of 42 (exceeds 20 allowed). Consider refactoring.
        Open

            override fun paintComponent(g: Graphics) {
                super.paintComponent(g)
        
                if (GlobalValues.sheet == null) return
        
        
        Severity: Minor
        Found in src/main/kotlin/com/deflatedpickle/faosdance/gui/SpritePanel.kt - About 3 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

        Method settings has 95 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def settings(panel)
            @red_widgets = FAOSDanceSettings.createOptionInteger panel, "Red:", @default, 255, 0.0
            @red_widgets.third.addChangeListener {|it|
              @red = it.source.to_java(javax::swing::JSpinner).model.value.to_java(java::lang::Float).intValue
              GlobalValues.setOption "colour_overlay-red", @red
        Severity: Major
        Found in src/main/resources/scripts/colour_overlay_extension.rb - About 3 hrs to fix

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

                  spinner.addChangeListener {
                      slider.value = when (T::class) {
                          Int::class -> when {
                              spinner.value is Int -> spinner.value as Int
                              spinner.value is Double -> (spinner.value as Double).roundToInt()
          src/main/kotlin/com/deflatedpickle/faosdance/util/GlobalValues.kt on lines 479..489
          src/main/kotlin/com/deflatedpickle/faosdance/util/GlobalValues.kt on lines 490..500

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

          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

              fun addLabelRangeSliderSpinnerInteger(
                  parent: Container,
                  gridBagLayout: GridBagLayout,
                  name: String,
                  highValue: Number,
          src/main/kotlin/com/deflatedpickle/faosdance/util/GlobalValues.kt on lines 533..551

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

          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

              fun addLabelRangeSliderSpinnerDouble(
                  parent: Container,
                  gridBagLayout: GridBagLayout,
                  name: String,
                  highValue: Number,
          src/main/kotlin/com/deflatedpickle/faosdance/util/GlobalValues.kt on lines 553..571

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

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

                  lowSpinner.addChangeListener {
                      slider.lowValue = when (T::class) {
                          Int::class -> when {
                              lowSpinner.value is Int -> lowSpinner.value as Int
                              lowSpinner.value is Double -> (lowSpinner.value as Double).roundToInt()
          src/main/kotlin/com/deflatedpickle/faosdance/util/GlobalValues.kt on lines 379..389
          src/main/kotlin/com/deflatedpickle/faosdance/util/GlobalValues.kt on lines 490..500

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

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

                  highSpinner.addChangeListener {
                      slider.highValue = when (T::class) {
                          Int::class -> when {
                              highSpinner.value is Int -> highSpinner.value as Int
                              highSpinner.value is Double -> (highSpinner.value as Double).roundToInt()
          src/main/kotlin/com/deflatedpickle/faosdance/util/GlobalValues.kt on lines 379..389
          src/main/kotlin/com/deflatedpickle/faosdance/util/GlobalValues.kt on lines 479..489

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

          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

                  yLocationWidgets = GlobalValues.addComponentSliderSpinner<Int>(
                      this,
                      this.layout as GridBagLayout,
                      JLabel("${Lang.bundle.getString("settings.location.y")}:"),
                      GlobalValues.optionsMap.getMap("window")!!.getMap("location")!!.getOption<Int>("y")!!,
          src/main/kotlin/com/deflatedpickle/faosdance/gui/settings/general/LocationCategory.kt on lines 24..31

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

          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

                  xLocationWidgets = GlobalValues.addComponentSliderSpinner<Int>(
                      this,
                      this.layout as GridBagLayout,
                      JLabel("${Lang.bundle.getString("settings.location.x")}:"),
                      GlobalValues.optionsMap.getMap("window")!!.getMap("location")!!.getOption<Int>("x")!!,
          src/main/kotlin/com/deflatedpickle/faosdance/gui/settings/general/LocationCategory.kt on lines 58..65

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

          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

          Method addComponentSliderSpinner has 69 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              inline fun <reified T : Number> addComponentSliderSpinner(
                  parent: Container,
                  gridBagLayout: GridBagLayout,
                  component: JComponent,
                  defaultValue: Number,
          Severity: Major
          Found in src/main/kotlin/com/deflatedpickle/faosdance/util/GlobalValues.kt - About 2 hrs to fix
            Severity
            Category
            Status
            Source
            Language