MiraitSystems/enju_trunk

View on GitHub

Showing 1,155 of 1,155 total issues

File items_controller.rb has 415 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class ItemsController < ApplicationController
  authorize_function
  add_breadcrumb "I18n.t('activerecord.models.item')", 'items_path'
  add_breadcrumb "I18n.t('page.new', :model => I18n.t('activerecord.models.item'))", 'new_item_path', :only => [:new, :create]
  add_breadcrumb "I18n.t('page.editing', :model => I18n.t('activerecord.models.item'))", 'edit_item_path(params[:id])', :only => [:edit, :update]
Severity: Minor
Found in app/controllers/items_controller.rb - About 5 hrs to fix

    Method get_unable_list_pdf has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.get_unable_list_pdf(users, sort)
        report = EnjuTrunk.new_report('userlist.tlf')
        # set page_num
        report.events.on :page_create do |e|
          e.page.item(:page).value(e.page.no)
    Severity: Minor
    Found in app/models/unablelist.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

    File manifestations_helper.rb has 411 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module ManifestationsHelper
      def resource_title(manifestation, action)
        string = LibraryGroup.site_config.display_name.localize.dup
        unless action == ('index' or 'new')
          if manifestation.try(:original_title)
    Severity: Minor
    Found in app/helpers/manifestations_helper.rb - About 5 hrs to fix

      Method output_columns has 146 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.output_columns(wbstyles, sheet, conditions, cols)
          merge_style = wbstyles.add_style :font_name => Setting.item_statistics_print_excelx.fontname, :alignment => {:horizontal => :center, :vertical => :center}
          if cols.length > 0
            # 1行目
            if conditions.aggregation_first.present?
      Severity: Major
      Found in app/models/item_statistics.rb - About 5 hrs to fix

        File resource_import.rb has 408 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'roo'
        require File.join(File.expand_path(File.dirname(__FILE__)), 'import_book')
        require File.join(File.expand_path(File.dirname(__FILE__)), 'import_article')
        class ResourceImport < EnjuTrunk::ResourceAdapter::Base
          include EnjuTrunk::ImportBook
        Severity: Minor
        Found in lib/enju_trunk/resourceadapter/resource_import.rb - About 5 hrs to fix

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

                          case 38: // up arrow 
                              if ($(event.target).is('.' + options.linkHover)) {    
                                  var prevLink = $(event.target).parent().prev().find('a:eq(0)');                        
                                  if (prevLink.size() > 0) {
                                      $(event.target).trigger('mouseout');
          Severity: Major
          Found in app/assets/javascripts/fg.menu.js and 1 other location - About 5 hrs to fix
          app/assets/javascripts/fg.menu.js on lines 165..175

          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 150.

          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

                          case 40: // down arrow 
                              if ($(event.target).is('.' + options.linkHover)) {
                                  var nextLink = $(event.target).parent().next().find('a:eq(0)');                        
                                  if (nextLink.size() > 0) {                            
                                      $(event.target).trigger('mouseout');
          Severity: Major
          Found in app/assets/javascripts/fg.menu.js and 1 other location - About 5 hrs to fix
          app/assets/javascripts/fg.menu.js on lines 138..148

          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 150.

          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 export_tsv has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.export_tsv(expenses)
              dir_base = "#{Rails.root}/private/system"
              out_dir = "#{dir_base}/expense/"
              tsv_file = out_dir + "expenses.tsv"
              FileUtils.mkdir_p(out_dir) unless FileTest.exist?(out_dir)
          Severity: Minor
          Found in app/models/expense.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 output_reminder_list_tsv has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.output_reminder_list_tsv(reminder_lists)
              columns = [
                [:checkout_id, 'activerecord.attributes.reminder_list.checkout_id'],
                [:title, 'activerecord.attributes.reminder_list.original_title'],
                [:call_number, 'activerecord.attributes.item.call_number'],
          Severity: Minor
          Found in app/models/reminder_list.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 make_audio_list_tsv has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.make_audio_list_tsv(tsvfile, items)
              columns = [
                [:library, 'activerecord.models.library'],
                [:carrier_type, 'activerecord.models.carrier_type'],
                [:shelf, 'activerecord.models.shelf'],
          Severity: Minor
          Found in app/models/item.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 import_for_incremental_synchronization! has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

              def import_for_incremental_synchronization!(dump)
                last_processed = current_proccessing = nil
                item_attributes = nil
          
                # レコード毎の履歴
          Severity: Minor
          Found in app/models/version.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 do_numbering has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.do_numbering(name, is_save = true, options = {})
              counter = 10
              n = nil
              number = ''
              Numbering.transaction do
          Severity: Minor
          Found in app/models/numbering.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 bestreader has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

            def bestreader
              if params[:opac] and params[:search_date_first].blank? and params[:search_date_last].blank?
                @start_d = (Date.today - 2.weeks).to_s
                @end_d = Date.today.to_s
              end
          Severity: Minor
          Found in app/controllers/manifestation_exstats_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

          Method prepare_options has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

            def prepare_options
              @subject_types = SubjectType.all
              @carrier_types = CarrierType.all
              @sub_carrier_types = SubCarrierType.all
              @manifestation_types = ManifestationType.all
          Severity: Minor
          Found in app/controllers/manifestations_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

          Method update has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
          Open

            def update
              if params[:item][:claim_attributes]
                if params[:item][:claim_attributes][:claim_type_id].blank? && params[:item][:claim_attributes][:note].blank?
                  params[:item][:claim_attributes][:_destroy] = 1
                end
          Severity: Minor
          Found in app/controllers/items_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 setup has 131 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Calendar.setup = function (params) {
              function param_default(pname, def) { if (typeof params[pname] == "undefined") { params[pname] = def; } };
          
              param_default("inputField",     null);
              param_default("displayArea",    null);
          Severity: Major
          Found in app/assets/javascripts/jquery.simplecalendarjp.js - About 5 hrs to fix

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

              def self.make_item_register_tsv(tsvfile, items)
                columns = [
                  [:bookstore, 'activerecord.models.bookstore'],
                  ['item_identifier', 'activerecord.attributes.item.item_identifier'],
                  ['acquired_at_string', 'activerecord.attributes.item.acquired_at_string'],
            Severity: Minor
            Found in app/models/item.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 hide_item? has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

              def hide_item?(show_all = false, item)
                unless user_signed_in? and current_user.has_role?('Librarian') and SystemConfiguration.get("manifestation.show_all")
                  if @removed
                    return true unless item.circulation_status.name == "Removed"
                  else 
            Severity: Minor
            Found in app/helpers/manifestations_helper.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 output_excelx has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.output_excelx(output_data, filename = nil)
                require 'axlsx'
            
                # initialize
                if filename.present?
            Severity: Minor
            Found in app/models/item_statistics.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 create has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                @manifestation = Manifestation.new(params[:manifestation])
                @original_manifestation = Manifestation.where(:id => params[:manifestation_id]).first
                if @manifestation.respond_to?(:post_to_scribd)
                  @manifestation.post_to_scribd = true if params[:manifestation][:post_to_scribd] == "1"
            Severity: Minor
            Found in app/controllers/manifestations_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

            Severity
            Category
            Status
            Source
            Language