MiraitSystems/enju_trunk

View on GitHub

Showing 1,155 of 1,155 total issues

Method suggestions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def suggestions
        suggestions = raw_suggestions
        return nil unless suggestions.is_a?(Array)

        suggestions.each_slice(2).inject({}) do |hash, (key, val)|
Severity: Minor
Found in lib/plugins/ext/sunspot/spellcheck.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_data_is_numeric has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def check_data_is_numeric(field_value, field_name, options = {:mode => 'create'})
      if options[:mode] == "delete"
        return nil if field_value.nil? or field_value.blank?
      end
      return nil unless field_value
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 logic_adapter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def logic_adapter
    case
    when LOGIC_ALL.include?(@index)
      raise AdapterError unless %w[ALL ANY = EXACT ^].include?(@relation)
    when LOGIC_ANY.include?(@index)
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 2 locations. Consider refactoring.
Open

  def state_facet(state, current_states, facet)
    string = ''
    current = true if current_states.include?(state)
    string << "<strong>" if current
    string << link_to("#{t('activerecord.attributes.nacsis_user_request.state_names')[state.state]} (" + facet.count.to_s + ")", url_for(params.merge(:page => nil, :state => state.state, :view => nil)))
Severity: Major
Found in app/helpers/nacsis_user_requests_helper.rb and 1 other location - About 1 hr to fix
app/helpers/nacsis_user_requests_helper.rb on lines 3..9

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

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

  def request_type_facet(request_type, current_request_types, facet)
    string = ''
    current = true if current_request_types.include?(request_type)
    string << "<strong>" if current
    string << link_to("#{t('activerecord.attributes.nacsis_user_request.request_type_names')[request_type.request_type]} (" + facet.count.to_s + ")", url_for(params.merge(:page => nil, :request_type => request_type.request_type, :view => nil)))
Severity: Major
Found in app/helpers/nacsis_user_requests_helper.rb and 1 other location - About 1 hr to fix
app/helpers/nacsis_user_requests_helper.rb on lines 12..18

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

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

        print_log "--#{index}-- START to update Manifestation(#{manifestation.id}) IDENTIFIER: #{manifestation.identifier} ISBN: #{manifestation.isbn}"
        catalog = Catalog.where(:display_name => 'NACSIS UPDATE', :name => 'NACSIS UPDATE', :nacsis_identifier => 'NACSIS UPDATE').first_or_create
        manifestation.update_attribute('catalog_id', catalog.id)

        begin 
Severity: Major
Found in app/models/nacsis_cat.rb and 1 other location - About 1 hr to fix
app/models/nacsis_cat.rb on lines 259..269

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

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

        print_log "--#{index}-- START to update Manifestation(#{manifestation.id}) IDENTIFIER: #{manifestation.identifier} NBN: #{manifestation.nbn}"
        #TODO 
        catalog = Catalog.where(:display_name => 'NACSIS UPDATE', :name => 'NACSIS UPDATE', :nacsis_identifier => 'NACSIS UPDATE').first_or_create
        manifestation.update_attribute('catalog_id', catalog.id)

Severity: Major
Found in app/models/nacsis_cat.rb and 1 other location - About 1 hr to fix
app/models/nacsis_cat.rb on lines 286..295

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

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

    insertValue: function(input, value) {
        input = (input.jquery ? input : $(input));
        var field = input[0];
        var newValue = input.val();
        var range = [newValue.length, newValue.length];
Severity: Minor
Found in app/assets/javascripts/jquery.keypad.js - About 1 hr to fix

    Function continuation_for_the_fucking_khtml_browser has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        Calendar.continuation_for_the_fucking_khtml_browser = function() {
            var w = self.element.offsetWidth;
            var h = self.element.offsetHeight;
            self.element.style.display = "none";
            var valign = opts.substr(0, 1);
    Severity: Minor
    Found in app/assets/javascripts/jquery.simplecalendarjp.js - About 1 hr to fix

      Function showMonthsCombo has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Calendar.showMonthsCombo = function () {
          var cal = Calendar._C;
          if (!cal) {
              return false;
          }
      Severity: Minor
      Found in app/assets/javascripts/jquery.simplecalendarjp.js - About 1 hr to fix

        Method perform has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def perform
              user_file = UserFile.new(user)
        
              # get data
              query = Marshal.load(dumped_query)
        Severity: Minor
        Found in app/models/item.rb - About 1 hr to fix

          Function _getIERange has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _getIERange: function(field) {
                  field.focus();
                  var selectionRange = document.selection.createRange().duplicate();
                  // Use two ranges: before and selection
                  var beforeRange = this._getIETextRange(field);
          Severity: Minor
          Found in app/assets/javascripts/jquery.keypad.js - About 1 hr to fix

            Method utl_group has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def utl_group # book only
                    results = []
                    title_type = TitleType.find_by_name('UTL')
                    utl_titles = @manifestation.manifestation_titles.where('work_has_titles.title_type_id' => title_type.id)
                    utl_titles.each do |title|
            Severity: Minor
            Found in app/models/nacsis_cat.rb - About 1 hr to fix

              Method make_export_new_item_list_pdf has 27 lines of code (exceeds 25 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 1 hr to fix

                Method perform has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def perform
                      fn = "#{file_name}.#{file_type}"
                      user_file = UserFile.new(user)
                      url = nil
                      logger.error "SQL start at #{Time.now}"
                Severity: Minor
                Found in app/models/item.rb - About 1 hr to fix

                  Method create_pdf_sheet_custom has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def create_pdf_sheet_custom(custom_barcodes)
                        dir_base = "#{Rails.root}/private/system/barcode_list/#{self.id}/original/"
                        FileUtils.mkdir_p(dir_base) unless FileTest.exist?(dir_base)
                        #filename = "barcode#{Time.now.strftime('%s')}.pdf"
                        filename = "barcode.pdf"
                  Severity: Minor
                  Found in app/models/barcode_list.rb - About 1 hr to fix

                    Method set_query has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def self.set_query(query = nil, birth = nil, add = nil)
                        date_of_birth = nil
                        # query
                        query = query.to_s
                        query = query.gsub("-", "") if query
                    Severity: Minor
                    Found in app/models/user.rb - About 1 hr to fix

                      Method render_mode has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def render_mode(mode)
                          case mode
                          when 'barcode'
                            barcode = Barby::QrCode.new(@manifestation.id)
                            send_data(barcode.to_svg, :disposition => 'inline', :type => 'image/svg+xml')
                      Severity: Minor
                      Found in app/controllers/manifestations_controller.rb - About 1 hr to fix

                        Method show has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def show
                            @user = current_user
                        
                            if params[:filename]
                              find_and_send_user_file
                        Severity: Minor
                        Found in app/controllers/my_accounts_controller.rb - About 1 hr to fix

                          Method process_article_data has 27 lines of code (exceeds 25 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 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language