GlobalNamesArchitecture/dwca-hunter

View on GitHub
lib/dwca_hunter/resources/wikispecies.rb

Summary

Maintainability
D
1 day
Test Coverage

Method generate_dwca has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def generate_dwca
      DwcaHunter.logger_write(object_id,
                              "Creating DarwinCore Archive file")
      @core = [
        ["http://rs.tdwg.org/dwc/terms/taxonID",
Severity: Major
Found in lib/dwca_hunter/resources/wikispecies.rb - About 3 hrs to fix

    Method generate_dwca has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def generate_dwca
          DwcaHunter.logger_write(object_id,
                                  "Creating DarwinCore Archive file")
          @core = [
            ["http://rs.tdwg.org/dwc/terms/taxonID",
    Severity: Minor
    Found in lib/dwca_hunter/resources/wikispecies.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

    File wikispecies.rb has 293 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module DwcaHunter
      # Wikispecies source
      class ResourceWikispecies < DwcaHunter::Resource
        def initialize(opts = { download: true, unpack: true })
          @wikisp_path = File.join(Dir.tmpdir, "dwca_hunter", "wikispecies")
    Severity: Minor
    Found in lib/dwca_hunter/resources/wikispecies.rb - About 3 hrs to fix

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

          def enrich_data
            DwcaHunter.logger_write(object_id,
                                    "Extracting data from xml file...")
            Dir.chdir(@download_dir)
            f = open("data.xml", "r:utf-8")
      Severity: Minor
      Found in lib/dwca_hunter/resources/wikispecies.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 enrich_data has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def enrich_data
            DwcaHunter.logger_write(object_id,
                                    "Extracting data from xml file...")
            Dir.chdir(@download_dir)
            f = open("data.xml", "r:utf-8")
      Severity: Minor
      Found in lib/dwca_hunter/resources/wikispecies.rb - About 1 hr to fix

        Method get_vernacular_names has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_vernacular_names(items)
              vern = items["{{int:vernacular names}}"]
              return unless vern.is_a?(Array) && vern.size.positive?
        
              vn_string = vern.join("")
        Severity: Minor
        Found in lib/dwca_hunter/resources/wikispecies.rb - About 55 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

        Method init_classification_path has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def init_classification_path(items)
              # ignore non-template links
              items["taxonavigation"]&.each do |line|
                line.gsub!(/\[\[.*\]\]/, "") # ignore non-template links
                next unless template_link = line.match(@re[:template_link])
        Severity: Minor
        Found in lib/dwca_hunter/resources/wikispecies.rb - About 45 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

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

            def process_template(x)
              name = page_title(x).gsub!(@re[:template], "").strip
              text = x.xpath("//text").text.strip
              parent_name = text.match(@re[:template_link])
              if parent_name
        Severity: Minor
        Found in lib/dwca_hunter/resources/wikispecies.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