MiraitSystems/enju_trunk

View on GitHub

Showing 1,155 of 1,155 total issues

Method make_export_new_book_list_pdf has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  def self.make_export_new_book_list_pdf(items)
    return false if items.blank?
    report = EnjuTrunk.new_report('new_book_list')

    report.events.on :page_create do |e|
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 create has a Cognitive Complexity of 20 (exceeds 5 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 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 output_userlist_tsv has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  def self.output_userlist_tsv(users)
    columns = [
      [:full_name, 'activerecord.attributes.agent.full_name'],
      [:full_name_transcription, 'activerecord.attributes.agent.full_name_transcription'],
      [:full_name_alternative, 'activerecord.attributes.agent.full_name_alternative'],
Severity: Minor
Found in app/models/user.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_root_manifestation_instance_vals has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  def set_root_manifestation_instance_vals(root_manifestation)
    @creators = root_manifestation.try(:creates).present? ? root_manifestation.creates.order(:position) : [{}] unless @creators
    @contributors = root_manifestation.try(:realizes).present? ? root_manifestation.realizes.order(:position) : [{}] unless @contributors
    @publishers = root_manifestation.try(:produces).present? ? root_manifestation.produces.order(:position) : [{}] unless @publishers
    @subjects = root_manifestation.try(:subjects).present? ? root_manifestation.subjects.order(:position) : [{}] unless @subjects
Severity: Minor
Found in app/controllers/series_statements_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 20 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    @item = Item.new(params[:item])

    @manifestation = Manifestation.find(@item.manifestation_id)

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

    def update_manifestation_classifications(sheet, datas, field, manifestation, error_msgs)
      return unless field == 'book'

      classification_field = "#{field}.classification"
      classification_type_field = "#{field}.classification_type"
Severity: Minor
Found in lib/enju_trunk/resourceadapter/import_book.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 detail has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def detail
    return nil unless @record

    {
      :subject_heading => @record['TR'].try(:[], 'TRD'),
Severity: Major
Found in app/models/nacsis_cat.rb - About 2 hrs to fix

    Method import_for_incremental_synchronization! has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def import_for_incremental_synchronization!(dump)
          last_processed = current_proccessing = nil
          item_attributes = nil
    
          # レコード毎の履歴
    Severity: Major
    Found in app/models/version.rb - About 2 hrs to fix

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

          if (mon) {
              date = new Date(cal.date);
              if (mon.month != date.getMonth()) {
                  date.setMonth(mon.month);
                  cal.setDate(date);
      Severity: Major
      Found in app/assets/javascripts/jquery.simplecalendarjp.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/jquery.simplecalendarjp.js on lines 425..433

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

      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

              if (year) {
                  date = new Date(cal.date);
                  if (year.year != date.getFullYear()) {
                      date.setFullYear(year.year);
                      cal.setDate(date);
      Severity: Major
      Found in app/assets/javascripts/jquery.simplecalendarjp.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/jquery.simplecalendarjp.js on lines 415..434

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

      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 checkout_statistics.rb has 277 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class CheckoutStatistics
        include ActiveModel::Conversion
        include ActiveModel::Validations
        extend ActiveModel::Naming
        extend ActiveModel::Translation
      Severity: Minor
      Found in app/models/checkout_statistics.rb - About 2 hrs to fix

        Function setPosition has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Menu.prototype.setPosition = function(widget, caller, options) { 
            var el = widget;
            var referrer = caller;
            var dims = {
                refX: referrer.offset().left,
        Severity: Major
        Found in app/assets/javascripts/fg.menu.js - About 2 hrs to fix

          Method make_detail_data has 66 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def make_detail_data(item_statistics, second_items)
              detail = {: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 - About 2 hrs to fix

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

              def prepare_options
                @subject_types = SubjectType.all
                @carrier_types = CarrierType.all
                @sub_carrier_types = SubCarrierType.all
                @manifestation_types = ManifestationType.all
            Severity: Major
            Found in app/controllers/manifestations_controller.rb - About 2 hrs to fix

              Function cookie has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

              jQuery.cookie = function (key, value, options) {
              
                  // key and at least value given, set cookie...
                  if (arguments.length > 1 && String(value) !== "[object Object]") {
                      options = jQuery.extend({}, options);
              Severity: Minor
              Found in app/assets/javascripts/jquery.cookie.js - 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 make_form has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                def make_form(system_configuration, errors = nil)
                  #TODO:
                  error = nil
                  if errors
                    errors.each do |e|
              Severity: Minor
              Found in app/helpers/system_configurations_helper.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_serial_number has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                def set_serial_number(m)
                  if m.serial_number_string.present? 
                    m.serial_number_string = m.serial_number_string.match(/\D/) ? nil : m.serial_number_string.to_i + 1
                    unless m.issue_number_string.blank?
                      m.issue_number_string = m.issue_number_string.match(/\D/) ? nil : m.issue_number_string.to_i + 1
              Severity: Minor
              Found in app/helpers/manifestations_helper.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 bulk_update has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                def bulk_update
                  unless (user_signed_in? and current_user.has_role?('Librarian'))
                    access_denied; return
                  end
                  unless @basket
              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 show has 64 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def show
                  case params[:size]
                  when 'original'
                    size = 'original'
                  when 'thumb'
              Severity: Major
              Found in app/controllers/picture_files_controller.rb - About 2 hrs to fix

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

                  def index
                    flash[:reserve_notice] = ""
                    unless params[:do_search].blank?
                      query = params[:query].to_s.strip
                      @query = query.dup
                Severity: Major
                Found in app/controllers/reminder_lists_controller.rb - About 2 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language