datacite/lupo

View on GitHub

Showing 575 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

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

                              indexes :provider,
                                      type: :object,
                                      properties: {
                                        id: { type: :keyword },
                                        uid: { type: :keyword },
                        Severity: Major
                        Found in app/models/client.rb and 1 other location - About 1 day to fix
                        app/models/contact.rb on lines 76..219

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

                        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

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

                              indexes :provider,
                                      type: :object,
                                      properties: {
                                        id: { type: :keyword },
                                        uid: { type: :keyword },
                        Severity: Major
                        Found in app/models/contact.rb and 1 other location - About 1 day to fix
                        app/models/client.rb on lines 216..359

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

                        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

                        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
                              Severity
                              Category
                              Status
                              Source
                              Language