MiraitSystems/enju_trunk

View on GitHub

Showing 1,155 of 1,155 total issues

Method get_user_label has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def get_user_label
    @printed_types = %w(printed_type_full_name printed_type_address printed_type_postal_barcode)
    @selected_type = params[:type]

    if params[:users] and @selected_type
Severity: Minor
Found in app/controllers/print_labels_controller.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 parse_date_string has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_date_string(date_str)
    return [nil, nil] if date_str.blank?

    begin
      time = Time.zone.parse(date_str)
Severity: Minor
Found in app/controllers/form_input_utils.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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    @order = Order.new(params[:order])
    if @order.item_id.blank? && @order.manifestion_id.blank?
      # error
    end
Severity: Minor
Found in app/controllers/orders_controller.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 create_import_start_message has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create_import_start_message(sheet, resource_import_textfile)
    sheet_name = sheet.excelx_sheet
    with_import_message(resource_import_textfile, true) do |res|
      res.extraparams = "{'sheet'=>'#{sheet_name}'}" if sheet_name
      res.body        = sheet.field.keys.join("\t")
Severity: Minor
Found in lib/enju_trunk/resourceadapter/resource_import.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_subjects has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def update_manifestation_subjects(sheet, datas, field, manifestation, error_msgs)
      if Manifestation.separate_output_columns?
        subject_data = sheet.field_data_set(
          datas, %W(#{field}.subject #{field}.subject_transcription))
        if subject_data.nil?
Severity: Minor
Found in lib/enju_trunk/resourceadapter/import_book.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 index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    @count = {}

    search = Sunspot.new_search(Item)
    set_role_query(current_user, search)
Severity: Minor
Found in app/controllers/loss_items_controller.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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create

    @approval = Approval.new(params[:approval])
    @approval.check_status
    @approval.identifier = params[:identifier] if params[:identifier]
Severity: Minor
Found in app/controllers/approvals_controller.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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    @loss_item = LossItem.find(params[:id])
    LossItem.transaction do 
      @loss_item.status = params[:loss_item][:status]
      @loss_item.note = params[:loss_item][:note]
Severity: Minor
Found in app/controllers/loss_items_controller.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_book_row has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def check_book_row(sheet, is_series, errmsg_key)
      if is_series
        unless yield(SERIES_REQUIRE_COLUMNS) && yield(BOOK_REQUIRE_COLUMNS)
          series_field_names = SERIES_REQUIRE_COLUMNS.map {|c| sheet.field_name(c) }
          book_field_names = BOOK_REQUIRE_COLUMNS.map {|c| sheet.field_name(c) }
Severity: Minor
Found in lib/enju_trunk/resourceadapter/import_book.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 manage_list_of_order has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def manage_list_of_order
    @start_at_s = params[:start_at]
    @end_at_s = params[:end_at]
    action = params[:submit_order_list] || params[:submit_not_arrival_list]

Severity: Minor
Found in app/controllers/order_lists_controller.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 fix_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def fix_data(cell)
    return nil unless cell
    cell = cell.to_s.strip

    if cell.match(/^[0-9]+\.0$/)
Severity: Minor
Found in lib/enju_trunk/resourceadapter/resource_import.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 process_article_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def process_article_data(import_textresult, origin_datas, sheet, textfile, numbering)
      check_article_datas_has_necessary_field(origin_datas, sheet)

      attrs = article_attributes(origin_datas, sheet)
      item, mode, error_msg = find_same_item(attrs, sheet.manifestation_type)
Severity: Minor
Found in lib/enju_trunk/resourceadapter/import_article.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 to_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def to_params
        @options.inject({ :spellcheck => 'true' }) do |params, (key, val)|
          params.tap do |h|
            if key == :collate && val.is_a?(Fixnum)
              h[:"spellcheck.collate"] = "true"
Severity: Minor
Found in lib/plugins/ext/sunspot/spellcheck.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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    SeriesStatement.transaction do
      if params[:move]
        move_position(@series_statement, params[:move])
        return
Severity: Minor
Found in app/controllers/series_statements_controller.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 translation_for_output_columns has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def translation_for_output_columns
        translation = {}
        column_spec = {}
        initialize_output_column_spec(column_spec, true)

Severity: Minor
Found in lib/enju_trunk/output_columns.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_or_create_series_statement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def update_or_create_series_statement(datas, sheet, manifestation, series_statement)
      if series_statement
        mode = 'edit'
      else
        mode = 'create'
Severity: Minor
Found in lib/enju_trunk/resourceadapter/import_book.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 unite_au_query has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def unite_au_query(query)
    new_query = []
    au_item = []
    str = "au_text:"
    au_flg = false
Severity: Minor
Found in lib/enju_leaf/openurl.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

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

        rescue EnjuNdl::InvalidIsbn
          import_result.error_msg = "FAIL[#{row_num}]: "+I18n.t('resource_import_file.invalid_isbn', :isbn => isbn)
          Rails.logger.error "FAIL[#{row_num}]: import_isbn catch EnjuNdl::InvalidIsbn isbn: #{isbn}"
          manifestation = nil
          num[:failed] += 1
Severity: Minor
Found in app/models/resource_import_file.rb and 1 other location - About 35 mins to fix
app/models/resource_import_file.rb on lines 120..125

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

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

        rescue EnjuNdl::RecordNotFound
          import_result.error_msg = "FAIL[#{row_num}]: "+I18n.t('resource_import_file.record_not_found', :isbn => isbn)
          Rails.logger.error "FAIL[#{row_num}]: import_isbn catch EnjuNdl::RecordNotFound isbn: #{isbn}"
          manifestation = nil
          num[:failed] += 1
Severity: Minor
Found in app/models/resource_import_file.rb and 1 other location - About 35 mins to fix
app/models/resource_import_file.rb on lines 114..119

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

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

    def create_manifestation_from_nbn(nbn, book_types = ManifestationType.book.all, nacsis_cat = nil)
      raise ArgumentError if nbn.blank?
      if nacsis_cat.nil?
        result = NacsisCat.search(dbs: [:book], nbn: nbn)
        nacsis_cat = result[:book].first
Severity: Major
Found in app/models/nacsis_cat.rb and 5 other locations - About 35 mins to fix
app/models/nacsis_cat.rb on lines 109..115
app/models/nacsis_cat.rb on lines 124..130
app/models/nacsis_cat.rb on lines 301..307
app/models/nacsis_cat.rb on lines 311..317
app/models/nacsis_cat.rb on lines 320..326

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

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