next-l/enju_leaf

View on GitHub

Showing 709 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        getVerticalIndex: function(topOffset) {
            this.ensureBuilt();
    
            var boundingRect = this.boundingRect;
            var tops = this.tops;
    Severity: Major
    Found in app/assets/javascripts/enju_event/fullcalendar.js and 1 other location - About 6 hrs to fix
    app/assets/javascripts/enju_event/fullcalendar.js on lines 2317..2333

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 157.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        getHorizontalIndex: function(leftOffset) {
            this.ensureBuilt();
    
            var boundingRect = this.boundingRect;
            var lefts = this.lefts;
    Severity: Major
    Found in app/assets/javascripts/enju_event/fullcalendar.js and 1 other location - About 6 hrs to fix
    app/assets/javascripts/enju_event/fullcalendar.js on lines 2338..2354

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 157.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            buildElHorizontals: function() {
                var lefts = [];
                var rights = [];
        
                this.els.each(function(i, node) {
        Severity: Major
        Found in app/assets/javascripts/enju_event/fullcalendar.js and 1 other location - About 5 hrs to fix
        app/assets/javascripts/enju_event/fullcalendar.js on lines 2297..2312

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 141.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            buildElVerticals: function() {
                var tops = [];
                var bottoms = [];
        
                this.els.each(function(i, node) {
        Severity: Major
        Found in app/assets/javascripts/enju_event/fullcalendar.js and 1 other location - About 5 hrs to fix
        app/assets/javascripts/enju_event/fullcalendar.js on lines 2278..2293

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 141.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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
                    Severity
                    Category
                    Status
                    Source
                    Language