MiraitSystems/enju_trunk

View on GitHub

Showing 1,155 of 1,155 total issues

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

        if (cd.navtype < 0)
            s.left = cd.offsetLeft + "px";
        else {
            var ycw = yc.offsetWidth;
            if (typeof ycw == "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 335..343

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

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

        switch (valign) {
            case "T": p.y -= h; break;
            case "B": p.y += el.offsetHeight; break;
            case "C": p.y += (el.offsetHeight - h) / 2; break;
            case "t": p.y += el.offsetHeight - h; break;
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 1506..1512

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

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

        switch (halign) {
            case "L": p.x -= w; break;
            case "R": p.x += el.offsetWidth; break;
            case "C": p.x += (el.offsetWidth - w) / 2; break;
            case "l": p.x += el.offsetWidth - w; break;
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 1498..1504

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

Function tableMouseOver has 75 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Calendar.tableMouseOver = function (ev) {
    var cal = Calendar._C;
    if (!cal) {
        return;
    }
Severity: Major
Found in app/assets/javascripts/jquery.simplecalendarjp.js - About 3 hrs to fix

    Method search_family has 75 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def search_family
        return nil unless request.xhr?
        unless params[:keys].blank?
          tel_1 = params[:keys][:tel_1]
          tel_1.delete!("-")
    Severity: Major
    Found in app/controllers/users_controller.rb - About 3 hrs to fix

      Method set_manifestations_data has 74 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.set_manifestations_data(column, manifestation_ids)
          logger.debug "begin export manifestations"
          transaction do
            where(:id => manifestation_ids).
                includes(
      Severity: Major
      Found in app/models/manifestation.rb - About 2 hrs to fix

        Function Keypad has 74 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function Keypad() {
            this._curInst = null; // The current instance in use
            this._disabledFields = []; // List of keypad fields that have been disabled
            this._keypadShowing = false; // True if the popup panel is showing , false if not
            this._keyCode = 0;
        Severity: Major
        Found in app/assets/javascripts/jquery.keypad.js - About 2 hrs to fix

          Method make_query_filter has 74 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def make_query_filter(options)
              with = []
              without = []
          
              #
          Severity: Major
          Found in app/controllers/manifestations_controller.rb - About 2 hrs to fix

            Method identify_manifestation has 73 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def identify_manifestation(datas, sheet)
                  Rails.logger.debug "identify_manifestation"
            
                  scope = Manifestation.scoped
                  scope = scope.readonly(false)
            Severity: Major
            Found in lib/enju_trunk/resourceadapter/import_book.rb - About 2 hrs to fix

              Method fetch has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                def fetch(row, options = {:edit_mode => 'create'})
                  shelf = Shelf.where(:name => row['shelf'].to_s.strip).first || Shelf.web
                  case options[:edit_mode]
                  when 'create'
                    manifestation = nil
              Severity: Minor
              Found in app/models/resource_import_file.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_column has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.set_column(selected_column, manifestation_ids)
                  col_spec = OUTPUT_COLUMN_FIELDS.inject({}) do |spec, name|
                    spec[name] = select_output_column_spec(name)
                    spec
                  end
              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

              Method create_pdf_sheet has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                def create_pdf_sheet(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#{Time.now.strftime('%s')}.pdf"
                    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

              Method set_user_value has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                def set_user_value(user, row)
                  #日本語化
                  username = I18n.t('activerecord.attributes.user.username')
                  user_number = I18n.t('activerecord.attributes.user.user_number')
                  library = I18n.t('activerecord.attributes.user.library')
              Severity: Minor
              Found in app/models/agent_import_file.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_sheet_custom has a Cognitive Complexity of 21 (exceeds 5 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 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 exec_print has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                def exec_print
                  @barcode_list = BarcodeList.find(params[:id])
              
                  respond_to do |format|
                    if @barcode_list.usage_type == "user"
              Severity: Minor
              Found in app/controllers/barcode_lists_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 field_index_set has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                  def field_index_set(field_keys)
                    names = {}
                    field_keys.each do |fk|
                      next unless @column_spec[fk] == :plural
                      name = field_name(fk)
              Severity: Minor
              Found in lib/enju_trunk/resourceadapter/resource_import.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 edit has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                def edit
                  @series_statement.work = @work if @work
                  @creators = @series_statement.root_manifestation.try(:creates).present? ? @series_statement.root_manifestation.creates.order(:position) : [{}] unless @creators
                  @contributors = @series_statement.root_manifestation.try(:realizes).present? ? @series_statement.root_manifestation.realizes.order(:position) : [{}] unless @contributors
                  @publishers = @series_statement.root_manifestation.try(:produces).present? ? @series_statement.root_manifestation.produces.order(:position) : [{}] unless @publishers
              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

              Function showAtElement has 70 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Calendar.prototype.showAtElement = function (el, opts) {
                  var self = this;
                  var p = Calendar.getAbsolutePos(el);
                  if (!opts || typeof opts != "string") {
                      this.showAt(p.x, p.y + el.offsetHeight);
              Severity: Major
              Found in app/assets/javascripts/jquery.simplecalendarjp.js - About 2 hrs to fix

                Method output_excelx has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.output_excelx(output_data, filename = nil)
                    require 'axlsx'
                
                    # initialize
                    if filename.present?
                Severity: Major
                Found in app/models/checkout_statistics.rb - About 2 hrs to fix

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

                    def self.make_export_removed_list_pdf(items)
                      return false if items.blank?
                      report = EnjuTrunk.new_book_term('removed_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

                  Severity
                  Category
                  Status
                  Source
                  Language