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
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
- 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 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
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"
- 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 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
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"
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,
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()
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}"
Method main
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def main
Yast.import "UI"
textdomain "base"
Yast.import "XML"
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()
- 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 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")
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)
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)
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(
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
- 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 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)
- 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 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")
- 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
minimum_step = Ops.add(minimum_step, 1) if Ops.less_or_equal(@current_step, minimum_step) && !allow_back
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
- 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 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
- 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
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(
- 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 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
- 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 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(
- 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 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
- 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 DisableModule(modname)
if modname.nil? || modname == ""
Builtins.y2error("Module to disable is '%1'", modname)
else
@DisabledModules = Convert.convert(
- 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
def DisableProposal(disable_proposal)
if disable_proposal.nil? || disable_proposal == ""
Builtins.y2error("Module to disable is '%1'", disable_proposal)
else
@DisabledProposals = Convert.convert(
- 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
label = if Builtins.haskey(m, "textdomain")
Builtins.dgettext(
Ops.get_string(m, "textdomain", ""),
Ops.get_string(m, "label", "")
)
- 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 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
- 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
heading = if Builtins.haskey(m, "textdomain")
Builtins.dgettext(
Ops.get_string(m, "textdomain", ""),
Ops.get_string(m, "label", "")
)
- 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 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
- 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