MiraitSystems/enju_trunk

View on GitHub

Showing 1,155 of 1,155 total issues

Method search has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def search

    @approvals = Approval.scoped

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

  def user_list(params)
    query = params[:query].to_s
    @query = query.dup
    @count = {}
    
Severity: Minor
Found in app/controllers/families_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 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create
    # check checked
    @selected_list_type = params[:export_item_list][:list_type]
    @selected_library = params[:library].map(&:to_i) if params[:library]
    @selected_carrier_type = params[:carrier_type].map(&:to_i) if params[:carrier_type]
Severity: Major
Found in app/controllers/export_item_lists_controller.rb - About 2 hrs to fix

    Method user_list has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def user_list(params)
        query = params[:query].to_s
        @query = query.dup
        @count = {}
        
    Severity: Major
    Found in app/controllers/families_controller.rb - About 2 hrs to fix

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

                  for (j = 0; j < 12; ++j) {
                      if (Calendar._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { t = j; break; }
                  }
      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 1703..1705

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

      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

                  for (j = 0; j < 12; ++j) {
                      if (Calendar._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { m = j; break; }
                  }
      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 1739..1741

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

      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 _randomiseLayout has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _randomiseLayout: function(inst) {
              var randomiseNumeric = this._get(inst, 'randomiseNumeric');
              var randomiseAlpha = this._get(inst, 'randomiseAlphabetic');
              var randomiseOther = this._get(inst, 'randomiseOther');
              var randomiseAll = this._get(inst, 'randomiseAll');
      Severity: Major
      Found in app/assets/javascripts/jquery.keypad.js - About 2 hrs to fix

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

              elsif datestr.match(/^\d{4}/)
                datestr.gsub!("年", "/")
                datestr.gsub!("月", "/")
                datestr.gsub!("日", "/")
                #puts "datestr=#{datestr}"
        Severity: Major
        Found in app/models/wareki.rb and 1 other location - About 2 hrs to fix
        lib/enju_trunk/date_helper.rb on lines 89..109

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

        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

              elsif datestr.match(/^\d{4}/)
                datestr.gsub!("年", "/")
                datestr.gsub!("月", "/")
                datestr.gsub!("日", "/")
                #puts "datestr=#{datestr}"
        Severity: Major
        Found in lib/enju_trunk/date_helper.rb and 1 other location - About 2 hrs to fix
        app/models/wareki.rb on lines 123..143

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

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

        class ExportItemListsController < ApplicationController
          before_filter :check_librarian
        
          def initialize
            @list_types = [[t('item_list.shelf_list'),1],
        Severity: Minor
        Found in app/controllers/export_item_lists_controller.rb - About 2 hrs to fix

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

          function fitHorizontal(el, leftOffset){
              var leftVal = parseInt(leftOffset) || $(el).offset().left;
              return (leftVal + $(el).width() <= getWindowWidth() + getScrollLeft() && leftVal - getScrollLeft() >= 0);
          };
          Severity: Major
          Found in app/assets/javascripts/fg.menu.js and 1 other location - About 2 hrs to fix
          app/assets/javascripts/fg.menu.js on lines 585..588

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

          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

          function fitVertical(el, topOffset){
              var topVal = parseInt(topOffset) || $(el).offset().top;
              return (topVal + $(el).height() <= getWindowHeight() + getScrollTop() && topVal - getScrollTop() >= 0);
          };
          Severity: Major
          Found in app/assets/javascripts/fg.menu.js and 1 other location - About 2 hrs to fix
          app/assets/javascripts/fg.menu.js on lines 580..583

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

          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 _showKeypad has 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _showKeypad: function(field) {
                  field = field.target || field;
                  if ($.keypad._isDisabledKeypad(field) ||
                          $.keypad._lastField == field) { // already here
                      return;
          Severity: Major
          Found in app/assets/javascripts/jquery.keypad.js - About 2 hrs to fix

            Method import has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def import(resource_import_textfile)
                I18n.locale = :ja
            
                adapter = EnjuTrunk::ResourceAdapter::Base.find_by_classname(resource_import_textfile.adapter_name)
                adapter.logger = logger
            Severity: Major
            Found in lib/enju_trunk/resourceadapter/resource_import.rb - About 2 hrs to fix

              Method article_attributes has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def article_attributes(origin_datas, sheet)
                    attrs = {}
                    Manifestation.article_output_columns.each do |column|
                      name, value = sheet.field_name_and_data(origin_datas, column)
              
              
              Severity: Major
              Found in lib/enju_trunk/resourceadapter/import_article.rb - About 2 hrs to fix

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

                  def has_available_items?(role_id = 1)
                    unless article? or root_of_series?
                      return false if items.empty?
                      is = items.where(['required_role_id <= ?', role_id])
                      if SystemConfiguration.get('manifestation.search.hide_not_for_loan')
                Severity: Minor
                Found in app/models/manifestation.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

                Function setPosition has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                Menu.prototype.setPosition = function(widget, caller, options) { 
                    var el = widget;
                    var referrer = caller;
                    var dims = {
                        refX: referrer.offset().left,
                Severity: Minor
                Found in app/assets/javascripts/fg.menu.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_export_new_item_list_pdf has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                  def self.make_export_new_item_list_pdf(items)
                    return false if items.blank?
                    report = EnjuTrunk.new_book_list('new_item_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 make_export_item_list_pdf has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                  def self.make_export_item_list_pdf(items, filename)
                    return false if items.blank?
                    report = EnjuTrunk.new_book_list('item_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_pdf_user_number_list has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                  def create_pdf_user_number_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 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

                Severity
                Category
                Status
                Source
                Language