datacite/lupo

View on GitHub

Showing 314 of 596 total issues

File doi.rb has 2078 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "maremma"
require "benchmark"

class Doi < ApplicationRecord
  self.ignored_columns += [:publisher]
Severity: Major
Found in app/models/doi.rb - About 5 days to fix

    Method query has a Cognitive Complexity of 194 (exceeds 5 allowed). Consider refactoring.
    Open

        def query(query, options = {})
          # support scroll api
          # map function is small performance hit
          if options[:scroll_id].present? && options.dig(:page, :scroll)
            begin
    Severity: Minor
    Found in app/models/concerns/indexable.rb - About 3 days 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 query_type.rb has 1225 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class QueryType < BaseObject
      extend_type
    
      field :members, MemberConnectionWithTotalType, null: false do
        argument :query, String, required: false
    Severity: Major
    Found in app/graphql/types/query_type.rb - About 3 days to fix

      Class Doi has 156 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Doi < ApplicationRecord
        self.ignored_columns += [:publisher]
        PUBLISHER_JSON_SCHEMA = Rails.root.join("app", "models", "schemas", "doi", "publisher.json")
        audited only: %i[doi url creators contributors titles publisher_obj publication_year types descriptions container sizes formats version_info language dates identifiers related_identifiers related_items funding_references geo_locations rights_list subjects schema_version content_url landing_page aasm_state source reason]
      
      
      Severity: Major
      Found in app/models/doi.rb - About 3 days to fix

        Method query has 548 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def query(query, options = {})
              # support scroll api
              # map function is small performance hit
              if options[:scroll_id].present? && options.dig(:page, :scroll)
                begin
        Severity: Major
        Found in app/models/concerns/indexable.rb - About 2 days to fix

          File indexable.rb has 966 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module Indexable
            extend ActiveSupport::Concern
          
            require "aws-sdk-sqs"
          
          
          Severity: Major
          Found in app/models/concerns/indexable.rb - About 2 days to fix

            File client.rb has 882 lines of code (exceeds 250 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: Major
            Found in app/models/client.rb - About 2 days to fix

              File event.rb has 878 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

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

                File doi_item.rb has 861 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                module DoiItem
                  include BaseInterface
                  include Bolognese::MetadataUtils
                
                  REGISTRATION_AGENCIES = {
                Severity: Major
                Found in app/graphql/types/doi_item.rb - About 2 days to fix

                  File provider.rb has 812 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require "countries"
                  
                  class Provider < ApplicationRecord
                    audited except: %i[
                      globus_uuid
                  Severity: Major
                  Found in app/models/provider.rb - About 1 day to fix

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

                      def index
                        sort =
                          case params[:sort]
                          when "name"
                            { "doi" => { order: "asc" } }
                    Severity: Major
                    Found in app/controllers/datacite_dois_controller.rb - About 1 day to fix

                      Method query has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def self.query(query, options = {})
                          # support scroll api
                          # map function is small performance hit
                          if options[:scroll_id].present? && options.dig(:page, :scroll)
                            begin
                      Severity: Minor
                      Found in app/models/doi.rb - About 1 day 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 datacite_dois_controller.rb has 708 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      require "uri"
                      require "base64"
                      require "pp"
                      
                      class DataciteDoisController < ApplicationController
                      Severity: Major
                      Found in app/controllers/datacite_dois_controller.rb - About 1 day to fix

                        Class QueryType has 71 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        class QueryType < BaseObject
                          extend_type
                        
                          field :members, MemberConnectionWithTotalType, null: false do
                            argument :query, String, required: false
                        Severity: Major
                        Found in app/graphql/types/query_type.rb - About 1 day to fix

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

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

                            def self.query(query, options = {})
                              # support scroll api
                              # map function is small performance hit
                              if options[:scroll_id].present? && options.dig(:page, :scroll)
                                begin
                          Severity: Major
                          Found in app/models/doi.rb - About 1 day to fix

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

                              def index
                                sort =
                                  case params[:sort]
                                  when "name"
                                    { "doi" => { order: "asc" } }
                            Severity: Minor
                            Found in app/controllers/datacite_dois_controller.rb - About 1 day 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 197 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/providers_controller.rb - About 7 hrs to fix

                              File facetable.rb has 492 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

                                Severity
                                Category
                                Status
                                Source
                                Language