Showing 372 of 392 total issues

Method read_file has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

  def self.read_file filename, encoding, force_transcode = false
    content = File.open filename, "rb" do |f| f.read end
    content.gsub!("\r\n", "\n") if RUBY_PLATFORM =~ /mswin|mingw/

    utf8 = content.sub!(/\A\xef\xbb\xbf/, '')
Severity: Minor
Found in lib/rdoc/encoding.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

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

  def parse parent, indent = 0
    p :parse_start => indent if @debug

    until @tokens.empty? do
      type, data, column, = get
Severity: Minor
Found in lib/rdoc/markup/parser.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

Method do_classes_and_modules has 86 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def do_classes_and_modules
    do_boot_defclass if @file_name == "class.c"

    @content.scan(
      %r(
Severity: Major
Found in lib/rdoc/parser/c.rb - About 3 hrs to fix

    Method setup_output_dir has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      def setup_output_dir(dir, force)
        flag_file = output_flag_file dir
    
        last = {}
    
    
    Severity: Minor
    Found in lib/rdoc/rdoc.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

    Method get_squashed_tk has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_squashed_tk
        if @buf.empty?
          tk = @tokens.shift
        else
          tk = @buf.shift
    Severity: Minor
    Found in lib/rdoc/parser/ripper_state_lex.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

    Method skip_optional_do_after_expression has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      def skip_optional_do_after_expression
        skip_tkspace_without_nl
        tk = get_tk
    
        b_nest = 0
    Severity: Minor
    Found in lib/rdoc/parser/ruby.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 rdoc.rb has 304 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_relative '../rdoc'
    
    require 'find'
    require 'fileutils'
    require 'pathname'
    Severity: Minor
    Found in lib/rdoc/rdoc.rb - About 3 hrs to fix

      Method parse_call_parameters has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

        def parse_call_parameters(tk)
          end_token = case tk[:kind]
                      when :on_lparen
                        :on_rparen
                      when :on_rparen
      Severity: Minor
      Found in lib/rdoc/parser/ruby.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

      Method override has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

        def override map # :nodoc:
          if map.has_key?('encoding')
            encoding = map['encoding']
            @encoding = encoding ? Encoding.find(encoding) : encoding
          end
      Severity: Minor
      Found in lib/rdoc/options.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

      Function prototype has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Search.prototype = Object.assign({}, Navigation, new function() {
        var suid = 1;
      
        this.init = function() {
          var _this = this;
      Severity: Major
      Found in lib/rdoc/generator/template/darkfish/js/search.js - About 3 hrs to fix

        Class TopLevel has 27 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class RDoc::TopLevel < RDoc::Context
        
          MARSHAL_VERSION = 0 # :nodoc:
        
          ##
        Severity: Minor
        Found in lib/rdoc/top_level.rb - About 3 hrs to fix

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

            def to_html text
              html = (''.encode text.encoding).dup
          
              encoded = RDoc::Text::TO_HTML_CHARACTERS[text.encoding]
          
          
          Severity: Minor
          Found in lib/rdoc/text.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

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

            def report_methods cm
              return if cm.method_list.empty?
          
              report = []
          
          
          Severity: Minor
          Found in lib/rdoc/stats.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

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

            def handle_class_module(var_name, type, class_name, parent, in_module)
              parent_name = @known_classes[parent] || parent
          
              if in_module then
                enclosure = @classes[in_module] || @store.find_c_enclosure(in_module)
          Severity: Minor
          Found in lib/rdoc/parser/c.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 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

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

            class RDoc::MethodAttr < RDoc::CodeObject
            
              include Comparable
            
              ##
            Severity: Minor
            Found in lib/rdoc/method_attr.rb - About 3 hrs to fix

              Method to_html has 74 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def to_html text
                  html = (''.encode text.encoding).dup
              
                  encoded = RDoc::Text::TO_HTML_CHARACTERS[text.encoding]
              
              
              Severity: Major
              Found in lib/rdoc/text.rb - About 2 hrs to fix

                Method add_class has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def add_class class_type, given_name, superclass = '::Object'
                    # superclass +nil+ is passed by the C parser in the following cases:
                    # - registering Object in 1.8 (correct)
                    # - registering BasicObject in 1.9 (correct)
                    # - registering RubyVM in 1.9 in iseq.c (incorrect: < Object in vm.c)
                Severity: Major
                Found in lib/rdoc/context.rb - About 2 hrs to fix

                  Method get_method_container has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def get_method_container container, name_t # :nodoc:
                      prev_container = container
                      container = container.find_module_named(name_t[:text])
                  
                      unless container then
                  Severity: Minor
                  Found in lib/rdoc/parser/ruby.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 build_paragraph has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def build_paragraph margin
                      p :paragraph_start => margin if @debug
                  
                      paragraph = RDoc::Markup::Paragraph.new
                  
                  
                  Severity: Minor
                  Found in lib/rdoc/tom_doc.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

                  Severity
                  Category
                  Status
                  Source
                  Language