next-l/enju_leaf

View on GitHub

Showing 709 of 709 total issues

Method to_hash has 106 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def to_hash(role: 'Guest')
    record = {
      manifestation_id: id,
      original_title: original_title,
      title_alternative: title_alternative,
Severity: Major
Found in app/models/manifestation.rb - About 4 hrs to fix

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

            if (this.scrollTopVel < 0) { // scrolling up?
                if (el.scrollTop() <= 0) { // already scrolled all the way up?
                    this.scrollTopVel = 0;
                }
            }
    Severity: Major
    Found in app/assets/javascripts/enju_event/fullcalendar.js and 1 other location - About 4 hrs to fix
    app/assets/javascripts/enju_event/fullcalendar.js on lines 2922..2931

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

    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 (this.scrollLeftVel < 0) { // scrolling left?
                if (el.scrollLeft() <= 0) { // already scrolled all the left?
                    this.scrollLeftVel = 0;
                }
            }
    Severity: Major
    Found in app/assets/javascripts/enju_event/fullcalendar.js and 1 other location - About 4 hrs to fix
    app/assets/javascripts/enju_event/fullcalendar.js on lines 2911..2920

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

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

          def import_record_from_cinii_books(doc)
            # http://ci.nii.ac.jp/info/ja/api/api_outline.html#cib_od
            # return nil
    
            ncid = doc.at('//cinii:ncid').try(:content)
    Severity: Minor
    Found in app/models/concerns/enju_nii/enju_manifestation.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 modify has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

      def modify
        transition_to!(:started)
        rows = open_import_file(create_import_temp_file(attachment))
        check_field(rows.first)
        row_num = 1
    Severity: Minor
    Found in app/models/event_import_file.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 make_query has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

      def make_query(query, options = {})
        # TODO: integerやstringもqfに含める
        query = query.to_s.strip
    
        if query.size == 1
    Severity: Minor
    Found in app/controllers/manifestations_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 27 (exceeds 5 allowed). Consider refactoring.
    Open

      def index
        if params[:mode] == 'add'
          unless current_user.try(:has_role?, 'Librarian')
            access_denied
            return
    Severity: Minor
    Found in app/controllers/agents_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 27 (exceeds 5 allowed). Consider refactoring.
    Open

      def index
        unless current_user.has_role?('Librarian')
          if @user
            if current_user == @user
              redirect_to reserves_url(format: params[:format])
    Severity: Minor
    Found in app/controllers/reserves_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

        groupSegsByCol: function(segs) {
            var segsByCol = [];
            var i;
    
            for (i = 0; i < this.colCnt; i++) {
    Severity: Major
    Found in app/assets/javascripts/enju_event/fullcalendar.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/enju_event/fullcalendar.js on lines 6295..6308

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

    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

        groupSegRows: function(segs) {
            var segRows = [];
            var i;
    
            for (i = 0; i < this.rowCnt; i++) {
    Severity: Major
    Found in app/assets/javascripts/enju_event/fullcalendar.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/enju_event/fullcalendar.js on lines 7404..7417

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

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

          def self.import_record_from_loc(doc)
            record_identifier = doc.at('//mods:recordInfo/mods:recordIdentifier', NS).try(:content)
            identifier_type = IdentifierType.find_by(name: 'loc_identifier')
            identifier_type ||= IdentifierType.create!(name: 'loc_identifier')
            loc_identifier = Identifier.find_by(body: record_identifier, identifier_type_id: identifier_type.id)
    Severity: Major
    Found in app/models/concerns/enju_loc/enju_manifestation.rb - About 3 hrs to fix

      Method set_date_of_publication has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

        def set_date_of_publication
          return if pub_date.blank?
      
          year = Time.utc(pub_date.rjust(4, "0").to_i).year rescue nil
          begin
      Severity: Minor
      Found in app/models/manifestation.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 import has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

        def import
          transition_to!(:started)
          num = { imported: 0, failed: 0 }
          rows = open_import_file(create_import_temp_file(attachment))
          check_field(rows.first)
      Severity: Minor
      Found in app/models/event_import_file.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

      Function _fetchEventSource has 91 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function _fetchEventSource(source, callback) {
              var i;
              var fetchers = FC.sourceFetchers;
              var res;
      
      
      Severity: Major
      Found in app/assets/javascripts/enju_event/fullcalendar.js - About 3 hrs to fix

        Method modify has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

          def modify
            transition_to!(:started)
            rows = open_import_file(create_import_temp_file(attachment))
            rows.shift
            row_num = 1
        Severity: Minor
        Found in app/models/resource_import_file.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 destroy? has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

          def destroy?
            if record.items.empty?
              unless record.try(:is_reserved?)
                if record.series_master?
                  if record.children.empty?
        Severity: Minor
        Found in app/policies/manifestation_policy.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

        Function buildSegDragListener has 87 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            buildSegDragListener: function(seg) {
                var _this = this;
                var view = this.view;
                var calendar = view.calendar;
                var el = seg.el;
        Severity: Major
        Found in app/assets/javascripts/enju_event/fullcalendar.js - About 3 hrs to fix

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

            def index
              unless current_user.has_role?('Librarian')
                if @user
                  if current_user == @user
                    redirect_to reserves_url(format: params[:format])
          Severity: Major
          Found in app/controllers/reserves_controller.rb - About 3 hrs to fix

            Method update_item has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

              def update_item(item, row)
                shelf = Shelf.find_by(name: row['shelf'].to_s.strip)
                bookstore = Bookstore.find_by(name: row['bookstore'])
                required_role = Role.find_by(name: row['item_required_role'])
            
            
            Severity: Minor
            Found in app/models/resource_import_file.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 85 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def index
                if params[:icalendar_token].present?
                  icalendar_user = Profile.where(checkout_icalendar_token: params[:icalendar_token]).first.try(:user)
                  if icalendar_user.blank?
                    raise ActiveRecord::RecordNotFound
            Severity: Major
            Found in app/controllers/checkouts_controller.rb - About 3 hrs to fix
              Severity
              Category
              Status
              Source
              Language