Method clean_css_code
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def clean_css_code(css_code, options = {})
return "" if !css_code.match(/\w/) # only spaces of various kinds
clean_css = ""
parser = CssParser::Parser.new
parser.add_block!(css_code)
- 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 tokenize_and_sanitize_css_value
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def tokenize_and_sanitize_css_value(value)
cleanval = ""
scanner = StringScanner.new(value)
# we scan until we find either a space, a comma, or an open parenthesis
- 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 clean_css_code
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def clean_css_code(css_code, options = {})
return "" if !css_code.match(/\w/) # only spaces of various kinds
clean_css = ""
parser = CssParser::Parser.new
parser.add_block!(css_code)
Method tokenize_and_sanitize_css_value
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def tokenize_and_sanitize_css_value(value)
cleanval = ""
scanner = StringScanner.new(value)
# we scan until we find either a space, a comma, or an open parenthesis
Method sanitize_css_declaration_value
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def sanitize_css_declaration_value(property, value)
clean = ""
property = property.downcase
if property == "font-family"
if !sanitize_css_font(value).blank?
- 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 ""