File Popup.rb
has 1135 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "yast"
require "erb"
# when we need to modify some old method, then sometimes it is easier to replace it with new one
require "yast2/popup"
Class PopupClass
has 68 methods (exceeds 20 allowed). Consider refactoring. Open
class PopupClass < Module
def main
Yast.import "UI"
textdomain "base"
Method popupLayoutInternalTypeWithLabel
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def popupLayoutInternalTypeWithLabel(headline, message, button_box, label, richtext, width, height)
button_box = deep_copy(button_box)
rt = VWeight(
1,
VBox(
- 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 AnyQuestion3
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
def AnyQuestion3(headline, message, yes_button_message, no_button_message, retry_button_message, focus)
yes_button = Empty()
no_button = Empty()
retry_button = Empty()
Method ConfirmAbort
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ConfirmAbort(severity)
what_will_happen = ""
# Confirm user request to abort installation
abort_label = _("Really abort the installation?")
Method anyMessageDetailsInternalType
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
def anyMessageDetailsInternalType(headline, message, details, richtext, width, height)
button_box = ButtonBox(
PushButton(Id(:ok_msg), Opt(:default, :okButton), Label.OKButton),
# FIXME: BNC #422612, Use `opt(`noSanityCheck) later
# button label
Method TimedAnyQuestion
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def TimedAnyQuestion(headline, message, yes_button_message, no_button_message, focus, timeout_seconds)
button_box = AnyQuestionButtonBox(
yes_button_message,
no_button_message,
focus
- 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 popupLayoutInternalTypeWithLabel
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def popupLayoutInternalTypeWithLabel(headline, message, button_box, label, richtext, width, height)
button_box = deep_copy(button_box)
rt = VWeight(
1,
VBox(
Method TimedOKCancel
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def TimedOKCancel(message, timeout_seconds)
success = UI.OpenDialog(
Opt(:decorated),
HBox(
HSpacing(1),
- 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 TimedAnyQuestion
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def TimedAnyQuestion(headline, message, yes_button_message, no_button_message, focus, timeout_seconds)
button_box = AnyQuestionButtonBox(
yes_button_message,
no_button_message,
focus
Method TimedOKCancel
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def TimedOKCancel(message, timeout_seconds)
success = UI.OpenDialog(
Opt(:decorated),
HBox(
HSpacing(1),
Method ShowTextTimed
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ShowTextTimed(headline, text, timeout)
heading = if Builtins.size(headline) == 0
VSpacing(0.2)
else
Heading(headline)
Method ModuleError
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ModuleError(text)
success = UI.OpenDialog(
Opt(:decorated, :warncolor),
HBox(
HSpacing(1),
Method anyTimedMessageTypeInternal
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def anyTimedMessageTypeInternal(headline, message, timeout, richtext, width, height)
button_box = ButtonBox(
# FIXME: BNC #422612, Use `opt(`noSanityCheck) later
PushButton(Id(:stop), Opt(:cancelButton), Label.StopButton),
PushButton(Id(:ok_msg), Opt(:default, :okButton), Label.OKButton)
- 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 AnyQuestionRichText
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def AnyQuestionRichText(headline, richtext, hdim, vdim, yes_button_message, no_button_message, focus)
yes_button = PushButton(
Id(:ok),
if focus == :focus_yes
Opt(:default, :key_F10, :okButton)
Method ShowText
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ShowText(headline, text)
heading = if Builtins.size(headline) == 0
VSpacing(0.2)
else
Heading(headline)
Method anyTimedMessageTypeInternal
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def anyTimedMessageTypeInternal(headline, message, timeout, richtext, width, height)
button_box = ButtonBox(
# FIXME: BNC #422612, Use `opt(`noSanityCheck) later
PushButton(Id(:stop), Opt(:cancelButton), Label.StopButton),
PushButton(Id(:ok_msg), Opt(:default, :okButton), Label.OKButton)
Method anyMessageInternalType
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def anyMessageInternalType(headline, message, richtext, width, height)
button_box = ButtonBox(
PushButton(
Id(:ok_msg),
Opt(:default, :key_F10, :okButton),
Method LongText
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def LongText(headline, richtext, hdim, vdim)
richtext = deep_copy(richtext)
success = UI.OpenDialog(
Opt(:decorated),
HBox(
Method popupLayoutInternalTypeWithLabel
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def popupLayoutInternalTypeWithLabel(headline, message, button_box, label, richtext, width, height)
Method AnyQuestionRichText
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def AnyQuestionRichText(headline, richtext, hdim, vdim, yes_button_message, no_button_message, focus)
Method TimedErrorAnyQuestion
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def TimedErrorAnyQuestion(headline, message, yes_button_message, no_button_message, focus, timeout_seconds)
Method anyMessageDetailsInternalType
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def anyMessageDetailsInternalType(headline, message, details, richtext, width, height)
Method anyTimedMessageTypeInternal
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def anyTimedMessageTypeInternal(headline, message, timeout, richtext, width, height)
Method anyMessageDetailsInternalType
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def anyMessageDetailsInternalType(headline, message, details, richtext, width, height)
button_box = ButtonBox(
PushButton(Id(:ok_msg), Opt(:default, :okButton), Label.OKButton),
# FIXME: BNC #422612, Use `opt(`noSanityCheck) later
# button label
- 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 TimedAnyQuestion
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def TimedAnyQuestion(headline, message, yes_button_message, no_button_message, focus, timeout_seconds)
Method AnyQuestion3
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def AnyQuestion3(headline, message, yes_button_message, no_button_message, retry_button_message, focus)
Method popupLayoutInternalRich
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def popupLayoutInternalRich(headline, message, button_box, width, height)
Method anyMessageInternalType
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def anyMessageInternalType(headline, message, richtext, width, height)
Method anyTimedRichMessageInternal
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def anyTimedRichMessageInternal(headline, message, timeout, width, height)
Method ErrorAnyQuestion
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def ErrorAnyQuestion(headline, message, yes_button_message, no_button_message, focus)
Method AnyQuestion
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def AnyQuestion(headline, message, yes_button_message, no_button_message, focus)
Method AnyQuestionRichText
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def AnyQuestionRichText(headline, richtext, hdim, vdim, yes_button_message, no_button_message, focus)
yes_button = PushButton(
Id(:ok),
if focus == :focus_yes
Opt(:default, :key_F10, :okButton)
- 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 2 locations. Consider refactoring. Open
def AnyQuestion(headline, message, yes_button_message, no_button_message, focus)
button_box = AnyQuestionButtonBox(
yes_button_message,
no_button_message,
focus
- 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 31.
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
def ErrorAnyQuestion(headline, message, yes_button_message, no_button_message, focus)
button_box = AnyQuestionButtonBox(
yes_button_message,
no_button_message,
focus
- 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 31.
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