next-l/enju_leaf

View on GitHub

Showing 345 of 709 total issues

Method import has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

  def import
    transition_to!(:started)
    num = { user_imported: 0, user_found: 0, failed: 0, error: 0 }
    rows = open_import_file(create_import_temp_file(attachment))
    row_num = 1
Severity: Minor
Found in app/models/user_import_file.rb - About 6 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 manifestations_helper.rb has 441 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ManifestationsHelper
  # include EnjuCirculation::ManifestationsHelper if defined?(EnjuCirculation)

  def resource_title(manifestation, action)
    string = LibraryGroup.site_config.display_name.localize.dup
Severity: Minor
Found in app/helpers/manifestations_helper.rb - About 6 hrs to fix

    Method import_record_from_loc has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.import_record_from_loc(doc)
            record_identifier = doc.at('//mods:recordInfo/mods:recordIdentifier', NS).try(:content)
            identifier_type = IdentifierType.find_by(name: 'loc_identifier')
            identifier_type ||= IdentifierType.create!(name: 'loc_identifier')
            loc_identifier = Identifier.find_by(body: record_identifier, identifier_type_id: identifier_type.id)
    Severity: Minor
    Found in app/models/concerns/enju_loc/enju_manifestation.rb - About 6 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 modify has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

      def modify
        transition_to!(:started)
        rows = open_import_file
        rows.shift
        row_num = 1
    Severity: Minor
    Found in app/models/agent_import_file.rb - About 6 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 index has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

      def index
        if params[:icalendar_token].present?
          icalendar_user = Profile.where(checkout_icalendar_token: params[:icalendar_token]).first.try(:user)
          if icalendar_user.blank?
            raise ActiveRecord::RecordNotFound
    Severity: Minor
    Found in app/controllers/checkouts_controller.rb - About 5 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

    Function renderSection has 135 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function renderSection(position) {
            var sectionEl = $('<div class="fc-' + position + '"/>');
            var options = calendar.options;
            var buttonStr = options.header[position];
    
    
    Severity: Major
    Found in app/assets/javascripts/enju_event/fullcalendar.js - About 5 hrs to fix

      Method get_mods_carrier_and_content_types has 133 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def self.get_mods_carrier_and_content_types(doc)
              carrier_type = content_type = nil
              doc.xpath('//mods:form', NS).each do |e|
                    authority = e.attributes['authority'].try(:content)
                    case authority
      Severity: Major
      Found in app/models/concerns/enju_loc/enju_manifestation.rb - About 5 hrs to fix

        Method update_carrier_type has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
        Open

        def update_carrier_type
          CarrierType.find_each do |carrier_type|
            case carrier_type.name
            when "volume"
              carrier_type = CarrierType.find_by(name: 'volume')
        Severity: Minor
        Found in lib/tasks/carrier_type.rb - About 5 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 migrate_attachment_s3 has 127 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def migrate_attachment_s3
          AgentImportFile.where.not(agent_import_file_name: nil).find_each do |file|
            file.attachment.attach(
              io: URI(Paperclip::Attachment.new(
                :agent_import,
        Severity: Major
        Found in lib/tasks/attachment.rb - About 5 hrs to fix

          Method migrate_attachment has 124 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def migrate_attachment
            option = {
              path: ":rails_root/private/system/:class/:attachment/:id_partition/:style/:filename"
            }
          
          
          Severity: Major
          Found in lib/tasks/attachment.rb - About 4 hrs to fix

            Method set_acquisition_date has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
            Open

              def set_acquisition_date(query, options)
                unless options[:acquired_from].blank? && options[:acquired_until].blank?
                  options[:acquired_from].to_s.gsub!(/\D/, '')
                  options[:acquired_until].to_s.gsub!(/\D/, '')
            
            
            Severity: Minor
            Found in app/controllers/manifestations_controller.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 import_record has 119 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def import_record(doc)
                    iss_itemno = URI.parse(doc.at('//dcndl:BibAdminResource[@rdf:about]').values.first).path.split('/').last
                    ndl_bib_id_record =NdlBibIdRecord.find_by(body: iss_itemno)
                    return ndl_bib_id_record.manifestation if ndl_bib_id_record
            
            
            Severity: Major
            Found in app/models/concerns/enju_ndl/enju_manifestation.rb - About 4 hrs to fix

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

                  def make_internal_query(search)
                    # 内部的なクエリ
                    set_role_query(current_user, search)
              
                    unless params[:mode] == "add"
              Severity: Minor
              Found in app/controllers/concerns/enju_biblio/controller.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

              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

                File enju_manifestation.rb has 346 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                module EnjuNdl
                  module EnjuManifestation
                    extend ActiveSupport::Concern
                
                    module ClassMethods
                Severity: Minor
                Found in app/models/concerns/enju_ndl/enju_manifestation.rb - About 4 hrs to fix

                  Method index has 107 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def index
                      query = params[:query].to_s.strip
                      per_page = Item.default_per_page
                      @count = {}
                      if user_signed_in?
                  Severity: Major
                  Found in app/controllers/items_controller.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 import_record_from_cinii_books has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def import_record_from_cinii_books(doc)
                              # http://ci.nii.ac.jp/info/ja/api/api_outline.html#cib_od
                              # return nil
                      
                              ncid = doc.at('//cinii:ncid').try(:content)
                      Severity: Minor
                      Found in app/models/concerns/enju_nii/enju_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 modify has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def modify
                          transition_to!(:started)
                          rows = open_import_file(create_import_temp_file(attachment))
                          check_field(rows.first)
                          row_num = 1
                      Severity: Minor
                      Found in app/models/event_import_file.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 make_query has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def make_query(query, options = {})
                          # TODO: integerやstringもqfに含める
                          query = query.to_s.strip
                      
                          if query.size == 1
                      Severity: Minor
                      Found in app/controllers/manifestations_controller.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

                      Severity
                      Category
                      Status
                      Source
                      Language