ddfreyne/nanoc

View on GitHub

Showing 85 of 91 total issues

Method print_item_dependencies has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def print_item_dependencies(items, dependency_store)
      print_header('Item dependencies')

      puts 'Legend:'
      puts '  r = dependency on raw content'
Severity: Minor
Found in lib/nanoc/cli/commands/show-data.rb - About 4 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 30 (exceeds 5 allowed). Consider refactoring.
Open

    def run(content, params = {})
      Nanoc::Extra::JRubyNokogiriWarner.check_and_warn

      # Take colorizers from parameters
      @colorizers = Hash.new(params[:default_colorizer] || DEFAULT_COLORIZER)
Severity: Minor
Found in lib/nanoc/filters/colorize_syntax.rb - About 4 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

File compile.rb has 328 lines of code (exceeds 250 allowed). Consider refactoring.
Open

usage 'compile [options]'
summary 'compile items of this site'
description <<-EOS
Compile all items of the current site.
EOS
Severity: Minor
Found in lib/nanoc/cli/commands/compile.rb - About 3 hrs to fix

    Method validate has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate(href)
          # Parse
          url = nil
          begin
            url = URI.parse(href)
    Severity: Minor
    Found in lib/nanoc/checking/checks/external_links.rb - About 3 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

    Class Filesystem has 29 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Filesystem < Nanoc::DataSource
        identifiers :filesystem, :filesystem_unified
    
        # See {Nanoc::DataSource#up}.
        def up; end
    Severity: Minor
    Found in lib/nanoc/data_sources/filesystem.rb - About 3 hrs to fix

      Method xml_sitemap has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def xml_sitemap(params = {})
            require 'builder'
      
            # Extract parameters
            items       = params.fetch(:items) { @items.reject { |i| i[:is_hidden] } }
      Severity: Minor
      Found in lib/nanoc/helpers/xml_sitemap.rb - About 3 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

      File filesystem.rb has 292 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Nanoc::DataSources
        # The filesystem data source stores its items and layouts in nested
        # directories. Items and layouts are represented by one or two files; if it
        # is represented using one file, the metadata can be contained in this file.
        #
      Severity: Minor
      Found in lib/nanoc/data_sources/filesystem.rb - About 3 hrs to fix

        Class ErrorHandler has 26 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class ErrorHandler
            # @param [Nanoc::CLI::Command, nil] command The command that is
            #   currently being executed, or nil if there is none
            def initialize(command: nil)
              @command = command
        Severity: Minor
        Found in lib/nanoc/cli/error_handler.rb - About 3 hrs to fix

          Class CleaningStream has 24 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class CleaningStream
              # @param [IO, StringIO] stream The stream to wrap
              def initialize(stream)
                @stream = stream
                @stream_cleaners = []
          Severity: Minor
          Found in lib/nanoc/cli/cleaning_stream.rb - About 2 hrs to fix

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

                def run
                  unless File.exist?(source_path)
                    raise Errors::OutputDirDoesNotExist.new(source_path)
                  end
            
            
            Severity: Minor
            Found in lib/nanoc/deploying/deployers/git.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 each has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                def each
                  queue = SizedQueue.new(2 * @parallelism)
                  error = nil
            
                  threads = (1..@parallelism).map do
            Severity: Minor
            Found in lib/nanoc/extra/parallel_collection.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 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def run(content, params = {})
                  if ::Redcarpet::VERSION > '2'
                    options          = params.fetch(:options,          {})
                    renderer_class   = params.fetch(:renderer,         ::Redcarpet::Render::HTML)
                    renderer_options = params.fetch(:renderer_options, {})
            Severity: Minor
            Found in lib/nanoc/filters/redcarpet.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 validate has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def validate(href)
                  # Parse
                  url = nil
                  begin
                    url = URI.parse(href)
            Severity: Minor
            Found in lib/nanoc/checking/checks/external_links.rb - About 1 hr to fix

              Method all_split_files_in has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  def all_split_files_in(dir_name)
                    by_basename =
                      all_files_in(dir_name)
                      .reject   { |fn| fn =~ /(~|\.orig|\.rej|\.bak)$/ }
                      .group_by { |fn| basename_of(fn) }
              Severity: Minor
              Found in lib/nanoc/data_sources/filesystem.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 start has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                    def start
                      require 'tempfile'
                      setup_diffs
                      old_contents = {}
                      Nanoc::Int::NotificationCenter.on(:will_write_rep, self) do |rep, path|
              Severity: Minor
              Found in lib/nanoc/cli/commands/compile.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 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def run(content, params = {})
                    Nanoc::Extra::JRubyNokogiriWarner.check_and_warn
              
                    # Take colorizers from parameters
                    @colorizers = Hash.new(params[:default_colorizer] || DEFAULT_COLORIZER)
              Severity: Minor
              Found in lib/nanoc/filters/colorize_syntax.rb - About 1 hr to fix

                Method print_item_dependencies has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def print_item_dependencies(items, dependency_store)
                      print_header('Item dependencies')
                
                      puts 'Legend:'
                      puts '  r = dependency on raw content'
                Severity: Minor
                Found in lib/nanoc/cli/commands/show-data.rb - About 1 hr to fix

                  Method run has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def run
                        # Check arguments
                        if arguments.any?
                          raise Nanoc::Int::Errors::GenericTrivial, "usage: #{command.usage}"
                        end
                  Severity: Minor
                  Found in lib/nanoc/cli/commands/show-plugins.rb - About 1 hr to fix

                    Method content_for has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def content_for(*args, &block)
                          if block_given? # Set content
                            name = args[0]
                            params =
                              case args.size
                    Severity: Minor
                    Found in lib/nanoc/helpers/capturing.rb - About 1 hr to fix

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

                          def mtime_of(content_filename, meta_filename)
                            meta_mtime = meta_filename ? File.stat(meta_filename).mtime : nil
                            content_mtime = content_filename ? File.stat(content_filename).mtime : nil
                            if meta_mtime && content_mtime
                              meta_mtime > content_mtime ? meta_mtime : content_mtime
                      Severity: Minor
                      Found in lib/nanoc/data_sources/filesystem.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

                      Severity
                      Category
                      Status
                      Source
                      Language