zweilove/css_splitter

View on GitHub

Showing 3 of 3 total issues

Method extract_part has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def self.extract_part(rules, part = 1, max_selectors = MAX_SELECTORS_DEFAULT)
      return if rules.first.nil?

      charset_statement, rules[0] = extract_charset(rules.first)
      return if rules.nil?
Severity: Minor
Found in lib/css_splitter/splitter.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 extract_part has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.extract_part(rules, part = 1, max_selectors = MAX_SELECTORS_DEFAULT)
      return if rules.first.nil?

      charset_statement, rules[0] = extract_charset(rules.first)
      return if rules.nil?
Severity: Minor
Found in lib/css_splitter/splitter.rb - About 1 hr to fix

    Method split_string_into_rules has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.split_string_into_rules(css_string)
          partial_rules = strip_comments(css_string).chomp.scan /[^}]*}/
          whole_rules = []
          bracket_balance = 0
          in_media_query = false
    Severity: Minor
    Found in lib/css_splitter/splitter.rb - About 35 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

    Severity
    Category
    Status
    Source
    Language