yast/yast-yast2

View on GitHub
library/control/src/modules/ProductControl.rb

Summary

Maintainability
F
1 wk
Test Coverage

File ProductControl.rb has 1138 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "yast"
require "yast2/control_log_dir_rotator"
require "yast2/popup"

module Yast
Severity: Major
Found in library/control/src/modules/ProductControl.rb - About 2 days to fix

    Method RunFrom has a Cognitive Complexity of 96 (exceeds 5 allowed). Consider refactoring.
    Open

        def RunFrom(from, allow_back)
          former_result = :next
          final_result = nil
          @current_step = from # current module
    
    
    Severity: Minor
    Found in library/control/src/modules/ProductControl.rb - About 1 day 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 RunFrom has 221 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def RunFrom(from, allow_back)
          former_result = :next
          final_result = nil
          @current_step = from # current module
    
    
    Severity: Major
    Found in library/control/src/modules/ProductControl.rb - About 1 day to fix

      Method AddWizardSteps has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
      Open

          def AddWizardSteps(stagemode)
            stagemode = deep_copy(stagemode)
            debug_workflow = ProductFeatures.GetBooleanFeature(
              "globals",
              "debug_workflow"
      Severity: Minor
      Found in library/control/src/modules/ProductControl.rb - About 7 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

      Class ProductControlClass has 47 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class ProductControlClass < Module
          include Yast::Logger
      
          # Product control system roles key
          # @return [String] System roles
      Severity: Minor
      Found in library/control/src/modules/ProductControl.rb - About 6 hrs to fix

        Method AddWizardSteps has 109 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def AddWizardSteps(stagemode)
              stagemode = deep_copy(stagemode)
              debug_workflow = ProductFeatures.GetBooleanFeature(
                "globals",
                "debug_workflow"
        Severity: Major
        Found in library/control/src/modules/ProductControl.rb - About 4 hrs to fix

          Method getMatchingProposal has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def getMatchingProposal(stage, mode, proptype)
                Builtins.y2milestone(
                  "Stage: %1 Mode: %2, Type: %3",
                  stage,
                  mode,
          Severity: Major
          Found in library/control/src/modules/ProductControl.rb - About 2 hrs to fix

            Method getProposals has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def getProposals(stage, mode, proptype)
                  props = getMatchingProposal(stage, mode, proptype)
                  unique_id = Ops.get_string(props, [0, "unique_id"], "")
                  disabled_subprops = GetDisabledSubProposals()
            
            
            Severity: Minor
            Found in library/control/src/modules/ProductControl.rb - About 1 hr to fix

              Method ReadControlFile has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def ReadControlFile(controlfile)
                    begin
                      @productControl = XML.XMLToYCPFile(controlfile)
                    rescue RuntimeError => e
                      log.error "Failed to read control file: #{e.inspect}"
              Severity: Minor
              Found in library/control/src/modules/ProductControl.rb - About 1 hr to fix

                Method main has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def main
                      Yast.import "UI"
                      textdomain "base"
                
                      Yast.import "XML"
                Severity: Minor
                Found in library/control/src/modules/ProductControl.rb - About 1 hr to fix

                  Method getProposals has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def getProposals(stage, mode, proptype)
                        props = getMatchingProposal(stage, mode, proptype)
                        unique_id = Ops.get_string(props, [0, "unique_id"], "")
                        disabled_subprops = GetDisabledSubProposals()
                  
                  
                  Severity: Minor
                  Found in library/control/src/modules/ProductControl.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 PrepareScripts has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def PrepareScripts(workflow)
                        workflow = deep_copy(workflow)
                        tmp_dir = Convert.to_string(WFM.Read(path(".local.tmpdir"), []))
                        if Builtins.haskey(workflow, "prescript")
                          interpreter = Ops.get_string(workflow, ["prescript", "interpreter"], "shell")
                  Severity: Minor
                  Found in library/control/src/modules/ProductControl.rb - About 1 hr to fix

                    Method DisableAllModulesAndProposals has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def DisableAllModulesAndProposals(mode, stage)
                          this_workflow = { "mode" => mode, "stage" => stage }
                    
                          if Builtins.contains(@already_disabled_workflows, this_workflow)
                            Builtins.y2milestone("Workflow %1 already disabled", this_workflow)
                    Severity: Minor
                    Found in library/control/src/modules/ProductControl.rb - About 1 hr to fix

                      Method UnDisableAllModulesAndProposals has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def UnDisableAllModulesAndProposals(mode, stage)
                            this_workflow = { "mode" => mode, "stage" => stage }
                      
                            # Such mode/stage not disabled
                            if !Builtins.contains(@already_disabled_workflows, this_workflow)
                      Severity: Minor
                      Found in library/control/src/modules/ProductControl.rb - About 1 hr to fix

                        Method getClientTerm has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def getClientTerm(step, def_, former_result)
                              step = deep_copy(step)
                              def_ = deep_copy(def_)
                              former_result = deep_copy(former_result)
                              client = getClientName(
                        Severity: Minor
                        Found in library/control/src/modules/ProductControl.rb - About 1 hr to fix

                          Method checkDisabled has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def checkDisabled(mod)
                                mod = deep_copy(mod)
                                if mod.nil?
                                  Builtins.y2error("Unknown module %1", mod)
                                  return nil
                          Severity: Minor
                          Found in library/control/src/modules/ProductControl.rb - 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

                          Method RunRequired has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def RunRequired(stage, mode)
                                modules = getModules(stage, mode, :enabled)
                          
                                if modules.nil?
                                  Builtins.y2error("Undefined %1/%2", stage, mode)
                          Severity: Minor
                          Found in library/control/src/modules/ProductControl.rb - 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

                          Method PrepareScripts has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def PrepareScripts(workflow)
                                workflow = deep_copy(workflow)
                                tmp_dir = Convert.to_string(WFM.Read(path(".local.tmpdir"), []))
                                if Builtins.haskey(workflow, "prescript")
                                  interpreter = Ops.get_string(workflow, ["prescript", "interpreter"], "shell")
                          Severity: Minor
                          Found in library/control/src/modules/ProductControl.rb - 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

                          Avoid deeply nested control flow statements.
                          Open

                                        minimum_step = Ops.add(minimum_step, 1) if Ops.less_or_equal(@current_step, minimum_step) && !allow_back
                          Severity: Major
                          Found in library/control/src/modules/ProductControl.rb - About 45 mins to fix

                            Method CheckAdditionalParams has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def CheckAdditionalParams(check_workflow)
                                  if @_additional_workflow_params.nil? ||
                                      @_additional_workflow_params == {}
                                    return true
                                  end
                            Severity: Minor
                            Found in library/control/src/modules/ProductControl.rb - About 25 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

                            Method getClientName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def getClientName(name, execute)
                                  return "inst_test_workflow" if Mode.test
                            
                                  # BNC #401319
                                  # 'execute; is defined and thus returned
                            Severity: Minor
                            Found in library/control/src/modules/ProductControl.rb - About 25 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

                                  if Builtins.haskey(workflow, "postscript")
                                    interpreter = Ops.get_string(workflow, ["postscript", "interpreter"], "shell")
                                    source = Ops.get_string(workflow, ["postscript", "source"], "")
                                    type = (interpreter == "shell") ? "sh" : "pl"
                                    f = Builtins.sformat(
                            Severity: Major
                            Found in library/control/src/modules/ProductControl.rb and 1 other location - About 1 hr to fix
                            library/control/src/modules/ProductControl.rb on lines 519..534

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

                            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 Builtins.haskey(workflow, "prescript")
                                    interpreter = Ops.get_string(workflow, ["prescript", "interpreter"], "shell")
                                    source = Ops.get_string(workflow, ["prescript", "source"], "")
                                    type = (interpreter == "shell") ? "sh" : "pl"
                                    f = Builtins.sformat(
                            Severity: Major
                            Found in library/control/src/modules/ProductControl.rb and 1 other location - About 1 hr to fix
                            library/control/src/modules/ProductControl.rb on lines 538..553

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

                            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

                                def DisableModule(modname)
                                  if modname.nil? || modname == ""
                                    Builtins.y2error("Module to disable is '%1'", modname)
                                  else
                                    @DisabledModules = Convert.convert(
                            Severity: Minor
                            Found in library/control/src/modules/ProductControl.rb and 1 other location - About 20 mins to fix
                            library/control/src/modules/ProductControl.rb on lines 196..207

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

                            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

                                def DisableProposal(disable_proposal)
                                  if disable_proposal.nil? || disable_proposal == ""
                                    Builtins.y2error("Module to disable is '%1'", disable_proposal)
                                  else
                                    @DisabledProposals = Convert.convert(
                            Severity: Minor
                            Found in library/control/src/modules/ProductControl.rb and 1 other location - About 20 mins to fix
                            library/control/src/modules/ProductControl.rb on lines 163..174

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

                            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

                                        label = if Builtins.haskey(m, "textdomain")
                                          Builtins.dgettext(
                                            Ops.get_string(m, "textdomain", ""),
                                            Ops.get_string(m, "label", "")
                                          )
                            Severity: Minor
                            Found in library/control/src/modules/ProductControl.rb and 1 other location - About 15 mins to fix
                            library/control/src/modules/ProductControl.rb on lines 835..843

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

                            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

                                        heading = if Builtins.haskey(m, "textdomain")
                                          Builtins.dgettext(
                                            Ops.get_string(m, "textdomain", ""),
                                            Ops.get_string(m, "label", "")
                                          )
                            Severity: Minor
                            Found in library/control/src/modules/ProductControl.rb and 1 other location - About 15 mins to fix
                            library/control/src/modules/ProductControl.rb on lines 851..859

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

                            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