MiraitSystems/enju_trunk

View on GitHub

Showing 1,155 of 1,155 total issues

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

  def create
    @publication_status = PublicationStatus.new(params[:publication_status])

    respond_to do |format|
      if @publication_status.save
Severity: Major
Found in app/controllers/publication_statuses_controller.rb and 4 other locations - About 35 mins to fix
app/controllers/barcode_lists_controller.rb on lines 53..61
app/controllers/enju_terminals_controller.rb on lines 8..16
app/controllers/numberings_controller.rb on lines 10..17
app/controllers/user_statuses_controller.rb on lines 8..15

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

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

  def reservable_with_item?(user = nil) #TODO reservabl? メソッドと重複?
    #TODO reserve.not_reserve_on_loan 変数名と実態が異なる
    # true で 貸出中のみ予約可能
    if SystemConfiguration.get("reserve.not_reserve_on_loan")
      return true if user.try(:has_role?, 'Librarian')
Severity: Minor
Found in app/models/manifestation.rb - About 35 mins 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_manifestation_reserve_stats_tsv has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.get_manifestation_reserve_stats_tsv(manifestation_reserve_stat, stats)
    data = String.new
    data << "\xEF\xBB\xBF".force_encoding("UTF-8") + "\n"

    # term
Severity: Minor
Found in app/models/manifestation_reserve_stat.rb - About 35 mins 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_order_date has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.check_order_date(start_at, end_at)
    if start_at.present? && end_at.present?
      begin
        start_at_new = Time.zone.parse(start_at)
        end_at_new = Time.zone.parse(end_at)
Severity: Minor
Found in app/models/exchange_rate.rb - About 35 mins 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_manifestation_checkout_stats_tsv has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.get_manifestation_checkout_stats_tsv(manifestation_checkout_stat, stats)
    data = String.new
    data << "\xEF\xBB\xBF".force_encoding("UTF-8") + "\n"

    # manifestation_checkout_stat
Severity: Minor
Found in app/models/manifestation_checkout_stat.rb - About 35 mins 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 _removeString has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    _removeString: function(new_input) {
        if(new_input.match(this.ignoreString)) {
            return new_input.replace(this.ignoreString, '');
        } else {
            var i, l, ignoreArray, inputArray;
Severity: Minor
Found in app/assets/javascripts/jquery.autoKana.js - About 35 mins 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_resource_import_textresult_list has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.generate_resource_import_textresult_list(resource_import_textresults, output_type, current_user, &block)
    threshold ||= Setting.background_job.threshold.export rescue nil

    # 出力件数の計算
    all_size = resource_import_textresults.count
Severity: Minor
Found in app/models/resource_import_textresult.rb - About 35 mins 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 read_wrong_format has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.read_wrong_format(filename, options = { sheet: nil, default_style: nil, data: nil })
    split = SystemConfiguration.get('set_output_format_type') ? "\t" : ","
    #file = Tsvfile_Adapter.new.open_import_file(filename)
    tempfile = Tempfile.new('resource_import_file')
    if Setting.uploaded_file.storage == :s3
Severity: Minor
Found in app/models/resource_import_textresult.rb - About 35 mins 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_export_new_item_list_tsv has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.make_export_new_item_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 35 mins 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_manifestation_list_separated_column_count has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.get_manifestation_list_separated_column_count(manifestation_ids, field_key, outer_cache = {})
    field, field_ext = field_key.split(/\./, 2)

    case field_ext
    when /\Aother_title(?:_type|_transcription|_alternativ|_transcription|_alternativee)?\z/
Severity: Minor
Found in app/models/manifestation.rb - About 35 mins 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 change_state_on_order has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def change_state_on_order
    ordered_state = CirculationStatus.where(name: "On Ordered").first

    if ordered_state
      if self.orders
Severity: Minor
Found in app/models/order_list.rb - About 35 mins 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 build_query has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def build_query(cond, inverse = false)
        if inverse
          op = 'OR'
        else
          op = 'AND'
Severity: Minor
Found in app/models/nacsis_cat.rb - About 35 mins 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_agents has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.import_agents(agent_lists, options = {})
    list = []
    return list if agent_lists.blank?

    options[:language_id] ||= 1
Severity: Minor
Found in app/models/agent.rb - About 35 mins 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_date_of_publication has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def set_date_of_publication
    return if pub_date.blank?
    begin
      date = Time.zone.parse("#{pub_date}")
    rescue ArgumentError
Severity: Minor
Found in app/models/purchase_request.rb - About 35 mins 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_manifestation_from_isbn has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def update_manifestation_from_isbn(manifestation, book_types = ManifestationType.book.all, nacsis_cat = nil, index = nil)
      raise ArgumentError if manifestation.blank?
      raise ArgumentError if manifestation.isbn.blank?
      if nacsis_cat.nil?
        result = NacsisCat.search(isbn: manifestation.isbn)
Severity: Minor
Found in app/models/nacsis_cat.rb - About 35 mins 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_agents has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.add_agents(agent_names, agent_transcriptions = nil, options = {})
    return [] if agent_names.blank?
    names = agent_names.gsub(';', ';').split(/;/)
    if agent_transcriptions.nil?
      transcriptions = []
Severity: Minor
Found in app/models/agent.rb - About 35 mins 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 count_relationship has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.count_relationship(agent_id, relation_type_id, parent_child_relationship)
    return 0 if agent_id.blank?
    if relation_type_id.blank? && parent_child_relationship.blank?
      self.where("parent_id = ? OR child_id = ?", agent_id, agent_id).count
    else
Severity: Minor
Found in app/models/agent_relationship.rb - About 35 mins 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_pdf has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.output_reminder_list_pdf(reminder_lists)
    report = EnjuTrunk.new_report('reminder_list.tlf')

    # set page_num
    report.events.on :page_create do |e|
Severity: Minor
Found in app/models/reminder_list.rb - About 35 mins 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_order has a Cognitive Complexity of 7 (exceeds 5 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 35 mins 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 summary has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def summary
    return nil unless @record

    if item?
      hash = {
Severity: Minor
Found in app/models/nacsis_cat.rb - About 35 mins 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