holderdeord/hdo-transcript-search

View on GitHub
indexer/lib/hdo-transcript-indexer/converter.rb

Summary

Maintainability
D
2 days
Test Coverage

File converter.rb has 420 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'time'
require 'set'
require 'hashie/mash'
require 'hdo/storting_importer'
require 'childprocess'
Severity: Minor
Found in indexer/lib/hdo-transcript-indexer/converter.rb - About 6 hrs to fix

    Method parse_name_string has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

          def parse_name_string(str, person)
            result = Hashie::Mash.new
            orig = str
            str = clean_name_string(str)
    
    
    Severity: Minor
    Found in indexer/lib/hdo-transcript-indexer/converter.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 parse_name_string has 88 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def parse_name_string(str, person)
            result = Hashie::Mash.new
            orig = str
            str = clean_name_string(str)
    
    
    Severity: Major
    Found in indexer/lib/hdo-transcript-indexer/converter.rb - About 3 hrs to fix

      Class Converter has 27 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Converter
            class << self
              def parse(file, options = {})
                case file
                when /s(\d{2})(\d{2})(\d{2}).*\.xml$/i
      Severity: Minor
      Found in indexer/lib/hdo-transcript-indexer/converter.rb - About 3 hrs to fix

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

              def parse_speech(node)
                name_nodes = node.css('navn, Navn')
                name_str = name_nodes.text
                text     = clean_text(text_from(node))
        
        
        Severity: Minor
        Found in indexer/lib/hdo-transcript-indexer/converter.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 parse_section has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

              def parse_section(node)
                @current_node = node
        
                section = case node.name.downcase
                          when 'innlegg', 'hovedinnlegg', 'replikk'
        Severity: Minor
        Found in indexer/lib/hdo-transcript-indexer/converter.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 parse_speech has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def parse_speech(node)
                name_nodes = node.css('navn, Navn')
                name_str = name_nodes.text
                text     = clean_text(text_from(node))
        
        
        Severity: Minor
        Found in indexer/lib/hdo-transcript-indexer/converter.rb - About 1 hr to fix

          Method extract_entities has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def extract_entities(section)
                  r, w = IO.pipe
          
                  process = ChildProcess.build("python", NER_SCRIPT)
                  process.duplex = true
          Severity: Minor
          Found in indexer/lib/hdo-transcript-indexer/converter.rb - About 1 hr to fix

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

                    def parse(file, options = {})
                      case file
                      when /s(\d{2})(\d{2})(\d{2}).*\.xml$/i
                        short_year = $1
                        month      = $2.to_i
            Severity: Minor
            Found in indexer/lib/hdo-transcript-indexer/converter.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

            There are no issues that match your filters.

            Category
            Status