File WorkflowManager.rb
has 1043 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "yast"
require "yast2/control_log_dir_rotator"
require "packages/package_downloader"
require "packages/package_extractor"
Class WorkflowManagerClass
has 51 methods (exceeds 20 allowed). Consider refactoring. Open
class WorkflowManagerClass < Module
include Yast::Logger
def main
Yast.import "UI"
Method UpdateWorkflows
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def UpdateWorkflows(workflows, prod_name, domain)
workflows = deep_copy(workflows)
Builtins.foreach(workflows) do |workflow|
stage = Ops.get_string(workflow, "stage", "")
mode = Ops.get_string(workflow, "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 ReplaceProposalModule
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def ReplaceProposalModule(proposal, old, new)
proposal = deep_copy(proposal)
new = deep_copy(new)
found = 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 control_file
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def control_file(source)
package = case source
when ::Integer
product = find_product(source)
return nil unless product&.product_package
- 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 Replaceworkflows
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def Replaceworkflows(workflows)
workflows = deep_copy(workflows)
workflows = PrepareWorkflows(workflows)
# This function doesn't update the current workflow but replaces it.
Method MergeProposal
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def MergeProposal(base, additional_control, prod_name, domain)
base = deep_copy(base)
additional_control = deep_copy(additional_control)
# Additional proposal settings - Replacing items
replaces = Builtins.listmap(
Method UpdateProposals
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def UpdateProposals(proposals, prod_name, domain)
proposals = deep_copy(proposals)
Builtins.foreach(proposals) do |proposal|
name = Ops.get_string(proposal, "name", "")
stage = Ops.get_string(proposal, "stage", "")
- 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 MergeWorkflow
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def MergeWorkflow(base, addon, _prod_name, domain)
base = deep_copy(base)
addon = deep_copy(addon)
log.info "merging workflow #{addon.inspect} to #{base.inspect}"
Method UpdateWorkflows
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def UpdateWorkflows(workflows, prod_name, domain)
workflows = deep_copy(workflows)
Builtins.foreach(workflows) do |workflow|
stage = Ops.get_string(workflow, "stage", "")
mode = Ops.get_string(workflow, "mode", "")
Method MergeWorkflows
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def MergeWorkflows
Builtins.y2milestone("Merging additional control files from scratch...")
@unmerged_changes = false
# Init the Base Workflow settings
Method UpdateProposals
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def UpdateProposals(proposals, prod_name, domain)
proposals = deep_copy(proposals)
Builtins.foreach(proposals) do |proposal|
name = Ops.get_string(proposal, "name", "")
stage = Ops.get_string(proposal, "stage", "")
Method IntegrateWorkflow
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def IntegrateWorkflow(filename)
Builtins.y2milestone("IntegrateWorkflow %1", filename)
begin
update_file = XML.XMLToYCPFile(filename)
Method ReplaceProposalModule
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ReplaceProposalModule(proposal, old, new)
proposal = deep_copy(proposal)
new = deep_copy(new)
found = false
Method main
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def main
Yast.import "UI"
Yast.import "Pkg"
textdomain "base"
Method UpdateProductInfo
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def UpdateProductInfo(update_file, _filename)
update_file = deep_copy(update_file)
# merging all 'map <string, any>' type
Builtins.foreach(["globals", "software", "partitioning", "network"]) do |section|
sect = ProductFeatures.GetSection(section)
Method StoreWorkflowFile
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def StoreWorkflowFile(file_from, file_to)
if file_from.nil? || file_from == "" || file_to.nil? || file_to == ""
Builtins.y2error("Cannot copy '%1' to '%2'", file_from, file_to)
return nil
end
Method RemoveWorkflow
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def RemoveWorkflow(type, src_id, name)
Builtins.y2milestone(
"Removing Workflow: Type %1, ID %2, Name %3",
type,
src_id,
Method PrepareWorkflows
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def PrepareWorkflows(workflows)
workflows = deep_copy(workflows)
new_workflows = []
# Going through all workflows
Method control_file
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def control_file(source)
package = case source
when ::Integer
product = find_product(source)
return nil unless product&.product_package
Method find_control_package
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def find_control_package(release_package)
return nil unless release_package&.deps
release_package.deps.each do |dep|
provide = dep["provides"]
- 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 PrepareProposals
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def PrepareProposals(proposals)
proposals = deep_copy(proposals)
new_proposals = []
# Going through all proposals
Method GetCachedWorkflowFilename
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def GetCachedWorkflowFilename(type, src_id, name = "")
if ![:package, :addon].include?(type)
Builtins.y2error("Unknown workflow type: %1", type)
return nil
end
Method GetCachedWorkflowFilename
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def GetCachedWorkflowFilename(type, src_id, name = "")
if ![:package, :addon].include?(type)
Builtins.y2error("Unknown workflow type: %1", type)
return nil
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 PrepareProposals
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def PrepareProposals(proposals)
proposals = deep_copy(proposals)
new_proposals = []
# Going through all proposals
- 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 PrepareWorkflows
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def PrepareWorkflows(workflows)
workflows = deep_copy(workflows)
new_workflows = []
# Going through all workflows
- 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 RemoveWorkflow
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def RemoveWorkflow(type, src_id, name)
Builtins.y2milestone(
"Removing Workflow: Type %1, ID %2, Name %3",
type,
src_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 MergeWorkflows
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def MergeWorkflows
Builtins.y2milestone("Merging additional control files from scratch...")
@unmerged_changes = false
# Init the Base Workflow settings
- 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 MergeProposal
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def MergeProposal(base, additional_control, prod_name, domain)
base = deep_copy(base)
additional_control = deep_copy(additional_control)
# Additional proposal settings - Replacing items
replaces = Builtins.listmap(
- 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 ReplaceWorkflowModule
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def ReplaceWorkflowModule(workflow, old, new, domain, keep)
Method StoreWorkflowFile
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def StoreWorkflowFile(file_from, file_to)
if file_from.nil? || file_from == "" || file_to.nil? || file_to == ""
Builtins.y2error("Cannot copy '%1' to '%2'", file_from, file_to)
return nil
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
Avoid too many return
statements within this method. Open
return false
Avoid too many return
statements within this method. Open
return false
Method ReplaceWorkflowModule
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def ReplaceWorkflowModule(workflow, old, new, domain, keep)
workflow = deep_copy(workflow)
new = deep_copy(new)
found = 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 IntegrateWorkflow
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def IntegrateWorkflow(filename)
Builtins.y2milestone("IntegrateWorkflow %1", filename)
begin
update_file = XML.XMLToYCPFile(filename)
- 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 package_repository
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def package_repository(package_name)
# Identify the installation repository with the package
pkgs = Y2Packager::Resolvable.find(kind: :package, name: package_name)
if pkgs.empty?
- 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 3 locations. Consider refactoring. Open
inserts = Builtins.listmap(Ops.get_list(addon, "insert_modules", [])) do |i|
before = Ops.get_string(i, "before", "")
new = Ops.get_list(i, "modules", [])
{ before => new }
- 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 3 locations. Consider refactoring. Open
replaces = Builtins.listmap(Ops.get_list(addon, "replace_modules", [])) do |a|
old = Ops.get_string(a, "replace", "")
new = Ops.get_list(a, "modules", [])
{ old => new }
- 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 3 locations. Consider refactoring. Open
replaces = Builtins.listmap(
Ops.get_list(additional_control, "replace_modules", [])
) do |one_addon|
old = Ops.get_string(one_addon, "replace", "")
new = Ops.get_list(one_addon, "modules", [])
- 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