MiraitSystems/enju_trunk

View on GitHub

Showing 1,155 of 1,155 total issues

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

  def self.make_export_removed_list_tsv(items)
    data = String.new
    data << "\xEF\xBB\xBF".force_encoding("UTF-8") + "\n"

    columns = [
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

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

  def exist_series_statement?
    if self.before_series_statement_relationship_id.present?
      before_series_statement = SeriesStatement.find(self.before_series_statement_relationship_id) rescue nil
      unless before_series_statement
        errors.add(:before_series_statement_relationship_id, I18n.t('series_statement_relationship.not_exist_series_statement'))
Severity: Minor
Found in app/models/series_statement_relationship.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 detail has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def detail
    return nil unless @record

    {
      :subject_heading => @record['TR'].try(:[], 'TRD'),
Severity: Minor
Found in app/models/nacsis_cat.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 filterout_personal_attributes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def filterout_personal_attributes(item_type, item_attributes)
        item_attributes.dup.tap do |hash|
          hash.each_pair do |name, value|
            # user_idがnilでないAgentレコードは
            # 一部を除いた属性を空にする
Severity: Minor
Found in app/models/version.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 initialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(options = {})
      model_class = NacsisUserRequest
      @search = Sunspot.new_search(model_class)

      per_page = normalize_integer(options[:per_page]) || model_class.default_per_page
Severity: Minor
Found in app/controllers/nacsis_user_requests_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

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

  def check_status
    if self.all_process_start_at

      if self.all_process_end_at
        self.set_all_process_end
Severity: Minor
Found in app/models/approval.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 create_pdf_item_identifier_list has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def create_pdf_item_identifier_list(start_number, end_number)
    dir_base = "#{Rails.root}/private/system/barcode_list/#{self.id}/original/"
    FileUtils.mkdir_p(dir_base) unless FileTest.exist?(dir_base)

    filename = "barcode.pdf"
Severity: Minor
Found in app/models/barcode_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 deletable_by has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def deletable_by(current_user)
    # 未返却の資料のあるユーザを削除しようとした
    if self.checkouts.not_returned.count > 0
      errors[:base] << I18n.t('user.this_user_has_checked_out_item')
    end
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 create_from_nacsis has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def create_from_nacsis
    ncid = params['ncid']
    type = params['manifestation_type'] || 'book'

    if type == 'book'
Severity: Minor
Found in app/controllers/manifestations_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

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

  def update_search_sessions(search_opts, search_container)
    return unless search_opts[:index] == :local # FIXME: 非local検索のときにも動作するようにする

    search = search_container[:session]

Severity: Minor
Found in app/controllers/manifestations_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

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

  def search_bookstores
    return nil unless request.xhr?
    exist = true
    unless params[:input].blank?
      query = params[:input]
Severity: Minor
Found in app/controllers/bookstores_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

Method index has a Cognitive Complexity of 12 (exceeds 5 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

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

    def create_article_item(attrs, manifestation, item, textfile, numbering, mode = 'edit')
      unless item
        if manifestation.items.size < 1
          mode = 'create'
          item = Item.new
Severity: Minor
Found in lib/enju_trunk/resourceadapter/import_article.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 import_row_data has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def import_row_data(origin_datas, row_num, textfile, sheet, numbering, auto_numbering, not_set_serial_number, external_resource)
    logger.info "import start row_num=#{row_num}"

    sheet_name = sheet.excelx_sheet
    with_import_message(textfile) do |res|
Severity: Minor
Found in lib/enju_trunk/resourceadapter/resource_import.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 fix_rank has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def fix_rank(cell, options = {:manifestation => nil, :mode => 'create'})
      case cell
      when I18n.t('item.original')
        #if manifestation.items.map {|i| i.rank.to_i }.compact.include?(0)
        #  raise I18n.t('resource_import_textfile.error.book.has_original', :data => cell)
Severity: Minor
Found in lib/enju_trunk/resourceadapter/import_book.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 index has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    search = Sunspot.new_search(SeriesStatement)
    query = params[:query].to_s.strip
    page = params[:page] || 1
    unless query.blank?
Severity: Minor
Found in app/controllers/series_statements_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

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

  def index
    @bookstores = Bookstore.all
    @bookstore_id = params[:bookstore_id]
    @ordered_start_at = params[:ordered_start_at]
    @ordered_end_at = params[:ordered_end_at]
Severity: Minor
Found in app/controllers/order_lists_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

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

    def create_article_manifestation(attrs, item, manifestation_type, mode = 'edit')
      manifestation = nil
      if item
         manifestation = item.manifestation
      else
Severity: Minor
Found in lib/enju_trunk/resourceadapter/import_article.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 split_clause_text has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def split_clause_text(line)
    clauses = []

    s = StringScanner.new(line)
    text = ''
Severity: Minor
Found in lib/enju_leaf/porta_cql.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

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

  def create
    @subscription = Subscription.new(params[:subscription])
    @subscription.user = current_user

    respond_to do |format|
Severity: Major
Found in app/controllers/subscriptions_controller.rb and 2 other locations - About 1 hr to fix
app/controllers/agent_import_files_controller.rb on lines 59..69
app/controllers/resource_import_files_controller.rb on lines 59..69

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

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

Severity
Category
Status
Source
Language