trulia/hologram

View on GitHub

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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

          if File.exists?("#{doc_assets_dir}/_header.html")
            @header_erb = ERB.new(File.read("#{doc_assets_dir}/_header.html"))
          elsif File.exists?("#{doc_assets_dir}/header.html")
            @header_erb = ERB.new(File.read("#{doc_assets_dir}/header.html"))
          else
    Severity: Minor
    Found in lib/hologram/doc_builder.rb and 1 other location - About 40 mins to fix
    lib/hologram/doc_builder.rb on lines 262..269

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

    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 File.exists?("#{doc_assets_dir}/_footer.html")
            @footer_erb = ERB.new(File.read("#{doc_assets_dir}/_footer.html"))
          elsif File.exists?("#{doc_assets_dir}/footer.html")
            @footer_erb = ERB.new(File.read("#{doc_assets_dir}/footer.html"))
          else
    Severity: Minor
    Found in lib/hologram/doc_builder.rb and 1 other location - About 40 mins to fix
    lib/hologram/doc_builder.rb on lines 253..260

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

    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

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

    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

    Severity
    Category
    Status
    Source
    Language