File URL.rb
has 375 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "yast"
module Yast
# A module for dealing with URLs
#
Method Build
has 110 lines of code (exceeds 25 allowed). Consider refactoring. Open
def Build(tokens)
tokens = deep_copy(tokens)
url = ""
userpass = ""
Method Build
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def Build(tokens)
tokens = deep_copy(tokens)
url = ""
userpass = ""
- 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 Parse
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
def Parse(url)
Builtins.y2debug("url=%1", url)
# We don't parse empty URLs
return {} if url.nil? || Ops.less_than(Builtins.size(url), 1)
Method Parse
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def Parse(url)
Builtins.y2debug("url=%1", url)
# We don't parse empty URLs
return {} if url.nil? || Ops.less_than(Builtins.size(url), 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 main
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def main
textdomain "base"
Yast.import "Hostname"
Yast.import "String"
Method Check
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def Check(url)
# We don't allow empty URLs
return false if url.nil? || Ops.less_than(Builtins.size(url), 1)
# We don't allow URLs with spaces
- 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 if !Builtins.regexpmatch(Ops.get_string(tokens, "port", ""), "^[0-9]*$")
Method MakeMapFromParams
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def MakeMapFromParams(params)
# Error
if params.nil?
Builtins.y2error("Erroneous (nil) params!")
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 MakeParamsFromMap
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def MakeParamsFromMap(params_map)
params_map = deep_copy(params_map)
# ["key1=value1", "key2=value2", ...] -> "key1=value1&key2=value2"
Builtins.mergestring(
# ["key" : "value", ...] -> ["key=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"