trulia/hologram

View on GitHub

Showing 9 of 11 total issues

Class DocBuilder has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

  class DocBuilder
    attr_accessor :source, :destination, :documentation_assets, :dependencies, :index, :base_path, :renderer, :doc_blocks, :pages, :config_yml
    attr_reader :errors
    attr :doc_assets_dir, :output_dir, :input_dir, :header_erb, :footer_erb

Severity: Minor
Found in lib/hologram/doc_builder.rb - About 2 hrs to fix

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

        def write_docs
          load_code_example_templates_and_renderers
    
          renderer_instance = renderer.new(link_helper: link_helper)
          markdown = Redcarpet::Markdown.new(renderer_instance, { fenced_code_blocks: true, tables: true })
    Severity: Minor
    Found in lib/hologram/doc_builder.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 copy_assets has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def copy_assets
          return unless doc_assets_dir
          Dir.foreach(doc_assets_dir) do |item|
            # ignore . and .. directories and files that start with
            # underscore
    Severity: Minor
    Found in lib/hologram/doc_builder.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 process_file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_file(file, doc_block_collection)
          file_str = File.read(file)
          # get any comment blocks that match the patterns:
          # .sass: //doc (follow by other lines proceeded by a space)
          # other types: /*doc ... */
    Severity: Minor
    Found in lib/hologram/doc_parser.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 create_nested_structure has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def create_nested_structure
          blocks_to_remove_from_top_level = []
          @doc_blocks.each do |key, doc_block|
            # don't do anything to top level doc_blocks
            next if !doc_block.parent
    Severity: Minor
    Found in lib/hologram/doc_block_collection.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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def run
          return setup if args[0] == 'init'
          extra_args = []
    
          #support passing the config file with no command line flag
    Severity: Minor
    Found in lib/hologram/cli.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 parse_block has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_block(comment_block, file)
    
          plugin_sections = comment_block.markdown.scan(/^\s*\[\[\[plugin:#{Regexp.quote(@name)}(.*?)\]\]\]/m)
    
          if self.is_active?
    Severity: Minor
    Found in lib/hologram/plugin.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 process_files has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_files(files, directory, doc_block_collection)
    
          if !@ignore_paths.empty?
            valid_files = files.select { |input_file|
              @ignore_paths.select { |glob| File.fnmatch(glob, input_file) }.empty?
    Severity: Minor
    Found in lib/hologram/doc_parser.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 set_header_footer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def set_header_footer
          # load the markdown renderer we are going to use
    
          if File.exists?("#{doc_assets_dir}/_header.html")
            @header_erb = ERB.new(File.read("#{doc_assets_dir}/_header.html"))
    Severity: Minor
    Found in lib/hologram/doc_builder.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