openjaf/cenit

View on GitHub
lib/xsd/document.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Method process_element_message has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def process_element_message(primary_method, alternative_method, name, attributes = nil)
      if top.respond_to?(primary_method)
        return top.send(primary_method, attributes) if attributes
        return top.send(primary_method)
      elsif top_available? && top.respond_to?(alternative_method)
Severity: Minor
Found in lib/xsd/document.rb - About 1 hr 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 self.send(primary_method, attributes) if attributes
Severity: Major
Found in lib/xsd/document.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return self.send(primary_method)
    Severity: Major
    Found in lib/xsd/document.rb - About 30 mins to fix

      Method start_element has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def start_element(name, attributes = [])
            unless @xsd_tag
              @xsd_tag = 'http://www.w3.org/2001/XMLSchema'
              attr = attributes.detect { |attr| attr[0] =~ /\Axmlns:/ && attr[1] == 'http://www.w3.org/2001/XMLSchema' }
              if attr
      Severity: Minor
      Found in lib/xsd/document.rb - About 25 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

      There are no issues that match your filters.

      Category
      Status