MiraitSystems/enju_trunk

View on GitHub

Showing 1,155 of 1,155 total issues

Method make_export_series_statements_latest_list_pdf has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

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

    report.events.on :page_create do |e|
Severity: Minor
Found in app/models/item.rb - About 3 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 has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    @user = current_user

    respond_to do |format|
=begin
Severity: Minor
Found in app/controllers/my_accounts_controller.rb - About 3 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 23 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    @count = {}

    # set screen option
    @departments = Department.all
Severity: Minor
Found in app/controllers/users_controller.rb - About 3 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 has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    unless @user == current_user or current_user.has_role?('Librarian')
      access_denied; return
    end
    unless @user.agent
Severity: Minor
Found in app/controllers/users_controller.rb - About 3 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

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

        if (nodeName == 'input' || nodeName == 'textarea') {
            target.disabled = false;
            control.siblings('button.' + this._triggerClass).
                each(function() { this.disabled = false; }).end().
                siblings('img.' + this._triggerClass).
Severity: Major
Found in app/assets/javascripts/jquery.keypad.js and 1 other location - About 3 hrs to fix
app/assets/javascripts/jquery.keypad.js on lines 277..300

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

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 (nodeName == 'input' || nodeName == 'textarea') {
        target.disabled = true;
            control.siblings('button.' + this._triggerClass).
            each(function() { this.disabled = true; }).end().
            siblings('img.' + this._triggerClass).
Severity: Major
Found in app/assets/javascripts/jquery.keypad.js and 1 other location - About 3 hrs to fix
app/assets/javascripts/jquery.keypad.js on lines 253..264

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

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

    this.showMenu = function(){
        killAllMenus();
        if (!menu.menuExists) { menu.create() };
        caller
            .addClass('fg-menu-open')
Severity: Major
Found in app/assets/javascripts/fg.menu.js - About 3 hrs to fix

    Method get_list_size has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def get_list_size
        return nil unless request.xhr?
        # budgets
        budgets = params[:budgets] || []
        all_budgets = eval(params[:all_budgets]) if params[:all_budgets]
    Severity: Major
    Found in app/controllers/expenses_controller.rb - About 3 hrs to fix

      Class Agent has 27 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Agent < ActiveRecord::Base
        attr_accessible :last_name, :middle_name, :first_name,
          :last_name_transcription, :middle_name_transcription,
          :first_name_transcription, :corporate_name, :corporate_name_transcription,
          :full_name, :full_name_transcription, :full_name_alternative, :zip_code_1,
      Severity: Minor
      Found in app/models/agent.rb - About 3 hrs to fix

        Method enju_hiduke2yyyymmdd_sub has 79 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.enju_hiduke2yyyymmdd_sub(datestr)
            yyyymmdd_from = nil 
            yyyymmdd_to = nil 
            dfrom = nil 
            dto = nil
        Severity: Major
        Found in lib/enju_trunk/date_helper.rb - About 3 hrs to fix

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

            def show
              @location_symbol_size = Keycode.where(:name => 'item.location_symbol')
          
              if params[:isbn].present?
                if @manifestation_redirect = Manifestation.find_by_isbn(params[:isbn])
          Severity: Major
          Found in app/controllers/manifestations_controller.rb - About 3 hrs to fix

            File agents_controller.rb has 296 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class AgentsController < ApplicationController
              add_breadcrumb "I18n.t('page.listing', :model => I18n.t('activerecord.models.agent'))", 'agents_path'
              add_breadcrumb "I18n.t('activerecord.models.agent')", 'agent_path(params[:id])', :only => [:show]
              add_breadcrumb "I18n.t('page.new', :model => I18n.t('activerecord.models.agent'))", 'new_agent_path', :only => [:new, :create]
              add_breadcrumb "I18n.t('page.editing', :model => I18n.t('activerecord.models.agent'))", 'edit_agent_path(params[:id])', :only => [:edit, :update]
            Severity: Minor
            Found in app/controllers/agents_controller.rb - About 3 hrs to fix

              Method create_pdf has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                def create_pdf
                  @barcode_list = BarcodeList.find(params[:barcode_list_id])
                  start_number = params[:barcode_list][:start_number]
                  end_number = params[:barcode_list][:end_number]
              
              
              Severity: Minor
              Found in app/controllers/barcode_lists_controller.rb - About 3 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_pdf has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.output_userlist_pdf(users)
                  report = EnjuTrunk.new_report('userlist.tlf')
              
                  # set page_num
                  report.events.on :page_create do |e|
              Severity: Minor
              Found in app/models/user.rb - About 3 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 get_approval_report has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                def get_approval_report
                  begin
                    @approval = Approval.find(params[:param])
                    case params[:output]
                    when 'report'
              Severity: Minor
              Found in app/controllers/approvals_controller.rb - About 3 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_shelf has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  def set_shelf(input_shelf, user, library, options = {:mode => 'input'})
                    if input_shelf.nil?
                      if options[:mode] == 'input'
                        if library.nil?
                          shelf = user.library.in_process_shelf
              Severity: Minor
              Found in lib/enju_trunk/resourceadapter/import_book.rb - About 3 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

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

                        while address.length > max_column
                          address.length.times { |i|
                            cnt += 0.5 if address[i] =~ /^[\s0-9A-Za-z]+$/
                            cnt += 1 unless address[i] =~ /^[\s0-9A-Za-z]+$/
                            if cnt.to_f >= max_column or address[i+1].nil? or address[i] =~ /^[\n]+$/
              Severity: Major
              Found in app/models/reminder_list.rb and 1 other location - About 3 hrs to fix
              app/models/reminder_list.rb on lines 216..229

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

              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

                      while name.length > max_column
                        name.length.times { |i|
                          cnt += 0.5 if name[i] =~ /^[\s0-9A-Za-z]+$/
                          cnt += 1 unless name[i] =~ /^[\s0-9A-Za-z]+$/
                          if cnt.to_f >= max_column or name[i+1].nil? or name[i] =~ /^[\n]+$/
              Severity: Major
              Found in app/models/reminder_list.rb and 1 other location - About 3 hrs to fix
              app/models/reminder_list.rb on lines 191..204

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

              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

              Method hiduke2yyyymmdd_sub has 77 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.hiduke2yyyymmdd_sub(datestr)
                  yyyymmdd_from = nil 
                  yyyymmdd_to = nil 
                  dfrom = nil 
                  dto = nil
              Severity: Major
              Found in app/models/wareki.rb - About 3 hrs to fix

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

                    if (cd.navtype < 0)
                        s.left = cd.offsetLeft + "px";
                    else {
                        var mcw = mc.offsetWidth;
                        if (typeof mcw == "undefined")
                Severity: Major
                Found in app/assets/javascripts/jquery.simplecalendarjp.js and 1 other location - About 3 hrs to fix
                app/assets/javascripts/jquery.simplecalendarjp.js on lines 380..388

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

                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