next-l/enju_leaf

View on GitHub

Showing 345 of 709 total issues

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

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

            Method make_query has 82 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def make_query(query, options = {})
                # TODO: integerやstringもqfに含める
                query = query.to_s.strip
            
                if query.size == 1
            Severity: Major
            Found in app/controllers/manifestations_controller.rb - About 3 hrs to fix

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

                def set_agent_value(agent, row)
                  agent.first_name = row['first_name'] if row['first_name']
                  agent.middle_name = row['middle_name'] if row['middle_name']
                  agent.last_name = row['last_name'] if row['last_name']
                  agent.first_name_transcription = row['first_name_transcription'] if row['first_name_transcription']
              Severity: Minor
              Found in app/models/agent_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 23 (exceeds 5 allowed). Consider refactoring.
              Open

                def destroy?
                  return false unless user
                  return false unless user.try(:has_role?, 'Librarian')
              
                  if record.user
              Severity: Minor
              Found in app/policies/profile_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

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

                def import
                  transition_to!(:started)
                  num = { user_imported: 0, user_found: 0, failed: 0, error: 0 }
                  rows = open_import_file(create_import_temp_file(attachment))
                  row_num = 1
              Severity: Major
              Found in app/models/user_import_file.rb - About 3 hrs to fix

                Function exports has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                module.exports = function(api) {
                  var validEnv = ['development', 'test', 'production']
                  var currentEnv = api.env()
                  var isDevelopmentEnv = api.env('development')
                  var isProductionEnv = api.env('production')
                Severity: Major
                Found in babel.config.js - About 3 hrs to fix

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

                    def set_profile_params(row)
                      params = {}
                      user_group = UserGroup.find_by(name: row['user_group']) || default_user_group
                      params[:user_group_id] = user_group.id if user_group
                  
                  
                  Severity: Minor
                  Found in app/models/user_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 modify has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def modify
                      transition_to!(:started)
                      num = { user_updated: 0, user_not_found: 0, failed: 0 }
                      rows = open_import_file(create_import_temp_file(attachment))
                      row_num = 1
                  Severity: Minor
                  Found in app/models/user_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 parse_pub_date has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def parse_pub_date(options)
                      pub_date = {}
                      if options[:pub_date_from].blank?
                        pub_date[:from] = "*"
                      else
                  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

                  Severity
                  Category
                  Status
                  Source
                  Language