MiraitSystems/enju_trunk

View on GitHub

Showing 1,155 of 1,155 total issues

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

    items.each do |item|
      report.page.list(:list).add_row do |row|
        row.item(:library).value(item.shelf.library.display_name.localize) if item.shelf && item.shelf.library
        row.item(:acquired_at).value(item.acquired_at_string) if item.acquired_at_string
        row.item(:bookstore).value(item.bookstore.name) if item.bookstore
Severity: Major
Found in app/models/item.rb and 1 other location - About 2 hrs to fix
app/models/item.rb on lines 1173..1182

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

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

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

    items.each do |item|
      report.page.list(:list).add_row do |row|
        row.item(:library).value(item.shelf.library.display_name.localize) if item.shelf && item.shelf.library
        row.item(:acquired_at).value(item.acquired_at_string) if item.acquired_at_string
        row.item(:bookstore).value(item.bookstore.name) if item.bookstore
Severity: Major
Found in app/models/item.rb and 1 other location - About 2 hrs to fix
app/models/item.rb on lines 1255..1264

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

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

File reminder_list.rb has 271 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class ReminderList < ActiveRecord::Base
  attr_accessible :item_identifier, :status, :mail_sent_at

  default_scope :order => 'reminder_lists.id DESC'

Severity: Minor
Found in app/models/reminder_list.rb - About 2 hrs to fix

    Class NacsisCatSearch has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class NacsisCatSearch
        # sunspot_solrのSearchオブジェクトとの互換層
    
        include FormInputUtils
    
    
    Severity: Minor
    Found in app/controllers/manifestations_controller.rb - About 2 hrs to fix

      Method create_manifestation_from_nacsis_cat has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def create_manifestation_from_nacsis_cat(nacsis_cat, book_types, manifestation = nil)
              return nil if nacsis_cat.blank?
      
              ActiveRecord::Base.transaction do
                child_manifestation = nil
      Severity: Major
      Found in app/models/nacsis_cat.rb - About 2 hrs to fix

        Method set_user_value has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def set_user_value(user, row)
            #日本語化
            username = I18n.t('activerecord.attributes.user.username')
            user_number = I18n.t('activerecord.attributes.user.user_number')
            library = I18n.t('activerecord.attributes.user.library')
        Severity: Major
        Found in app/models/agent_import_file.rb - About 2 hrs to fix

          Method read_wrong_sheet has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.read_wrong_sheet(extraparams, options = { sheet: nil, default_style: nil, data: nil })
              oo = Excelx.new(eval(extraparams)['filename'])
              sheet_name = eval(extraparams)['sheet'] rescue nil
              oo.default_sheet = sheet_name
              begin
          Severity: Minor
          Found in app/models/resource_import_textresult.rb - About 2 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 check_price has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def check_price
              record = Expense.where(:item_id => self.id).order("id DESC").first
              begin
                unless record.nil?
                  record.acquired_at_ym = select_acquired_at
          Severity: Minor
          Found in app/models/item.rb - About 2 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 is_original? has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def is_original?
              if self.rank == 0
                manifestation = nil
                if self.manifestation
                  manifestation = self.manifestation
          Severity: Minor
          Found in app/models/item.rb - About 2 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 generate_non_arrival_list has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.generate_non_arrival_list(start_at, end_at)
              # generate order list
              logger.debug "self.generate_non_arrival_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 2 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 add_exinfos has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.add_exinfos(exinfos, item_id)
              return [] if exinfos.blank?
              list = []
              exinfos.each do |key, value|
                name = key.split('_').first 
          Severity: Minor
          Found in app/models/item_exinfo.rb - About 2 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 hold_query has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

                def hold_query(command, db_type)
                  return unless @item
                  return @item.nacsis_identifier if command == 'delete'
          
                  query_field = command == 'update' ? ["ID=#{@item.nacsis_identifier}"] : []
          Severity: Minor
          Found in app/models/nacsis_cat.rb - About 2 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 get has a Cognitive Complexity of 18 (exceeds 5 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 2 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 add_exinfos has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.add_exinfos(exinfos, manifestation_id)
              return [] if exinfos.blank?
              list = []
              exinfos.each do |key, value|
                name = key.split('_').first
          Severity: Minor
          Found in app/models/manifestation_exinfo.rb - About 2 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 get_list_size has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def get_list_size
              unless request.xhr? && params[:list_type].present?
                render :nothing => true, :status => :not_found
                return
              end
          Severity: Minor
          Found in app/controllers/export_item_lists_controller.rb - About 2 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 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def create
              # check checked
              @selected_list_type = params[:export_item_list][:list_type]
              @selected_library = params[:library].map(&:to_i) if params[:library]
              @selected_carrier_type = params[:carrier_type].map(&:to_i) if params[:carrier_type]
          Severity: Minor
          Found in app/controllers/export_item_lists_controller.rb - About 2 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_all has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def update_all
              respond_to do |format|
                begin
                  @current_basket.checked_manifestations.map(&:manifestation).each do |m|
                    if m.series_statement
          Severity: Minor
          Found in app/controllers/series_has_manifestations_controller.rb - About 2 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 has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def import(resource_import_textfile)
              I18n.locale = :ja
          
              adapter = EnjuTrunk::ResourceAdapter::Base.find_by_classname(resource_import_textfile.adapter_name)
              adapter.logger = logger
          Severity: Minor
          Found in lib/enju_trunk/resourceadapter/resource_import.rb - About 2 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 18 (exceeds 5 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 2 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 set_list has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def set_list(obj, status)
              unless obj.blank?
                obj.each do |i|
                  @same_items =  LossItem.where(:item_id => i.id) if obj == @items and status.blank?
                  @same_items =  LossItem.where(:item_id => i.id, :status => status) if obj == @items and !status.blank?
          Severity: Minor
          Found in app/controllers/loss_items_controller.rb - About 2 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