otwcode/otwarchive

View on GitHub
lib/css_cleaner.rb

Summary

Maintainability
D
1 day
Test Coverage

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)
Severity: Minor
Found in lib/css_cleaner.rb - About 4 hrs to fix

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
Severity: Minor
Found in lib/css_cleaner.rb - About 3 hrs to fix

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)
Severity: Minor
Found in lib/css_cleaner.rb - About 1 hr to fix

    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
    Severity: Minor
    Found in lib/css_cleaner.rb - About 1 hr to fix

      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?
      Severity: Minor
      Found in lib/css_cleaner.rb - About 55 mins to fix

      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 ""
      Severity: Major
      Found in lib/css_cleaner.rb - About 30 mins to fix

        There are no issues that match your filters.

        Category
        Status