MiraitSystems/enju_trunk

View on GitHub

Showing 1,155 of 1,155 total issues

Method update has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    check_can_access_purchase_request

    if @user
      @purchase_request = @user.purchase_requests.find(params[:id])
Severity: Minor
Found in app/controllers/purchase_requests_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_with_params has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def self.create_with_params(params, has_role_id)
    logger.debug "create_with_params start."
    user = User.new
    user.assign_attributes(params, :as => :admin)

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

  def new
    if user_signed_in?
      unless current_user.has_role?('Librarian')
        access_denied; return
      end
Severity: Minor
Found in app/controllers/users_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 index has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    sort = User.set_sort(params[:sort_by], params[:order])
    page = params[:page] || 1
    role = current_user.try(:role) || Role.default_role
    @search = User.search do
Severity: Minor
Found in app/controllers/unablelist_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 delete_record has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def delete_record(error_msgs, item, manifestation, series_statement)
      deleted_item =
        deleted_item_identifier =
        deleted_manifestation =
        deleted_manifestation_title =
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 make_item_register_tsv has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.make_item_register_tsv(tsvfile, items)
    columns = [
      [:bookstore, 'activerecord.models.bookstore'],
      ['item_identifier', 'activerecord.attributes.item.item_identifier'],
      ['acquired_at_string', 'activerecord.attributes.item.acquired_at_string'],
Severity: Major
Found in app/models/item.rb - About 2 hrs to fix

    Method get_unable_list_pdf has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.get_unable_list_pdf(users, sort)
        report = EnjuTrunk.new_report('userlist.tlf')
        # set page_num
        report.events.on :page_create do |e|
          e.page.item(:page).value(e.page.no)
    Severity: Major
    Found in app/models/unablelist.rb - About 2 hrs to fix

      Method update has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def update
          if params[:manifestation][:identifiers_attributes]
            params[:manifestation][:identifiers_attributes].each do |key, identifier_attributes|
              if identifier_attributes[:body].blank?
                params[:manifestation][:identifiers_attributes]["#{key}"][:_destroy] = 1
      Severity: Major
      Found in app/controllers/manifestations_controller.rb - About 2 hrs to fix

        Method create has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def create
            LossItem.transaction do 
              flash[:notice] = ""
              @loss_item = LossItem.new(params[:loss_item])
              if params[:user_number]
        Severity: Major
        Found in app/controllers/loss_items_controller.rb - About 2 hrs to fix

          Class Sheet has 21 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class Sheet
              def self.new_from_rows(rows)
                new do |obj|
                  obj.rows = rows
                end
          Severity: Minor
          Found in lib/enju_trunk/resourceadapter/resource_import.rb - About 2 hrs to fix

            Method get_manifestation_list_separated_column_count has 54 lines of code (exceeds 25 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: Major
            Found in app/models/manifestation.rb - About 2 hrs to fix

              Method generate_non_arrival_list has 54 lines of code (exceeds 25 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: Major
              Found in app/models/order_list.rb - About 2 hrs to fix

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

                  def index
                    query = params[:query].to_s.strip
                    per_page = Item.default_per_page
                    @count = {}
                    if user_signed_in?
                Severity: Major
                Found in app/controllers/items_controller.rb - About 2 hrs to fix

                  Method build_select2 has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def build_select2(selector_id, selector_name, collection, selected_id, options)
                          include_blank = options[:include_blank] || false
                          alt_display = options.has_key?(:alt_display) ? options[:alt_display] : true
                          width = options[:width] || 300
                          select_attribute = options[:select_attribute] || :v
                  Severity: Major
                  Found in lib/enju_trunk/enju_trunk_helper.rb - About 2 hrs to fix

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

                          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(:carrier_type).value(item.manifestation.carrier_type.display_name.localize) if item.manifestation && item.manifestation.carrier_type
                            row.item(:shelf).value(item.shelf.display_name) if item.shelf
                            row.item(:ndc).value(item.manifestation.ndc) if item.manifestation
                    Severity: Major
                    Found in app/models/item.rb and 1 other location - About 2 hrs to fix
                    app/models/item.rb on lines 834..841

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

                    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

                          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(:carrier_type).value(item.manifestation.carrier_type.display_name.localize) if item.manifestation && item.manifestation.carrier_type
                            row.item(:shelf).value(item.shelf.display_name) if item.shelf
                            row.item(:ndc).value(item.manifestation.ndc) if item.manifestation
                    Severity: Major
                    Found in app/models/item.rb and 1 other location - About 2 hrs to fix
                    app/models/item.rb on lines 864..871

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

                    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

                    Function minicolors has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            minicolors: function(method, data) {
                    
                                switch(method) {
                    
                                    // Destroy the control
                    Severity: Major
                    Found in app/assets/javascripts/jquery.minicolors.js - About 2 hrs to fix

                      Method make_audio_list_tsv has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def self.make_audio_list_tsv(tsvfile, items)
                          columns = [
                            [:library, 'activerecord.models.library'],
                            [:carrier_type, 'activerecord.models.carrier_type'],
                            [:shelf, 'activerecord.models.shelf'],
                      Severity: Major
                      Found in app/models/item.rb - About 2 hrs to fix

                        Method monthly_report has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def monthly_report
                            yyyymm = params[:library_report][:yyyymm]
                            library_ids = params[:library]
                            begin
                              report = EnjuTrunk.new_report('monthly_library_report.tlf')
                        Severity: Major
                        Found in app/controllers/library_reports_controller.rb - About 2 hrs to fix

                          Method new has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def new
                              if Shelf.real.blank?
                                flash[:notice] = t('item.create_shelf_first')
                                redirect_to libraries_url
                                return
                          Severity: Major
                          Found in app/controllers/items_controller.rb - About 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language