datacite/lupo

View on GitHub
app/models/person.rb

Summary

Maintainability
B
6 hrs
Test Coverage

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

  def self.parse_message(message: nil)
    orcid = message.fetch("orcid-id", nil)

    given_name = message.fetch("given-names", nil)
    family_name = message.fetch("family-names", nil)
Severity: Minor
Found in app/models/person.rb - About 1 hr to fix

    Method find_by_id has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.find_by_id(id)
        orcid = orcid_from_url(id)
        return {} if orcid.blank?
    
        person = get_orcid(orcid: orcid, endpoint: "person")
    Severity: Minor
    Found in app/models/person.rb - About 1 hr to fix

      Method get_employments has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.get_employments(employments)
          Array.wrap(employments.dig("data", "affiliation-group")).map do |a|
            i =
              a.dig(
                "summaries",
      Severity: Minor
      Found in app/models/person.rb - About 1 hr to fix

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

          def self.parse_message(message: nil)
            orcid = message.fetch("orcid-id", nil)
        
            given_name = message.fetch("given-names", nil)
            family_name = message.fetch("family-names", nil)
        Severity: Minor
        Found in app/models/person.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 query has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.query(query, options = {})
            options[:limit] ||= 25
            options[:offset] ||= 0
        
            params = {
        Severity: Minor
        Found in app/models/person.rb - About 25 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