DeflatedPickle/Quiver

View on GitHub
core/src/main/kotlin/com/deflatedpickle/quiver/backend/util/ActionUtil.kt

Summary

Maintainability
F
4 days
Test Coverage

Method newPack has a Cognitive Complexity of 141 (exceeds 20 allowed). Consider refactoring.
Open

    fun newPack() {
        val dialog = NewDialog()
        dialog.isVisible = true

        if (dialog.result == TaskDialog.StandardCommand.OK) {

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

    fun newPack() {
        val dialog = NewDialog()
        dialog.isVisible = true

        if (dialog.result == TaskDialog.StandardCommand.OK) {

    Method openPack has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        fun openPack() {
            val directoryChooser = JFileChooser(
                DotMinecraft.dotMinecraft.resolve("resourcepacks").absolutePath
            ).apply {
                fileSelectionMode = JFileChooser.DIRECTORIES_ONLY

      Avoid deeply nested control flow statements.
      Open

                                          textures = if (isSelected("assets/minecraft/textures")) PackUtil.PackStructure.Minecraft.Textures(
                                              block = isSelected("assets/minecraft/textures/block"),
                                              colourmap = isSelected("assets/minecraft/textures/colourmap"),
                                              effect = isSelected("assets/minecraft/textures/effect"),
                                              entity = isSelected("assets/minecraft/textures/entity"),

        Avoid deeply nested control flow statements.
        Open

                                            models = if (isSelected("assets/minecraft/models")) PackUtil.PackStructure.Minecraft.Models(
                                                block = isSelected("assets/minecraft/models/block"),
                                                item = isSelected("assets/minecraft/models/item")
                                            ) else null,

          Avoid deeply nested control flow statements.
          Open

                                              shaders = if (isSelected("assets/minecraft/shaders")) PackUtil.PackStructure.Minecraft.Shaders(
                                                  post = isSelected("assets/minecraft/shaders/post"),
                                                  program = isSelected("assets/minecraft/shaders/program")
                                              ) else null,

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

                                                shaders = if (isSelected("assets/minecraft/shaders")) PackUtil.PackStructure.Minecraft.Shaders(
                                                    post = isSelected("assets/minecraft/shaders/post"),
                                                    program = isSelected("assets/minecraft/shaders/program")
                                                ) else null,
            core/src/main/kotlin/com/deflatedpickle/quiver/backend/util/ActionUtil.kt on lines 59..62

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

            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 = if (isSelected("assets/minecraft/models")) PackUtil.PackStructure.Minecraft.Models(
                                                    block = isSelected("assets/minecraft/models/block"),
                                                    item = isSelected("assets/minecraft/models/item")
                                                ) else null,
            core/src/main/kotlin/com/deflatedpickle/quiver/backend/util/ActionUtil.kt on lines 65..68

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

            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

                                                        container = if (isSelected("assets/minecraft/textures/gui/container")) PackUtil.PackStructure.Minecraft.Textures.GUI.Container(
                                                            creativeInventory = isSelected("assets/minecraft/textures/gui/container/creative_inventory")
                                                        ) else null,
            core/src/main/kotlin/com/deflatedpickle/quiver/backend/util/ActionUtil.kt on lines 78..80
            core/src/main/kotlin/com/deflatedpickle/quiver/backend/util/ActionUtil.kt on lines 85..87

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

            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

                                                        advancements = if (isSelected("assets/minecraft/textures/gui/advancements")) PackUtil.PackStructure.Minecraft.Textures.GUI.Advancements(
                                                            backgrounds = isSelected("assets/minecraft/textures/gui/advancements/backgrounds")
                                                        ) else null,
            core/src/main/kotlin/com/deflatedpickle/quiver/backend/util/ActionUtil.kt on lines 81..83
            core/src/main/kotlin/com/deflatedpickle/quiver/backend/util/ActionUtil.kt on lines 85..87

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

            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

                                                        title = if (isSelected("assets/minecraft/textures/gui/title")) PackUtil.PackStructure.Minecraft.Textures.GUI.Title(
                                                            background = isSelected("assets/minecraft/textures/gui/title/background")
                                                        ) else null
            core/src/main/kotlin/com/deflatedpickle/quiver/backend/util/ActionUtil.kt on lines 78..80
            core/src/main/kotlin/com/deflatedpickle/quiver/backend/util/ActionUtil.kt on lines 81..83

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

            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