ddfreyne/nanoc

View on GitHub

Showing 85 of 91 total issues

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

    def relative_path_to(target)
      require 'pathname'

      # Find path
      if target.is_a?(String)
Severity: Minor
Found in lib/nanoc/helpers/link_to.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 valid? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def valid?(href, origin)
      # Skip hrefs that point to self
      # FIXME: this is ugly and won’t always be correct
      return true if href == '.'

Severity: Minor
Found in lib/nanoc/checking/checks/internal_links.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 raw_compiled_content has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def raw_compiled_content(rep:, snapshot: nil)
      # Get name of last pre-layout snapshot
      snapshot_name = snapshot || (get(rep, :pre) ? :pre : :last)

      # Check existance of snapshot
Severity: Minor
Found in lib/nanoc/base/repos/snapshot_repo.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 8 (exceeds 5 allowed). Consider refactoring.
Open

      def run
        rep = @requested_item.reps[:default].unwrap

        # Create dependency
        if @item.nil? || @requested_item != @item.unwrap
Severity: Minor
Found in lib/nanoc/helpers/capturing.rb - About 45 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 recursively_find_vertices has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def recursively_find_vertices(start, method)
      all_vertices = Set.new

      processed_vertices   = Set.new
      unprocessed_vertices = [start]
Severity: Minor
Found in lib/nanoc/base/entities/directed_graph.rb - About 45 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 active has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def active
      Set.new.tap do |pr|
        pr << :raw_content if raw_content?
        pr << :attributes if attributes?
        pr << :compiled_content if compiled_content?
Severity: Minor
Found in lib/nanoc/base/entities/props.rb - About 45 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 nokogiri_process_comment has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def nokogiri_process_comment(node, doc, selectors, namespaces, klass, type)
Severity: Minor
Found in lib/nanoc/filters/relativize_paths.rb - About 45 mins to fix

    Method parse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse(content, klass, is_fullpage)
          if is_fullpage
            klass.parse(content, nil, 'UTF-8')
          else
            klass.fragment(content)
    Severity: Minor
    Found in lib/nanoc/filters/colorize_syntax.rb - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def run(content, params = {})
          # Create formatter
          r = ::RedCloth.new(content)
    
          # Set options
    Severity: Minor
    Found in lib/nanoc/filters/redcloth.rb - About 45 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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.update(obj, digest)
            if obj.checksum_data
              digest.update('checksum_data=' + obj.checksum_data)
            else
              if obj.content_checksum_data
    Severity: Minor
    Found in lib/nanoc/base/services/checksummer.rb - About 45 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 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def run(&block)
            existing_behavior = @params.fetch(:existing, :error)
    
            # Capture
            content_string = capture(&block)
    Severity: Minor
    Found in lib/nanoc/helpers/capturing.rb - About 45 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 nokogiri_process has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def nokogiri_process(content, selectors, namespaces, klass, type)
    Severity: Minor
    Found in lib/nanoc/filters/relativize_paths.rb - About 35 mins to fix

      Method write_single has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def write_single(item_rep, snapshot_repo, snapshot_name, raw_path, written_paths)
      Severity: Minor
      Found in lib/nanoc/base/services/item_rep_writer.rb - About 35 mins to fix

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

            def run
              load_adsf
              require 'rack'
        
              load_site
        Severity: Minor
        Found in lib/nanoc/cli/commands/view.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 handle_while has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def handle_while(&_block)
              # Set exit handler
              %w(INT TERM).each do |signal|
                Signal.trap(signal) do
                  puts
        Severity: Minor
        Found in lib/nanoc/cli/error_handler.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 new_rule_memory_for_rep has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def new_rule_memory_for_rep(rep)
              dependency_tracker = Nanoc::Int::DependencyTracker::Null.new
              view_context = @site.compiler.compilation_context.create_view_context(dependency_tracker)
        
              rule_memory = Nanoc::Int::RuleMemory.new(rep)
        Severity: Minor
        Found in lib/nanoc/rule_dsl/rule_memory_calculator.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 diff_strings has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def diff_strings(a, b)
                require 'open3'
        
                # Create files
                Tempfile.open('old') do |old_file|
        Severity: Minor
        Found in lib/nanoc/cli/commands/compile.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 identifier_for_filename has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def identifier_for_filename(filename)
              if config[:identifier_type] == 'full'
                return Nanoc::Identifier.new(filename)
              end
        
        
        Severity: Minor
        Found in lib/nanoc/data_sources/filesystem.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 load_commands_at has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.load_commands_at(path)
            recursive_contents_of(path).each do |filename|
              # Create command
              command = Nanoc::CLI.load_command_at(filename)
        
        
        Severity: Minor
        Found in lib/nanoc/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 passthrough has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def passthrough(identifier, rep: :default)
              raise ArgumentError.new('#passthrough does not require a block') if block_given?
        
              compilation_block = proc {}
              compilation_rule = Nanoc::RuleDSL::Rule.new(create_pattern(identifier), rep, compilation_block)
        Severity: Minor
        Found in lib/nanoc/rule_dsl/compiler_dsl.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