npolar/api.npolar.no

View on GitHub
lib/metadata/dif_transformer.rb

Summary

Maintainability
F
3 days
Test Coverage

File dif_transformer.rb has 529 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "hashie"
require "uuidtools"
require "uri"
require "gcmd"

Severity: Major
Found in lib/metadata/dif_transformer.rb - About 1 day to fix

    Class DifTransformer has 56 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class DifTransformer
        include ::Npolar::Api
    
        BASE = "http://api.npolar.no/dataset/"
    
    
    Severity: Major
    Found in lib/metadata/dif_transformer.rb - About 1 day to fix

      Method activity has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def activity
            periods = []
            object.Temporal_Coverage.each do | period |
      
              start = ""
      Severity: Minor
      Found in lib/metadata/dif_transformer.rb - About 2 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 links has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def links
            links = []
      
            # 1. Related_URL
            if dif.Related_URL?
      Severity: Minor
      Found in lib/metadata/dif_transformer.rb - About 1 hr to fix

        Method links has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def links
              links = []
        
              # 1. Related_URL
              if dif.Related_URL?
        Severity: Minor
        Found in lib/metadata/dif_transformer.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 person_from_personnel has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.person_from_personnel(p)
        
              first_name = p.First_Name
              if p.Middle_Name? and p.Middle_Name.size >= 1
                first_name += " " + p.Middle_Name
        Severity: Minor
        Found in lib/metadata/dif_transformer.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 guess_topic_from_parameter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def guess_topic_from_parameter(parameter)
              if parameter.Variable_Level_1 =~ /FISHERIES/i
                ["biology", "marine"]
              elsif parameter.Term =~ /VEGETATION/i
                ["biology", "vegetation"]
        Severity: Minor
        Found in lib/metadata/dif_transformer.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 organisations has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def organisations
        
              orgs = []
        
              if dif.Data_Center? and dif.Data_Center.any?
        Severity: Minor
        Found in lib/metadata/dif_transformer.rb - About 1 hr to fix

          Method normalize_iso_topics has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def normalize_iso_topics(dif_iso_topic)
                step1 = dif_iso_topic.downcase.gsub(/(\s|\/)/, "")
                iso_topic = case step1
                  when "geoscientificinformation"
                    "geoscientificInformation"
          Severity: Minor
          Found in lib/metadata/dif_transformer.rb - About 1 hr to fix

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

                def organisations
            
                  orgs = []
            
                  if dif.Data_Center? and dif.Data_Center.any?
            Severity: Minor
            Found in lib/metadata/dif_transformer.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 guess_country_code_from_location has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def guess_country_code_from_location(location)
                  if location.Location_Subregion2 =~ /SVALBARD AND JAN MAYEN/i
                    "NO"
                  elsif location.Location_Subregion2  =~ /Norway/i
                    "NO"
            Severity: Minor
            Found in lib/metadata/dif_transformer.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

            Consider simplifying this complex logical expression.
            Open

                  if (topics||[]).include? "oceanography" or (topics||[]).include? "seaice" or (iso_topics||[]).include? "oceans"
                    sets << "NMDC"
                  end
            Severity: Major
            Found in lib/metadata/dif_transformer.rb - About 40 mins to fix

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

                  def guess_topic_from_title(title)
                    if title =~ /geology|geological/i
                      "geology"
                    elsif title =~ /bird|reindeer|fauna|ecology|faeces|fox|seal|walrus|vegetation|population dynamics|lichen/i
                      "biology"
              Severity: Minor
              Found in lib/metadata/dif_transformer.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