yast/yast-yast2

View on GitHub
library/packages/src/modules/PackagesUI.rb

Summary

Maintainability
F
5 days
Test Coverage

File PackagesUI.rb has 599 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "yast"
require "cgi"
require "packages/commit_result"
require "packages/update_messages_view"

Severity: Major
Found in library/packages/src/modules/PackagesUI.rb - About 1 day to fix

    Method InstallationSummary has 179 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def InstallationSummary(summary)
          ret = ""
    
          if Builtins.haskey(summary, "success")
            ret = HTML.Para(
    Severity: Major
    Found in library/packages/src/modules/PackagesUI.rb - About 7 hrs to fix

      Method ShowInstallationSummaryMap has 92 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def ShowInstallationSummaryMap(summary)
            summary_str = InstallationSummary(summary)
      
            if summary["installed"] == 0 && summary["updated"] == 0 && summary["removed"] == 0 && summary["remaining"] == []
              Builtins.y2warning("No summary, skipping summary dialog")
      Severity: Major
      Found in library/packages/src/modules/PackagesUI.rb - About 3 hrs to fix

        Method ConfirmLicenses has 74 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def ConfirmLicenses
              ret = true
        
              to_install = Pkg.GetPackages(:selected, true)
              licenses = Pkg.PkgGetLicensesToConfirm(to_install)
        Severity: Major
        Found in library/packages/src/modules/PackagesUI.rb - About 2 hrs to fix

          Method ShowInstallationSummaryMap has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              def ShowInstallationSummaryMap(summary)
                summary_str = InstallationSummary(summary)
          
                if summary["installed"] == 0 && summary["updated"] == 0 && summary["removed"] == 0 && summary["remaining"] == []
                  Builtins.y2warning("No summary, skipping summary dialog")
          Severity: Minor
          Found in library/packages/src/modules/PackagesUI.rb - About 2 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 RunPatternSelector has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def RunPatternSelector(enable_back: false, cancel_label: Label.CancelButton)
                Builtins.y2milestone("Running pattern selection dialog")
          
                if !UI.HasSpecialWidget(:PatternSelector) ||
                    UI.WizardCommand(term(:Ping)) != true
          Severity: Major
          Found in library/packages/src/modules/PackagesUI.rb - About 2 hrs to fix

            Method InstallationSummary has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

                def InstallationSummary(summary)
                  ret = ""
            
                  if Builtins.haskey(summary, "success")
                    ret = HTML.Para(
            Severity: Minor
            Found in library/packages/src/modules/PackagesUI.rb - About 2 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 RunPackageSelector has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def RunPackageSelector(options)
                  options = deep_copy(options)
                  Builtins.y2milestone("Called RunPackageSelector(%1)", options)
            
                  enable_repo_mgr = Ops.get_boolean(options, "enable_repo_mgr")
            Severity: Minor
            Found in library/packages/src/modules/PackagesUI.rb - About 1 hr to fix

              Method ConfirmLicenses has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def ConfirmLicenses
                    ret = true
              
                    to_install = Pkg.GetPackages(:selected, true)
                    licenses = Pkg.PkgGetLicensesToConfirm(to_install)
              Severity: Minor
              Found in library/packages/src/modules/PackagesUI.rb - 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

              Method RunPatternSelector has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def RunPatternSelector(enable_back: false, cancel_label: Label.CancelButton)
                    Builtins.y2milestone("Running pattern selection dialog")
              
                    if !UI.HasSpecialWidget(:PatternSelector) ||
                        UI.WizardCommand(term(:Ping)) != true
              Severity: Minor
              Found in library/packages/src/modules/PackagesUI.rb - 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

              Method RunPackageSelector has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def RunPackageSelector(options)
                    options = deep_copy(options)
                    Builtins.y2milestone("Called RunPackageSelector(%1)", options)
              
                    enable_repo_mgr = Ops.get_boolean(options, "enable_repo_mgr")
              Severity: Minor
              Found in library/packages/src/modules/PackagesUI.rb - 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

              Method DisplayHelpMsg has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def DisplayHelpMsg(headline, helptext, color, vdim)
                    helptext = deep_copy(helptext)
                    dia_opt = Opt(:decorated)
              
                    case color
              Severity: Minor
              Found in library/packages/src/modules/PackagesUI.rb - About 1 hr to fix

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

                      if Ops.greater_than(Ops.get_integer(summary, "installed", 0), 0)
                        items = Builtins.add(
                          items,
                          Ops.add(
                            Ops.add(
                Severity: Minor
                Found in library/packages/src/modules/PackagesUI.rb and 2 other locations - About 35 mins to fix
                library/packages/src/modules/PackagesUI.rb on lines 503..516
                library/packages/src/modules/PackagesUI.rb on lines 522..535

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

                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

                      if Ops.greater_than(Ops.get_integer(summary, "updated", 0), 0)
                        items = Builtins.add(
                          items,
                          Ops.add(
                            Ops.add(
                Severity: Minor
                Found in library/packages/src/modules/PackagesUI.rb and 2 other locations - About 35 mins to fix
                library/packages/src/modules/PackagesUI.rb on lines 484..497
                library/packages/src/modules/PackagesUI.rb on lines 522..535

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

                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

                      if Ops.greater_than(Ops.get_integer(summary, "removed", 0), 0)
                        items = Builtins.add(
                          items,
                          Ops.add(
                            Ops.add(
                Severity: Minor
                Found in library/packages/src/modules/PackagesUI.rb and 2 other locations - About 35 mins to fix
                library/packages/src/modules/PackagesUI.rb on lines 484..497
                library/packages/src/modules/PackagesUI.rb on lines 503..516

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

                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