aadlani/nanoc-toolbox

View on GitHub

Showing 9 of 11 total issues

Method render_menu has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def render_menu(items, options={})
      options[:depth]            ||= 3
      options[:collection_tag]   ||= 'ol'
      options[:collection_class] ||= 'menu'
      options[:item_tag]         ||= 'li'
Severity: Minor
Found in lib/nanoc/toolbox/helpers/navigation.rb - About 2 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 run has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def run(content, arguments={})
      require 'nokogiri'

      # Parse
      doc = Nokogiri::HTML.fragment(content)
Severity: Minor
Found in lib/nanoc/toolbox/filters/add_sections.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 run has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run(content, arguments={})
      require 'nokogiri'

      # Parse
      doc = Nokogiri::HTML.fragment(content)
Severity: Minor
Found in lib/nanoc/toolbox/filters/add_sections.rb - About 1 hr to fix

    Method find_toc_sections has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_toc_sections(section, section_xpath, title_level=1)
          return {} unless section.xpath(section_xpath)
    
          # For each section found call the find_toc_sections on it with an
          # increased header level (ex: h1 => h2) and then generate the hash res
    Severity: Minor
    Found in lib/nanoc/toolbox/helpers/navigation.rb - About 55 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 clean_options has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def clean_options(options={})
            # remove unsupported options
            options.delete_if {|key, value| !AVAILABLE_OPTIONS.include?(key) }
    
            # remove empty options
    Severity: Minor
    Found in lib/nanoc/toolbox/helpers/gravatar.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 gist has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def gist(gist_id, filename=nil)
          raise ArgumentError, "Gist ID should be a hex number" unless (gist_id.to_s).match(/^\h+$/)
          url = "#{GIST_HOST}/#{gist_id}.#{GIST_EXT}"
    
          if filename
    Severity: Minor
    Found in lib/nanoc/toolbox/helpers/github_gist.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

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

        def find_item_tree(root, options={})
          return nil unless root.children
    
          # filter the elements to contain only the kind requested
          children = options[:kind] ? root.children.select { |item| item[:kind] == options[:kind] } : root.children
    Severity: Minor
    Found in lib/nanoc/toolbox/helpers/navigation.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

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

        def tag_links_for(item, omit_tags=[], options={})
          tags = []
          return tags unless item[:tags]
    
          options[:tag_pattern]     ||= "%%tag%%"
    Severity: Minor
    Found in lib/nanoc/toolbox/helpers/tagging_extra.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

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

        def find_breadcrumbs_trail(root)
          trail = ["/"]
          root.split('/').each { |s| trail << trail.last + "#{s}/" unless s.empty? }
          trail.map do |child_identifier|
            child = @items[child_identifier]
    Severity: Minor
    Found in lib/nanoc/toolbox/helpers/navigation.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