yast/yast-yast2

View on GitHub
library/cwm/src/modules/TablePopup.rb

Summary

Maintainability
F
1 wk
Test Coverage

File TablePopup.rb has 787 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "yast"

module Yast
  class TablePopupClass < Module
    def main
Severity: Major
Found in library/cwm/src/modules/TablePopup.rb - About 1 day to fix

    Method TableHandle has a Cognitive Complexity of 79 (exceeds 5 allowed). Consider refactoring.
    Open

        def TableHandle(descr, key, event_descr)
          descr = deep_copy(descr)
          event_descr = deep_copy(event_descr)
          event_id = Ops.get(event_descr, "ID")
          UI.SetFocus(Id(:_tp_table))
    Severity: Minor
    Found in library/cwm/src/modules/TablePopup.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 TableHandle has 147 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def TableHandle(descr, key, event_descr)
          descr = deep_copy(descr)
          event_descr = deep_copy(event_descr)
          event_id = Ops.get(event_descr, "ID")
          UI.SetFocus(Id(:_tp_table))
    Severity: Major
    Found in library/cwm/src/modules/TablePopup.rb - About 5 hrs to fix

      Method CreateTableDescr has 125 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def CreateTableDescr(attrib, widget_descr)
            attrib = deep_copy(attrib)
            widget_descr = deep_copy(widget_descr)
            ValidateTableAttr(attrib)
      
      
      Severity: Major
      Found in library/cwm/src/modules/TablePopup.rb - About 5 hrs to fix

        Method singleOptionEditPopup has 85 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def singleOptionEditPopup(option)
              option = deep_copy(option)
              opt_key = Ops.get_string(option, "_cwm_key", "")
              opt_id = Ops.get(option, "_cwm_id")
        
        
        Severity: Major
        Found in library/cwm/src/modules/TablePopup.rb - About 3 hrs to fix

          Method singleOptionEditPopup has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              def singleOptionEditPopup(option)
                option = deep_copy(option)
                opt_key = Ops.get_string(option, "_cwm_key", "")
                opt_id = Ops.get(option, "_cwm_id")
          
          
          Severity: Minor
          Found in library/cwm/src/modules/TablePopup.rb - 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

          Class TablePopupClass has 24 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class TablePopupClass < Module
              def main
                Yast.import "UI"
                textdomain "base"
          
          
          Severity: Minor
          Found in library/cwm/src/modules/TablePopup.rb - About 2 hrs to fix

            Method askForNewOption has 55 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def askForNewOption(possible, editable, descr)
                  possible = deep_copy(possible)
                  descr = deep_copy(descr)
                  do_sort = !Ops.get_boolean(descr, "add_items_keep_order", false)
                  possible = Builtins.sort(possible) if do_sort
            Severity: Major
            Found in library/cwm/src/modules/TablePopup.rb - About 2 hrs to fix

              Method CreateTableDescr has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  def CreateTableDescr(attrib, widget_descr)
                    attrib = deep_copy(attrib)
                    widget_descr = deep_copy(widget_descr)
                    ValidateTableAttr(attrib)
              
              
              Severity: Minor
              Found in library/cwm/src/modules/TablePopup.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 ValidateValueType has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def ValidateValueType(key, value, widget, popup)
                    value = deep_copy(value)
                    success = true
                    if popup
                      case key
              Severity: Minor
              Found in library/cwm/src/modules/TablePopup.rb - About 1 hr to fix

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

                    def askForNewOption(possible, editable, descr)
                      possible = deep_copy(possible)
                      descr = deep_copy(descr)
                      do_sort = !Ops.get_boolean(descr, "add_items_keep_order", false)
                      possible = Builtins.sort(possible) if do_sort
                Severity: Minor
                Found in library/cwm/src/modules/TablePopup.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 updateOptionMap has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def updateOptionMap(opt_descr, fallbacks)
                      opt_descr = deep_copy(opt_descr)
                      fallbacks = deep_copy(fallbacks)
                      # ensure that the submaps exist
                      Ops.set(opt_descr, "table", Ops.get_map(opt_descr, "table", {}))
                Severity: Minor
                Found in library/cwm/src/modules/TablePopup.rb - About 1 hr to fix

                  Method TableRedraw has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def TableRedraw(descr, update_buttons)
                        descr = deep_copy(descr)
                        id_list = getIdList(descr)
                        @previous_selected_item = Ops.get(id_list, 0) if @previous_selected_item.nil?
                        entries = Builtins.maplist(id_list) do |opt_id|
                  Severity: Minor
                  Found in library/cwm/src/modules/TablePopup.rb - About 1 hr to fix

                    Method updateButtons has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def updateButtons(descr, opt_descr)
                          descr = deep_copy(descr)
                          opt_descr = deep_copy(opt_descr)
                          if Ops.get_boolean(descr, ["_cwm_attrib", "add_delete_buttons"], true)
                            UI.ChangeWidget(
                    Severity: Minor
                    Found in library/cwm/src/modules/TablePopup.rb - About 1 hr to fix

                      Method TableRedraw has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def TableRedraw(descr, update_buttons)
                            descr = deep_copy(descr)
                            id_list = getIdList(descr)
                            @previous_selected_item = Ops.get(id_list, 0) if @previous_selected_item.nil?
                            entries = Builtins.maplist(id_list) do |opt_id|
                      Severity: Minor
                      Found in library/cwm/src/modules/TablePopup.rb - About 55 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 ValidateValueType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def ValidateValueType(key, value, widget, popup)
                            value = deep_copy(value)
                            success = true
                            if popup
                              case key
                      Severity: Minor
                      Found in library/cwm/src/modules/TablePopup.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

                                      tableEntryChanged(opt_id, option_map) ? "*" : ""
                      Severity: Major
                      Found in library/cwm/src/modules/TablePopup.rb - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                      if Builtins.contains(present, opt_key)
                                        Report.Error(
                                          # error report
                                          _("The selected option is already present.")
                                        )
                        Severity: Major
                        Found in library/cwm/src/modules/TablePopup.rb - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                        return nil if opt_key.nil?
                          Severity: Major
                          Found in library/cwm/src/modules/TablePopup.rb - About 45 mins to fix

                            Method updateOptionMap has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def updateOptionMap(opt_descr, fallbacks)
                                  opt_descr = deep_copy(opt_descr)
                                  fallbacks = deep_copy(fallbacks)
                                  # ensure that the submaps exist
                                  Ops.set(opt_descr, "table", Ops.get_map(opt_descr, "table", {}))
                            Severity: Minor
                            Found in library/cwm/src/modules/TablePopup.rb - About 35 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

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

                                  Builtins.foreach(attr) do |k, v|
                                    type = Ops.get(types, k)
                                    if type.nil?
                                      Builtins.y2error("Unknown attribute %1", k)
                                      ret = false
                            Severity: Minor
                            Found in library/cwm/src/modules/TablePopup.rb and 1 other location - About 20 mins to fix
                            library/cwm/src/modules/CWMTable.rb on lines 64..71

                            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

                                  if event_id == :_tp_table && (Ops.get_string(event_descr, "EventReason", "") == "Activated" &&
                                        Ops.get_string(event_descr, "EventType", "") == "WidgetEvent" &&
                                        UI.WidgetExists(Id(:_tp_edit)))
                                    event_id = :_tp_edit
                                  end
                            Severity: Minor
                            Found in library/cwm/src/modules/TablePopup.rb and 1 other location - About 20 mins to fix
                            library/cwm/src/modules/CWMTable.rb on lines 212..216

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

                            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 !Builtins.haskey(Ops.get_map(opt_descr, "table", {}), "changed") &&
                                      Builtins.haskey(fallbacks, "changed")
                                    Ops.set(opt_descr, ["table", "changed"], Ops.get(fallbacks, "changed"))
                                  end
                            Severity: Minor
                            Found in library/cwm/src/modules/TablePopup.rb and 2 other locations - About 15 mins to fix
                            library/cwm/src/modules/TablePopup.rb on lines 241..244
                            library/cwm/src/modules/TablePopup.rb on lines 245..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 25.

                            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 !Builtins.haskey(Ops.get_map(opt_descr, "table", {}), "summary") &&
                                      Builtins.haskey(fallbacks, "summary")
                                    Ops.set(opt_descr, ["table", "summary"], Ops.get(fallbacks, "summary"))
                                  end
                            Severity: Minor
                            Found in library/cwm/src/modules/TablePopup.rb and 2 other locations - About 15 mins to fix
                            library/cwm/src/modules/TablePopup.rb on lines 245..252
                            library/cwm/src/modules/TablePopup.rb on lines 253..256

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

                            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 !Builtins.haskey(Ops.get_map(opt_descr, "table", {}), "label_func") &&
                                      Builtins.haskey(fallbacks, "label_func")
                                    Ops.set(
                                      opt_descr,
                                      ["table", "label_func"],
                            Severity: Minor
                            Found in library/cwm/src/modules/TablePopup.rb and 2 other locations - About 15 mins to fix
                            library/cwm/src/modules/TablePopup.rb on lines 241..244
                            library/cwm/src/modules/TablePopup.rb on lines 253..256

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

                            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