next-l/enju_leaf

View on GitHub
app/models/manifestation.rb

Summary

Maintainability
F
4 days
Test Coverage
A
94%

File manifestation.rb has 632 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Manifestation < ApplicationRecord
  include EnjuCirculation::EnjuManifestation
  include EnjuSubject::EnjuManifestation
  include EnjuNdl::EnjuManifestation
  include EnjuNii::EnjuManifestation
Severity: Major
Found in app/models/manifestation.rb - About 1 day to fix

    Class Manifestation has 34 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Manifestation < ApplicationRecord
      include EnjuCirculation::EnjuManifestation
      include EnjuSubject::EnjuManifestation
      include EnjuNdl::EnjuManifestation
      include EnjuNii::EnjuManifestation
    Severity: Minor
    Found in app/models/manifestation.rb - About 4 hrs to fix

      Method to_hash has 106 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def to_hash(role: 'Guest')
          record = {
            manifestation_id: id,
            original_title: original_title,
            title_alternative: title_alternative,
      Severity: Major
      Found in app/models/manifestation.rb - About 4 hrs to fix

        Method set_date_of_publication has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

          def set_date_of_publication
            return if pub_date.blank?
        
            year = Time.utc(pub_date.rjust(4, "0").to_i).year rescue nil
            begin
        Severity: Minor
        Found in app/models/manifestation.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

        Method set_agent_role_type has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

          def set_agent_role_type(agent_lists, options = {scope: :creator})
            agent_lists.each do |agent_list|
              name_and_role = agent_list[:full_name].split('||')
              if agent_list[:agent_identifier].present?
                agent = Agent.find_by(agent_identifier: agent_list[:agent_identifier])
        Severity: Minor
        Found in app/models/manifestation.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 to_hash has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          def to_hash(role: 'Guest')
            record = {
              manifestation_id: id,
              original_title: original_title,
              title_alternative: title_alternative,
        Severity: Minor
        Found in app/models/manifestation.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 set_number has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def set_number
            self.volume_number = volume_number_string.scan(/\d*/).map{|s| s.to_i if s =~ /\d/}.compact.first if volume_number_string && !volume_number?
            self.issue_number = issue_number_string.scan(/\d*/).map{|s| s.to_i if s =~ /\d/}.compact.first if issue_number_string && !issue_number?
            self.edition = edition_string.scan(/\d*/).map{|s| s.to_i if s =~ /\d/}.compact.first if edition_string && !edition?
          end
        Severity: Minor
        Found in app/models/manifestation.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 set_date_of_publication has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def set_date_of_publication
            return if pub_date.blank?
        
            year = Time.utc(pub_date.rjust(4, "0").to_i).year rescue nil
            begin
        Severity: Minor
        Found in app/models/manifestation.rb - About 1 hr to fix

          Method pub_dates has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def pub_dates
              return [] unless pub_date
          
              pub_date_array = pub_date.split(';')
              pub_date_array.map{|pub_date_string|
          Severity: Minor
          Found in app/models/manifestation.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 set_agent_role_type has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def set_agent_role_type(agent_lists, options = {scope: :creator})
              agent_lists.each do |agent_list|
                name_and_role = agent_list[:full_name].split('||')
                if agent_list[:agent_identifier].present?
                  agent = Agent.find_by(agent_identifier: agent_list[:agent_identifier])
          Severity: Minor
          Found in app/models/manifestation.rb - About 1 hr to fix

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

              def extract_text
                return unless attachment.attached?
                return unless ENV['ENJU_LEAF_EXTRACT_TEXT'] == 'true'
            
                if ENV['ENJU_LEAF_EXTRACT_FILESIZE_LIMIT'].present?
            Severity: Minor
            Found in app/models/manifestation.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 sort_title has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def sort_title
                if series_master?
                  if root_series_statement.title_transcription?
                    NKF.nkf('-w --katakana', root_series_statement.title_transcription)
                  else
            Severity: Minor
            Found in app/models/manifestation.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