MiraitSystems/enju_trunk

View on GitHub

Showing 1,155 of 1,155 total issues

Method exec_print has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def exec_print
    @barcode_list = BarcodeList.find(params[:id])

    respond_to do |format|
      if @barcode_list.usage_type == "user"
Severity: Minor
Found in app/controllers/barcode_lists_controller.rb - About 1 hr to fix

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

      def index
        @count = {}
        search = Sunspot.new_search(LibraryReport)
        if params[:yyyymm]
          @yyyymm = params[:yyyymm]
    Severity: Minor
    Found in app/controllers/library_reports_controller.rb - About 1 hr to fix

      Method prepare_options has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def prepare_options
          @libraries = Library.real
          @libraries.delete_if {|l| l.shelves.empty?}
          if @item.new_record?
            @library = Library.real.first(:order => :position, :include => :shelves)
      Severity: Minor
      Found in app/controllers/items_controller.rb - About 1 hr to fix

        Method attr_extext_accessor has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def attr_extext_accessor(*args)
            args.each do |arg|
              class_eval <<-EOF
                attr_accessible :#{arg}, :#{arg}_type_id
                def #{arg}=(obj)
        Severity: Minor
        Found in lib/active_record_extension.rb - About 1 hr to fix

          Method search has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def search
          
              @approvals = Approval.scoped
          
              # approval_identifier
          Severity: Minor
          Found in app/controllers/approvals_controller.rb - About 1 hr to fix

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

                    record_count.times do
                      sum_details << {: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},
            Severity: Major
            Found in app/models/item_statistics.rb and 1 other location - About 1 hr to fix
            app/models/item_statistics.rb on lines 654..660

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

            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 update
                @budget_category = BudgetCategory.find(params[:id])
                if params[:move]
                  move_position(@budget_category, params[:move])
                  return
            Severity: Major
            Found in app/controllers/budget_categories_controller.rb and 1 other location - About 1 hr to fix
            app/controllers/departments_controller.rb on lines 27..41

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

            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

                    record_count.times do
                      grand_totals << {: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},
            Severity: Major
            Found in app/models/item_statistics.rb and 1 other location - About 1 hr to fix
            app/models/item_statistics.rb on lines 147..153

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

            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 update
                @department = Department.find(params[:id])
                if params[:move]
                  move_position(@department, params[:move])
                  return
            Severity: Major
            Found in app/controllers/departments_controller.rb and 1 other location - About 1 hr to fix
            app/controllers/budget_categories_controller.rb on lines 54..67

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

            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

            Function keyHandler has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function keyHandler( handleObj ) {
                    // Only care when a possible input has been specified
                    if ( typeof handleObj.data !== "string" ) {
                        return;
                    }
            Severity: Minor
            Found in app/assets/javascripts/jquery.hotkeys.js - About 1 hr to fix

              Method output_reminder_list_tsv has 40 lines of code (exceeds 25 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 1 hr to fix

                Method do_order has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def do_order(letter_file_only = false)
                    # generate order file
                    order_file_dir = File.join(Rails.root.to_s, 'private', 'system', 'order_letter', "#{self.id}")
                    order_file_path = File.join(order_file_dir, "order_letter_#{Time.now.strftime("%Y%m%d")}")
                    FileUtils.mkdir_p(order_file_dir)
                Severity: Minor
                Found in app/models/order_list.rb - About 1 hr to fix

                  Method make_export_new_book_list_tsv has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def self.make_export_new_book_list_tsv(items)
                      data = String.new
                      data << "\xEF\xBB\xBF".force_encoding("UTF-8") + "\n"
                  
                      # set term
                  Severity: Minor
                  Found in app/models/item.rb - About 1 hr to fix

                    Method create has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def create
                        if @bookbinding
                          @binding_item = BindingItem.new(params[:binding_item])
                          @binding_item.bookbinding = @bookbinding
                        else
                    Severity: Minor
                    Found in app/controllers/binding_items_controller.rb - About 1 hr to fix

                      Method create has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def create
                          @agent = Agent.new(params[:agent])
                      
                          if @agent.user_username
                            @agent.user = User.find(@agent.user_username) rescue nil
                      Severity: Minor
                      Found in app/controllers/agents_controller.rb - About 1 hr to fix

                        Method update has 40 lines of code (exceeds 25 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 1 hr to fix

                          Method cleanup! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def cleanup!
                                now = Time.now
                          
                                Dir.glob(path_format%['*', '*', '*', '*']) do |path|
                                  next unless File.file?(path)
                          Severity: Minor
                          Found in app/models/user_file.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 generate_order_list has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def self.generate_order_list(start_at, end_at)
                              # generate order list
                              logger.debug "self.generate_order_list start_at=#{start_at} end_at=#{end_at}"
                          
                              order_lists = OrderList.where(:ordered_at => start_at.beginning_of_day..end_at.end_of_day)
                          Severity: Minor
                          Found in app/models/order_list.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 user_notice has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def user_notice
                              @messages = []
                              @messages << I18n.t('user.not_connect', :user => self.username) if self.unable
                              overdues = self.checkouts.overdue(Time.zone.today.beginning_of_day) rescue nil
                              @messages << I18n.t('user.overdue_item', :user => self.username, :count => overdues.length) unless overdues.empty?
                          Severity: Minor
                          Found in app/models/user.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 get_family_info has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def get_family_info
                              return nil unless request.xhr?
                              unless params[:user_id].blank?
                                family_id = FamilyUser.where(:user_id => params[:user_id]).first.family_id rescue nil
                                @user = User.find(FamilyUser.where(:family_id => family_id).order(:id).first.user_id) rescue nil
                          Severity: Minor
                          Found in app/controllers/users_controller.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