algolia/algoliasearch-jekyll

View on GitHub

Showing 7 of 7 total issues

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

      def site.write
        items = []
        is_verbose = config['verbose']
        each_site_file do |file|
          next unless AlgoliaSearchJekyllPush.indexable?(file)
Severity: Minor
Found in lib/push.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 configure_index has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def configure_index(index)
      settings = {
        distinct: true,
        attributeForDistinct: 'url',
        attributesForFaceting: %w(tags type title),
Severity: Minor
Found in lib/push.rb - About 1 hr to fix

    Method node_heading_parent has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def node_heading_parent(node, level = 'h7')
        # If initially called on a heading, we only accept stronger headings
        level = node.name if level == 'h7' && node_heading?(node)
    
        previous = node.previous_element
    Severity: Minor
    Found in lib/record_extractor.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 error_tester has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def error_tester
        # Ex: Cannot PUT to https://appid.algolia.net/1/indexes/index_name/settings:
        # {"message":"Invalid Application-ID or API key","status":403} (403)
        VerEx.new do
          find 'Cannot '
    Severity: Minor
    Found in lib/error_handler.rb - About 1 hr to fix

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

          def excluded_file?(file)
            excluded = [
              %r{^page([0-9]*)/index\.html}
            ]
            if @config['algolia']
      Severity: Minor
      Found in lib/push.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

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

          def indexable?(file)
            return false if file.is_a?(Jekyll::StaticFile)
      
            basename = File.basename(file.path)
            extname = File.extname(basename)[1..-1]
      Severity: Minor
      Found in lib/push.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

      Method extract has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def extract
          items = []
          html_nodes.each_with_index do |node, index|
            next if node.text.empty?
      
      
      Severity: Minor
      Found in lib/record_extractor.rb - About 25 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