datacite/lupo

View on GitHub

Showing 576 of 597 total issues

File facetable.rb has 493 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Facetable
  extend ActiveSupport::Concern

  SOURCES = {
    "datacite-usage" => "DataCite Usage Stats",
Severity: Minor
Found in app/controllers/concerns/facetable.rb - About 7 hrs to fix

    Method convert_affiliation_by_id has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.convert_affiliation_by_id(options = {})
        return nil if options[:id].blank?
    
        id = options[:id].to_i
        count = 0
    Severity: Minor
    Found in app/models/doi.rb - About 7 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 184 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def index
        sort =
          case params[:sort]
          when "relevance"
            { "_score" => { order: "desc" } }
    Severity: Major
    Found in app/controllers/old_events_controller.rb - About 7 hrs to fix

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

        def index
          sort =
            case params[:sort]
            when "relevance"
              { "_score" => { order: "desc" } }
      Severity: Major
      Found in app/controllers/events_controller.rb - About 7 hrs to fix

        Method index has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
        Open

          def index
            sort =
              case params[:sort]
              when "relevance"
                { "_score" => { order: "desc" } }
        Severity: Minor
        Found in app/controllers/events_controller.rb - About 7 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 179 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def index
            sort =
              case params[:sort]
              when "relevance"
                { "_score" => { order: "desc" } }
        Severity: Major
        Found in app/controllers/organizations_controller.rb - About 7 hrs to fix

          File contact.rb has 456 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          class Contact < ApplicationRecord
            strip_attributes
          
            # include helper module for Elasticsearch
            include Indexable
          Severity: Minor
          Found in app/models/contact.rb - About 6 hrs to fix

            Method initialize has 169 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def initialize(user)
                alias_action :create, :read, :update, :destroy, to: :crud
            
                user ||= User.new(nil) # Guest user
                # @user = user
            Severity: Major
            Found in app/models/ability.rb - About 6 hrs to fix

              File providers_controller.rb has 445 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              class ProvidersController < ApplicationController
                include ActionController::MimeResponds
                include Countable
              
                prepend_before_action :authenticate_user!
              Severity: Minor
              Found in app/controllers/providers_controller.rb - About 6 hrs to fix

                Class Event has 48 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class Event < ApplicationRecord
                  # include helper module for query caching
                  include Cacheable
                
                  # include event processing
                Severity: Minor
                Found in app/models/event.rb - About 6 hrs to fix

                  Method repositories has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def repositories
                      # authorize! :export, :repositories
                  
                      # Loop through all clients
                      page = { size: 1_000, number: 1 }
                  Severity: Minor
                  Found in app/controllers/exports_controller.rb - About 6 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 filters has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def filters
                        options = @options
                  
                        # turn ids into an array if provided as comma-separated string
                        options[:ids] = options[:ids].split(",") if options[:ids].is_a?(String)
                  Severity: Minor
                  Found in app/models/doi/graphql_query.rb - About 6 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_from_providers has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def self.import_from_providers
                      Provider.all.find_each do |provider|
                        if provider.voting_contact_email
                          contact = Contact.where(email: provider.voting_contact_email).first_or_create
                          if contact.update(
                  Severity: Minor
                  Found in app/models/contact.rb - About 6 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

                  File params_sanitizer.rb has 432 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  class ParamsSanitizer
                    include Crosscitable
                    include Helpable
                  
                    DEFAULTS_MAP =
                  Severity: Minor
                  Found in app/lib/params_sanitizer.rb - About 6 hrs to fix

                    Class Client has 46 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class Client < ApplicationRecord
                      SUBJECTS_JSON_SCHEMA = Rails.root.join("app", "models", "schemas", "client", "subjects.json")
                      audited except: %i[
                        system_email
                        service_contact
                    Severity: Minor
                    Found in app/models/client.rb - About 6 hrs to fix

                      Method initialize has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def initialize(user)
                          alias_action :create, :read, :update, :destroy, to: :crud
                      
                          user ||= User.new(nil) # Guest user
                          # @user = user
                      Severity: Minor
                      Found in app/models/ability.rb - About 6 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 150 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def index
                          sort =
                            case params[:sort]
                            when "relevance"
                              { "_score" => { order: "desc" } }
                      Severity: Major
                      Found in app/controllers/repositories_controller.rb - About 6 hrs to fix

                        Method aggregations has 143 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def aggregations
                              facet_count = (@options[:facet_count] || DEFAULT_FACET_COUNT).to_i
                              if facet_count.positive?
                                {
                                  resource_types: { terms: { field: "resource_type_id_and_name", size: facet_count, min_doc_count: 1, missing: "__missing__" } },
                        Severity: Major
                        Found in app/models/doi/graphql_query.rb - About 5 hrs to fix

                          Method repositories has 143 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def repositories
                              # authorize! :export, :repositories
                          
                              # Loop through all clients
                              page = { size: 1_000, number: 1 }
                          Severity: Major
                          Found in app/controllers/exports_controller.rb - About 5 hrs to fix

                            Method convert_affiliation_by_id has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def self.convert_affiliation_by_id(options = {})
                                return nil if options[:id].blank?
                            
                                id = options[:id].to_i
                                count = 0
                            Severity: Minor
                            Found in app/models/activity.rb - About 5 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