lib/rdoc/generator/darkfish.rb

Summary

Maintainability
F
3 days
Test Coverage

File darkfish.rb has 431 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'erb'
require 'fileutils'
require 'pathname'
require_relative 'markup'

Severity: Minor
Found in lib/rdoc/generator/darkfish.rb - About 6 hrs to fix

    Method generate_file_files has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

      def generate_file_files
        setup
    
        page_file     = @template_dir + 'page.rhtml'
        fileinfo_file = @template_dir + 'fileinfo.rhtml'
    Severity: Minor
    Found in lib/rdoc/generator/darkfish.rb - About 5 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 Darkfish has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class RDoc::Generator::Darkfish
    
      RDoc::RDoc.add_generator self
    
      include ERB::Util
    Severity: Minor
    Found in lib/rdoc/generator/darkfish.rb - About 3 hrs to fix

      Method generate_file_files has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def generate_file_files
          setup
      
          page_file     = @template_dir + 'page.rhtml'
          fileinfo_file = @template_dir + 'fileinfo.rhtml'
      Severity: Minor
      Found in lib/rdoc/generator/darkfish.rb - About 1 hr to fix

        Method time_delta_string has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def time_delta_string seconds
            return 'less than a minute'          if seconds < 60
            return "#{seconds / 60} minute#{seconds / 60 == 1 ? '' : 's'}" if
                                                    seconds < 3000     # 50 minutes
            return 'about one hour'              if seconds < 5400     # 90 minutes
        Severity: Minor
        Found in lib/rdoc/generator/darkfish.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_static has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def copy_static
            return if @options.static_path.empty?
        
            fu_options = { :verbose => $DEBUG_RDOC, :noop => @dry_run }
        
        
        Severity: Minor
        Found in lib/rdoc/generator/darkfish.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 write_style_sheet has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def write_style_sheet
            debug_msg "Copying static files"
            options = { :verbose => $DEBUG_RDOC, :noop => @dry_run }
        
            BUILTIN_STYLE_ITEMS.each do |item|
        Severity: Minor
        Found in lib/rdoc/generator/darkfish.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 render_template has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def render_template template_file, out_file = nil # :yield: io
            io_output = out_file && !@dry_run && @file_output
            erb_klass = io_output ? RDoc::ERBIO : ERB
        
            template = template_for template_file, true, erb_klass
        Severity: Minor
        Found in lib/rdoc/generator/darkfish.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 generate_class_files has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def generate_class_files
            setup
        
            template_file = @template_dir + 'class.rhtml'
            template_file = @template_dir + 'classpage.rhtml' unless
        Severity: Minor
        Found in lib/rdoc/generator/darkfish.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

        Avoid too many return statements within this method.
        Open

            return 'about one week'              if seconds < 1209600  #  2 week
        Severity: Major
        Found in lib/rdoc/generator/darkfish.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

              return "#{seconds / 604800} weeks"   if seconds < 7257600  #  3 months
          Severity: Major
          Found in lib/rdoc/generator/darkfish.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                return 'about one day'               if seconds < 172800   #  2 days
            Severity: Major
            Found in lib/rdoc/generator/darkfish.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                  return "#{seconds / 31536000} years"
              Severity: Major
              Found in lib/rdoc/generator/darkfish.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                    return 'one day'                     if seconds < 86400    #  1 day
                Severity: Major
                Found in lib/rdoc/generator/darkfish.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                      return "#{seconds / 2419200} months" if seconds < 31536000 #  1 year
                  Severity: Major
                  Found in lib/rdoc/generator/darkfish.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                        return "#{seconds / 86400} days"     if seconds < 604800   #  1 week
                    Severity: Major
                    Found in lib/rdoc/generator/darkfish.rb - About 30 mins to fix

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

                        def generate_table_of_contents
                          setup
                      
                          template_file = @template_dir + 'table_of_contents.rhtml'
                          return unless template_file.exist?
                      Severity: Minor
                      Found in lib/rdoc/generator/darkfish.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 generate_servlet_not_found has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def generate_servlet_not_found message
                          setup
                      
                          template_file = @template_dir + 'servlet_not_found.rhtml'
                          return unless template_file.exist?
                      Severity: Minor
                      Found in lib/rdoc/generator/darkfish.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 generate_servlet_root has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def generate_servlet_root installed
                          setup
                      
                          template_file = @template_dir + 'servlet_root.rhtml'
                          return unless template_file.exist?
                      Severity: Minor
                      Found in lib/rdoc/generator/darkfish.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 generate_index has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def generate_index
                          setup
                      
                          template_file = @template_dir + 'index.rhtml'
                          return unless template_file.exist?
                      Severity: Minor
                      Found in lib/rdoc/generator/darkfish.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

                      There are no issues that match your filters.

                      Category
                      Status