hummingbird-me/hummingbird

View on GitHub
lib/mal_import.rb

Summary

Maintainability
C
1 day
Test Coverage

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

  def metadata
    meta = {
      external_id: @mal_id,
      title: {
        canonical: @main_noko.css('h1').children[0].text.strip,
Severity: Minor
Found in lib/mal_import.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 metadata has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def metadata
    meta = {
      external_id: @mal_id,
      title: {
        canonical: @main_noko.css('h1').children[0].text.strip,
Severity: Minor
Found in lib/mal_import.rb - About 1 hr to fix

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

      def characters
        featured_chars = @main_noko.css('table div.picSurround a[href*="character/"]').map {|x|
          x['href'].scan(/character\/(\d+)/)
        }.flatten.map(&:to_i)
    
    
    Severity: Minor
    Found in lib/mal_import.rb - About 1 hr to fix

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

        def br_to_p(src)
          src = '<p>' + src.gsub(/<br>\s*<br>/, '</p><p>') + '</p>'
          doc = Nokogiri::HTML.fragment src
          doc.traverse do |x|
            next x.remove if x.name == 'br' && x.previous.nil?
      Severity: Minor
      Found in lib/mal_import.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 clean_desc has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def clean_desc(desc)
          desc = Nokogiri::HTML.fragment br_to_p(desc)
          desc.css('.spoiler').each do |x|
            x.name = 'span'
            x.inner_html = x.css('.spoiler_content').inner_html
      Severity: Minor
      Found in lib/mal_import.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

      There are no issues that match your filters.

      Category
      Status