File CWM.rb
has 784 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "yast"
require "cwm/abstract_widget"
module Yast
Method Run
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
def Run(widgets, functions, skip_store_for: [])
widgets = deep_copy(widgets)
functions = deep_copy(functions)
widgets = mergeFunctions(widgets, functions)
PushSettings()
- 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 prepareWidget
has 139 lines of code (exceeds 25 allowed). Consider refactoring. Open
def prepareWidget(widget_descr)
widget_descr = deep_copy(widget_descr)
w = deep_copy(widget_descr)
widget = Ops.get_symbol(w, "widget", :inputfield)
Class CWMClass
has 39 methods (exceeds 20 allowed). Consider refactoring. Open
class CWMClass < Module
def main
Yast.import "UI"
textdomain "base"
Method ProcessTerm
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def ProcessTerm(term, widgets)
return term if term.empty?
ret = Yast::Term.new(term.value)
- 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 Run
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def Run(widgets, functions, skip_store_for: [])
widgets = deep_copy(widgets)
functions = deep_copy(functions)
widgets = mergeFunctions(widgets, functions)
PushSettings()
Method ValidateMaps
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def ValidateMaps(widgets)
widgets = deep_copy(widgets)
ret = true
Builtins.foreach(widgets) do |k, v|
Builtins.foreach(v) do |kk, vv|
- 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 ValidateMaps
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ValidateMaps(widgets)
widgets = deep_copy(widgets)
ret = true
Builtins.foreach(widgets) do |k, v|
Builtins.foreach(v) do |kk, vv|
Method validateWidget
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def validateWidget(widget, event, key)
widget = deep_copy(widget)
event = deep_copy(event)
self.processed_widget = deep_copy(widget)
failed = false
Method prepareWidget
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def prepareWidget(widget_descr)
widget_descr = deep_copy(widget_descr)
w = deep_copy(widget_descr)
widget = Ops.get_symbol(w, "widget", :inputfield)
- 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 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ValidateValueType(key, value, widget)
types = {
# general
"widget" => "symbol",
"custom_widget" => "term",
Method ShowAndRun
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ShowAndRun(settings)
settings = deep_copy(settings)
if settings["widgets"]
widgets = settings["widgets"]
settings["widget_names"] ||= []
Method validateWidget
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def validateWidget(widget, event, key)
widget = deep_copy(widget)
event = deep_copy(event)
self.processed_widget = deep_copy(widget)
failed = false
- 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 ValidateValueContents
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def ValidateValueContents(key, value, widget)
error = ""
case key
when "label"
s = Convert.to_string(value)
- 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 StringsOfTerm
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def StringsOfTerm(term)
term = deep_copy(term)
rets = []
args = Builtins.size(term)
index = 0
- 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 AdjustButtons
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def AdjustButtons(next_, back, abort, _help)
next_ = "" if next_.nil?
back = "" if back.nil?
abort = "" if abort.nil?
if next_ == ""
- 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 ShowAndRunOrig
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def ShowAndRunOrig(widget_names, widget_descr, contents, caption, back_button, next_button, fallback)
Avoid deeply nested control flow statements. Open
ret = nil unless functions[:abort].call
Consider simplifying this complex logical expression. Open
if key != "label" ||
(Ops.get(v, "widget") != :radio_buttons &&
Ops.get(v, "widget") != :custom &&
Ops.get(v, "widget") != :rich_text &&
Ops.get(v, "widget") != :func)
Method handleWidgets
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def handleWidgets(widgets, event_descr)
event_descr = deep_copy(event_descr)
ret = nil
Builtins.foreach(widgets) do |w|
if ret.nil?
- 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 widgets_in_contents
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def widgets_in_contents(contents)
contents.each_with_object([]) do |arg, res|
case arg
when ::CWM::AbstractWidget
res << arg
- 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 show
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def show(contents, caption: nil, back_button: nil, next_button: nil, abort_button: nil, skip_store_for: [],
disable_buttons: [], next_handler: nil, back_handler: nil, abort_handler: nil)
widgets = widgets_in_contents(contents)
options = {
"contents" => widgets_contents(contents),
- 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 ValidateBasicType
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def ValidateBasicType(value, type)
return Ops.is_term?(value) if type == "term"
return Ops.is_string?(value) if type == "string"
return Ops.is_symbol?(value) if type == "symbol"
return Ops.is_list?(value) if type == "list"
- 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 too many return
statements within this method. Open
return Ops.is_map?(value) if type == "map"
Avoid too many return
statements within this method. Open
return Ops.is_boolean?(value) if type == "boolean"
Avoid too many return
statements within this method. Open
return Ops.is_integer?(value) if type == "integer"
Method ValidateValueType
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def ValidateValueType(key, value, widget)
types = {
# general
"widget" => "symbol",
"custom_widget" => "term",
- 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 DisableButtons
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def DisableButtons(buttons)
Builtins.foreach(buttons) do |button|
Wizard.DisableBackButton if button == "back_button"
Wizard.DisableAbortButton if button == "abort_button"
Wizard.DisableNextButton if button == "next_button"
- 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
Similar blocks of code found in 4 locations. Consider refactoring. Open
when :selection_box
Ops.set(
w,
"widget",
SelectionBox(
- 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 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
- 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 4 locations. Consider refactoring. Open
when :multi_selection_box
Ops.set(
w,
"widget",
MultiSelectionBox(
- 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 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
- 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 4 locations. Consider refactoring. Open
when :combobox
Ops.set(
w,
"widget",
ComboBox(
- 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 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
- 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 4 locations. Consider refactoring. Open
when :menu_button
Ops.set(
w,
"widget",
MenuButton(
- 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 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
- 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