Showing 11 of 217 total issues

File document_search_spec.rb has 942 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rails_helper'

describe DocumentSearch do
  let(:query) { 'common' }
  let(:handles) { %w[agency_blogs] }
Severity: Major
Found in spec/classes/document_search_spec.rb - About 2 days to fix

    Method build_search_query has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring.
    Open

      def build_search_query
        doc_query = self
    
        search.query do
          function_score do
    Severity: Minor
    Found in app/classes/document_query.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 documents_spec.rb has 391 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'rails_helper'
    require 'uri'
    
    describe Api::V1::Documents do
      let(:id) { 'some really!weird@id.name' }
    Severity: Minor
    Found in spec/requests/api/v1/documents_spec.rb - About 5 hrs to fix

      File collections_spec.rb has 382 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'rails_helper'
      
      describe Api::V1::Collections do
        let(:valid_session) do
          env_secrets = Rails.application.config_for(:secrets)
      Severity: Minor
      Found in spec/requests/api/v1/collections_spec.rb - About 5 hrs to fix

        Class Documents has 33 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Documents
          include Templatable
          LIGHT_STEMMERS = {
            de: 'german',
            es: 'spanish',
        Severity: Minor
        Found in app/templates/documents.rb - About 4 hrs to fix

          Method build_search_query has 93 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def build_search_query
              doc_query = self
          
              search.query do
                function_score do
          Severity: Major
          Found in app/classes/document_query.rb - About 3 hrs to fix

            File document_query.rb has 319 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class DocumentQuery
              include Elasticsearch::DSL
            
              HIGHLIGHT_OPTIONS = {
                pre_tags: ["\ue000"],
            Severity: Minor
            Found in app/classes/document_query.rb - About 3 hrs to fix

              Class DocumentQuery has 21 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class DocumentQuery
                include Elasticsearch::DSL
              
                HIGHLIGHT_OPTIONS = {
                  pre_tags: ["\ue000"],
              Severity: Minor
              Found in app/classes/document_query.rb - About 2 hrs to fix

                Method extract_hits has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  def extract_hits(hits)
                    hits.map do |hit|
                      highlight = hit['highlight']
                      source =  deserialized(hit)
                      if highlight.present?
                Severity: Minor
                Found in app/classes/document_search_results.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

                Method linguistic_filter has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def linguistic_filter(json, locale, lines, name, field, type)
                Severity: Minor
                Found in lib/templatable.rb - About 45 mins to fix

                  Method search has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def search
                      i14y_search_results = execute_client_search
                      if i14y_search_results.total.zero? && i14y_search_results.suggestion.present?
                        suggestion = i14y_search_results.suggestion
                        doc_query.query = suggestion['text']
                  Severity: Minor
                  Found in app/classes/document_search.rb - About 35 mins 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