datacite/lupo

View on GitHub
app/models/doi/graphql_query.rb

Summary

Maintainability
F
3 days
Test Coverage

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

    File graphql_query.rb has 379 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Doi::GraphqlQuery
      class Builder
        include Modelable
    
        DEFAULT_CURSOR = [0, ""]
    Severity: Minor
    Found in app/models/doi/graphql_query.rb - About 5 hrs to fix

      Method get_should_clause has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def get_should_clause
            options = @options
            should_query = []
            minimum_should_match = 0
            if options[:provider_id].present?
      Severity: Major
      Found in app/models/doi/graphql_query.rb - About 2 hrs to fix

        Method filters has 55 lines of code (exceeds 25 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: Major
        Found in app/models/doi/graphql_query.rb - About 2 hrs to fix

          Method get_should_clause has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_should_clause
                options = @options
                should_query = []
                minimum_should_match = 0
                if options[:provider_id].present?
          Severity: Minor
          Found in app/models/doi/graphql_query.rb - About 1 hr 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 3 locations. Consider refactoring.
          Open

                filter << { range: { created: { gte: "#{options[:created].split(',').min}||/y", lte: "#{options[:created].split(',').max}||/y", format: "yyyy" } } } if options[:created].present?
          Severity: Minor
          Found in app/models/doi/graphql_query.rb and 2 other locations - About 35 mins to fix
          app/models/doi/graphql_query.rb on lines 134..134
          app/models/doi/graphql_query.rb on lines 170..170

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

          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 3 locations. Consider refactoring.
          Open

                filter << { range: { publication_year: { gte: "#{options[:published].split(',').min}||/y", lte: "#{options[:published].split(',').max}||/y", format: "yyyy" } } } if options[:published].present?
          Severity: Minor
          Found in app/models/doi/graphql_query.rb and 2 other locations - About 35 mins to fix
          app/models/doi/graphql_query.rb on lines 133..133
          app/models/doi/graphql_query.rb on lines 170..170

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

          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 3 locations. Consider refactoring.
          Open

                filter << { range: { registered: { gte: "#{options[:registered].split(',').min}||/y", lte: "#{options[:registered].split(',').max}||/y", format: "yyyy" } } } if options[:registered].present?
          Severity: Minor
          Found in app/models/doi/graphql_query.rb and 2 other locations - About 35 mins to fix
          app/models/doi/graphql_query.rb on lines 133..133
          app/models/doi/graphql_query.rb on lines 134..134

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

          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 options[:provider_id].present?
                  options[:provider_id].split(",").each { |id|
                    should_query << { term: { "provider_id": { value: id, case_insensitive: true } } }
                  }
                  minimum_should_match = 1
          Severity: Minor
          Found in app/models/doi/graphql_query.rb and 1 other location - About 20 mins to fix
          app/models/doi/graphql_query.rb on lines 192..196

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

          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 options[:client_id].present?
                  options[:client_id].split(",").each { |id|
                    should_query << { term: { "client_id": { value: id, case_insensitive: true } } }
                  }
                  minimum_should_match = 1
          Severity: Minor
          Found in app/models/doi/graphql_query.rb and 1 other location - About 20 mins to fix
          app/models/doi/graphql_query.rb on lines 186..190

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

          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

          There are no issues that match your filters.

          Category
          Status