File TablePopup.rb
has 787 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "yast"
module Yast
class TablePopupClass < Module
def main
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))
- Read upRead up
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))
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)
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")
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")
- Read upRead up
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"
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
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)
- Read upRead up
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
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
- Read upRead up
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", {}))
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|
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(
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|
- Read upRead up
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
- Read upRead up
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) ? "*" : ""
Avoid deeply nested control flow statements. Open
if Builtins.contains(present, opt_key)
Report.Error(
# error report
_("The selected option is already present.")
)
Avoid deeply nested control flow statements. Open
return nil if opt_key.nil?
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", {}))
- Read upRead up
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
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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"],
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76