aozorahack/aozora2html

View on GitHub
lib/aozora2html/header.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method build_header_info has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def build_header_info
      header_info = { title: @header[0] }
      case @header.length
      when 2
        process_person(@header[1], header_info)
Severity: Minor
Found in lib/aozora2html/header.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

Method build_header_info has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def build_header_info
      header_info = { title: @header[0] }
      case @header.length
      when 2
        process_person(@header[1], header_info)
Severity: Minor
Found in lib/aozora2html/header.rb - About 1 hr to fix

    Method header_element_type has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def header_element_type(string)
          original = true
          string.each_char do |ch|
            code = ch.unpack1('H*')
            if ((code >= '00') && (code <= '7f')) || # 1byte
    Severity: Minor
    Found in lib/aozora2html/header.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

    Consider simplifying this complex logical expression.
    Open

            if ((code >= '00') && (code <= '7f')) || # 1byte
               ((code >= '8140') && (code <= '8258')) || # 1-1, 3-25
               ((code >= '839f') && (code <= '8491')) # 6-1, 7-81
            # continue
            else
    Severity: Major
    Found in lib/aozora2html/header.rb - About 40 mins to fix

      There are no issues that match your filters.

      Category
      Status