lib/rdoc/parser/c.rb

Summary

Maintainability
F
1 wk
Test Coverage

File c.rb has 734 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'tsort'

##
# RDoc::Parser::C attempts to parse C extension files.  It looks for
# the standard patterns that you find in extensions: +rb_define_class+,
Severity: Major
Found in lib/rdoc/parser/c.rb - About 1 day to fix

    Method handle_method has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

      def handle_method(type, var_name, meth_name, function, param_count,
                        source_file = nil)
        class_name = @known_classes[var_name]
        singleton  = @singleton_classes.key? var_name
    
    
    Severity: Minor
    Found in lib/rdoc/parser/c.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

    Class C has 32 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class RDoc::Parser::C < RDoc::Parser
    
      parse_files_matching(/\.(?:([CcHh])\1?|c([+xp])\2|y)\z/)
    
      include RDoc::Text
    Severity: Minor
    Found in lib/rdoc/parser/c.rb - About 4 hrs to fix

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

        Method find_body has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          def find_body class_name, meth_name, meth_obj, file_content, quiet = false
            if file_content
              @body_table ||= {}
              @body_table[file_content] ||= gen_body_table file_content
              type, *args = @body_table[file_content][meth_name]
        Severity: Minor
        Found in lib/rdoc/parser/c.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 rb_scan_args has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def rb_scan_args method_body
            method_body =~ /rb_scan_args\((.*?)\)/m
            return '(*args)' unless $1
        
            $1.split(/,/)[2] =~ /"(.*?)"/ # format argument
        Severity: Major
        Found in lib/rdoc/parser/c.rb - About 2 hrs to fix

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

            def rb_scan_args method_body
              method_body =~ /rb_scan_args\((.*?)\)/m
              return '(*args)' unless $1
          
              $1.split(/,/)[2] =~ /"(.*?)"/ # format argument
          Severity: Minor
          Found in lib/rdoc/parser/c.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 find_body has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def find_body class_name, meth_name, meth_obj, file_content, quiet = false
              if file_content
                @body_table ||= {}
                @body_table[file_content] ||= gen_body_table file_content
                type, *args = @body_table[file_content][meth_name]
          Severity: Major
          Found in lib/rdoc/parser/c.rb - About 2 hrs to fix

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

              def handle_method(type, var_name, meth_name, function, param_count,
                                source_file = nil)
                class_name = @known_classes[var_name]
                singleton  = @singleton_classes.key? var_name
            
            
            Severity: Minor
            Found in lib/rdoc/parser/c.rb - About 1 hr to fix

              Method handle_class_module has 41 lines of code (exceeds 25 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 1 hr to fix

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

                  def handle_constants(type, var_name, const_name, definition)
                    class_name = @known_classes[var_name]
                
                    return unless class_name
                
                
                Severity: Minor
                Found in lib/rdoc/parser/c.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 do_methods has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def do_methods
                    @content.scan(%r%rb_define_
                                   (
                                      singleton_method |
                                      method           |
                Severity: Minor
                Found in lib/rdoc/parser/c.rb - About 1 hr to fix

                  Method do_constants has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def do_constants
                      @content.scan(%r%\Wrb_define_
                                     ( variable          |
                                       readonly_variable |
                                       const             |
                  Severity: Minor
                  Found in lib/rdoc/parser/c.rb - About 1 hr to fix

                    Method load_variable_map has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def load_variable_map map_name
                        return {} unless files = @store.cache[map_name]
                        return {} unless name_map = files[@file_name]
                    
                        class_map = {}
                    Severity: Minor
                    Found in lib/rdoc/parser/c.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 do_classes_and_modules has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def do_classes_and_modules
                        do_boot_defclass if @file_name == "class.c"
                    
                        @content.scan(
                          %r(
                    Severity: Minor
                    Found in lib/rdoc/parser/c.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 handle_constants has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def handle_constants(type, var_name, const_name, definition)
                        class_name = @known_classes[var_name]
                    
                        return unless class_name
                    
                    
                    Severity: Minor
                    Found in lib/rdoc/parser/c.rb - About 1 hr to fix

                      Method initialize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def initialize top_level, file_name, content, options, stats
                          super
                      
                          @known_classes = RDoc::KNOWN_CLASSES.dup
                          @content = handle_tab_width handle_ifdefs_in @content
                      Severity: Minor
                      Found in lib/rdoc/parser/c.rb - About 1 hr to fix

                        Method gen_body_table has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def gen_body_table file_content
                            table = {}
                            file_content.scan(%r{
                              ((?>/\*.*?\*/\s*)?)
                              ((?:\w+\s+){0,2} VALUE\s+(\w+)
                        Severity: Minor
                        Found in lib/rdoc/parser/c.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 gen_const_table has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def gen_const_table file_content
                            table = {}
                            @content.scan(%r{
                              (?<doc>(?>^\s*/\*.*?\*/\s+))
                                rb_define_(?<type>\w+)\(\s*(?:\w+),\s*
                        Severity: Minor
                        Found in lib/rdoc/parser/c.rb - About 1 hr to fix

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

                            def do_methods
                              @content.scan(%r%rb_define_
                                             (
                                                singleton_method |
                                                method           |
                          Severity: Minor
                          Found in lib/rdoc/parser/c.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 handle_method has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                            def handle_method(type, var_name, meth_name, function, param_count,
                                              source_file = nil)
                          Severity: Minor
                          Found in lib/rdoc/parser/c.rb - About 45 mins to fix

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

                              def initialize top_level, file_name, content, options, stats
                            Severity: Minor
                            Found in lib/rdoc/parser/c.rb - About 35 mins to fix

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

                                def handle_class_module(var_name, type, class_name, parent, in_module)
                              Severity: Minor
                              Found in lib/rdoc/parser/c.rb - About 35 mins to fix

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

                                  def add_alias(var_name, class_obj, old_name, new_name, comment)
                                Severity: Minor
                                Found in lib/rdoc/parser/c.rb - About 35 mins to fix

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

                                    def find_body class_name, meth_name, meth_obj, file_content, quiet = false
                                  Severity: Minor
                                  Found in lib/rdoc/parser/c.rb - About 35 mins to fix

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

                                      def do_aliases
                                        @content.scan(/rb_define_alias\s*\(
                                                       \s*(\w+),
                                                       \s*"(.+?)",
                                                       \s*"(.+?)"
                                    Severity: Minor
                                    Found in lib/rdoc/parser/c.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 find_attr_comment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                      def find_attr_comment var_name, attr_name, read = nil, write = nil
                                        attr_name = Regexp.escape attr_name
                                    
                                        rw = if read and write then
                                               /\s*#{read}\s*,\s*#{write}\s*/xm
                                    Severity: Minor
                                    Found in lib/rdoc/parser/c.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 find_class has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                      def find_class(raw_name, name, base_name = nil)
                                        unless @classes[raw_name]
                                          if raw_name =~ /^rb_m/
                                            container = @top_level.add_module RDoc::NormalModule, name
                                          else
                                    Severity: Minor
                                    Found in lib/rdoc/parser/c.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_attr has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                      def handle_attr(var_name, attr_name, read, write)
                                        rw = ''
                                        rw += 'R' if TRUE_VALUES.include?(read)
                                        rw += 'W' if TRUE_VALUES.include?(write)
                                    
                                    
                                    Severity: Minor
                                    Found in lib/rdoc/parser/c.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