MiraitSystems/enju_trunk

View on GitHub

Showing 1,155 of 1,155 total issues

Method update_manifestation_classifications has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def update_manifestation_classifications(sheet, datas, field, manifestation, error_msgs)
      return unless field == 'book'

      classification_field = "#{field}.classification"
      classification_type_field = "#{field}.classification_type"
Severity: Minor
Found in lib/enju_trunk/resourceadapter/import_book.rb - About 1 hr to fix

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

      def index
        @selected_circulation_ids = params[:circulation_status].map{|s| s.to_i} if params[:circulation_status]
        if params[:pdf] || params[:tsv]
          @displist = []
          if params[:circulation_status].blank?
    Severity: Minor
    Found in app/controllers/checkoutlists_controller.rb - About 1 hr to fix

      Method find_same_item has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def find_same_item(attrs, manifestation_type)
            conditions = ["((manifestations).manifestation_type_id = \'#{manifestation_type.id}\')"] # FIXME!
            attrs.each do |key, value|
              case key
              when 'creators', 'subjects'
      Severity: Minor
      Found in lib/enju_trunk/resourceadapter/import_article.rb - About 1 hr to fix

        Method fixup_config_application has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def fixup_config_application
            target = 'config/application.rb'
        
            gsub_file target, /^(\s*)(class Application < Rails::Application)\n/, <<-'E'
        \1\2
        Severity: Minor
        Found in lib/generators/enju_trunk/install/install_generator.rb - About 1 hr to fix

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

              detail = {:jpn_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                        :foreign_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                        :jpn_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                        :foreign_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                        :not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
          Severity: Major
          Found in app/models/item_statistics.rb and 2 other locations - About 1 hr to fix
          app/models/item_statistics.rb on lines 137..142
          app/models/item_statistics.rb on lines 645..650

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

          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 3 locations. Consider refactoring.
          Open

                sum_detail = {:jpn_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                              :foreign_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                              :jpn_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                              :foreign_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                              :not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
          Severity: Major
          Found in app/models/item_statistics.rb and 2 other locations - About 1 hr to fix
          app/models/item_statistics.rb on lines 383..388
          app/models/item_statistics.rb on lines 645..650

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

          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 3 locations. Consider refactoring.
          Open

                grand_total = {:jpn_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                               :foreign_not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                               :jpn_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                               :foreign_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
                               :not_donate => {:book => 0, :price => 0, :book_remove => 0, :price_remove => 0},
          Severity: Major
          Found in app/models/item_statistics.rb and 2 other locations - About 1 hr to fix
          app/models/item_statistics.rb on lines 137..142
          app/models/item_statistics.rb on lines 383..388

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

          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 get has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.get(keyname)
              value = typename = nil
          
              s = Rails.cache.read("#{Prefix_Key}#{keyname}")
              if s
          Severity: Minor
          Found in app/models/system_configuration.rb - About 1 hr to fix

            Method get_purchase_requests_tsv has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.get_purchase_requests_tsv(purchase_requests)
                data = String.new
                data << "\xEF\xBB\xBF".force_encoding("UTF-8") + "\n"
                columns = [
                  [:original_title, 'activerecord.attributes.manifestation.original_title'],
            Severity: Minor
            Found in app/models/purchase_request.rb - About 1 hr to fix

              Method get_result_list has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def get_result_list(list_type, ranks, checkouts)
                  user_file = UserFile.new(current_user)
                  excel_filepath, excel_fileinfo = user_file.create(list_type, Setting.bestreader_excelx.filename)
              
                  begin
              Severity: Minor
              Found in app/controllers/manifestation_exstats_controller.rb - About 1 hr to fix

                Method new_search_internal has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def new_search_internal(manifestation_type = :all)
                      search = Sunspot.new_search(Manifestation)
                
                      Manifestation.build_search_for_manifestations_list(search, @query, @with_filter, @without_filter)
                
                
                Severity: Minor
                Found in app/controllers/manifestations_controller.rb - About 1 hr to fix

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

                    def create
                      @item_has_use_restriction = ItemHasUseRestriction.new(params[:item_has_use_restriction])
                  
                      respond_to do |format|
                        if @item_has_use_restriction.save
                  Severity: Major
                  Found in app/controllers/item_has_use_restrictions_controller.rb and 1 other location - About 1 hr to fix
                  app/controllers/library_reports_controller.rb on lines 115..126

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

                  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

                    def create
                      @library_report = LibraryReport.new(params[:library_report])
                  
                      respond_to do |format|
                        if @library_report.save
                  Severity: Major
                  Found in app/controllers/library_reports_controller.rb and 1 other location - About 1 hr to fix
                  app/controllers/item_has_use_restrictions_controller.rb on lines 48..59

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

                  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 get_resource_import_textresults_excelx has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def self.get_resource_import_textresults_excelx(resource_import_textresults)
                      # initialize
                      out_dir = "#{Rails.root}/private/system/manifestations_list_excelx"
                      excel_filepath = "#{out_dir}/list#{Time.now.strftime('%s')}#{rand(10)}.xlsx"
                      FileUtils.mkdir_p(out_dir) unless FileTest.exist?(out_dir)
                  Severity: Minor
                  Found in app/models/resource_import_textresult.rb - About 1 hr to fix

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

                      def send_message(status, reason = nil)
                        system_user = User.find(1) # TODO: システムからのメッセージの発信者
                        PurchaseRequest.transaction do
                          case status
                          when 'accepted'
                    Severity: Minor
                    Found in app/models/purchase_request.rb - About 1 hr to fix

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

                            def new_work_has_titles_from_nacsis_cat(nacsis_cat)
                              return [] if nacsis_cat.blank?
                              nacsis_info = nacsis_cat.detail
                              wht_ary = []
                              nacsis_info[:other_titles].each do |other_title|
                      Severity: Minor
                      Found in app/models/nacsis_cat.rb - About 1 hr to fix

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

                          def self.make_export_item_list_tsv(items)
                            data = String.new
                            data << "\xEF\xBB\xBF".force_encoding("UTF-8") + "\n"
                            columns = [
                              [:library, 'activerecord.models.library'],
                        Severity: Minor
                        Found in app/models/item.rb - About 1 hr to fix

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

                            def self.create_with_params(params, has_role_id)
                              logger.debug "create_with_params start."
                              user = User.new
                              user.assign_attributes(params, :as => :admin)
                          
                          
                          Severity: Minor
                          Found in app/models/user.rb - About 1 hr to fix

                            Method val_keyword has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def val_keyword
                                # 先頭に数字が混ざる可能性があるため、検証する開始文字位置を定める
                                string_location = 0
                                keyword.split("").each do |spelling|
                                  if string_location == 0 then
                            Severity: Minor
                            Found in app/models/abbreviation.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 excel_worksheet_value has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def excel_worksheet_value(ws_type, ws_col, sep_flg, ccount)
                                helper = Object.new
                                helper.extend(ItemsHelper)
                                helper.instance_eval { def t(*a) I18n.t(*a) end } # NOTE: ItemsHelper#i18n_rankの中でtを呼び出しているが、ヘルパーを直接利用しようとするとRedCloth由来のtが見えてしまうため、その回避策
                                val = nil
                            Severity: Minor
                            Found in app/models/item.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

                            Severity
                            Category
                            Status
                            Source
                            Language