lib/rdoc/parser/ruby.rb

Summary

Maintainability
F
3 wks
Test Coverage

File ruby.rb has 1520 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'ripper'
require_relative 'ripper_state_lex'

##
# Extracts code elements from a source file returning a TopLevel object
Severity: Major
Found in lib/rdoc/parser/ruby.rb - About 4 days to fix

    Method parse_statements has a Cognitive Complexity of 156 (exceeds 5 allowed). Consider refactoring.
    Open

      def parse_statements(container, single = NORMAL, current_method = nil,
                           comment = new_comment(''))
        raise 'no' unless RDoc::Comment === comment
        comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding
    
    
    Severity: Minor
    Found in lib/rdoc/parser/ruby.rb - About 3 days 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 Ruby has 73 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class RDoc::Parser::Ruby < RDoc::Parser
    
      parse_files_matching(/\.rbw?$/)
    
      include RDoc::TokenStream
    Severity: Major
    Found in lib/rdoc/parser/ruby.rb - About 1 day to fix

      Method get_included_module_with_optional_parens has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
      Open

        def get_included_module_with_optional_parens
          skip_tkspace_without_nl
          get_tkread
          tk = get_tk
          end_token = get_end_token tk
      Severity: Minor
      Found in lib/rdoc/parser/ruby.rb - About 1 day 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_method_or_yield_parameters has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
      Open

        def parse_method_or_yield_parameters(method = nil,
                                             modifiers = RDoc::METHOD_MODIFIERS)
          skip_tkspace_without_nl
          tk = get_tk
          end_token = get_end_token tk
      Severity: Minor
      Found in lib/rdoc/parser/ruby.rb - About 6 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_constant_body has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
      Open

        def parse_constant_body container, constant, is_array_or_hash # :nodoc:
          nest     = 0
          rhs_name = ''.dup
      
          get_tkread
      Severity: Minor
      Found in lib/rdoc/parser/ruby.rb - About 6 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_statements has 142 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def parse_statements(container, single = NORMAL, current_method = nil,
                             comment = new_comment(''))
          raise 'no' unless RDoc::Comment === comment
          comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding
      
      
      Severity: Major
      Found in lib/rdoc/parser/ruby.rb - About 5 hrs to fix

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

          def parse_constant container, tk, comment, ignore_constants = false
            line_no = tk[:line_no]
        
            name = tk[:text]
            skip_tkspace_without_nl
        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 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

        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 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 get_included_module_with_optional_parens has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def get_included_module_with_optional_parens
            skip_tkspace_without_nl
            get_tkread
            tk = get_tk
            end_token = get_end_token tk
        Severity: Major
        Found in lib/rdoc/parser/ruby.rb - About 2 hrs to fix

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

            def collect_first_comment
              skip_tkspace
              comment = ''.dup
              comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding
              first_line = true
          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 parse_meta_method_params has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def parse_meta_method_params container, single, meth, tk, comment # :nodoc:
              token_listener meth do
                meth.params = ''
          
                look_for_directives_in meth, comment
          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 scan has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def scan
              reset
          
              catch :eof do
                begin
          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 parse_method_name_singleton has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

            def parse_method_name_singleton container, name_t # :nodoc:
              skip_tkspace
              name_t2 = get_tk
          
              if (:on_kw == name_t[:kind] && 'self' == name_t[:text]) || (:on_op == name_t[:kind] && '%' == name_t[:text]) 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 read_directive has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def read_directive allowed
              tokens = []
          
              while tk = get_tk do
                tokens << tk
          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 parse_method_or_yield_parameters has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def parse_method_or_yield_parameters(method = nil,
                                                 modifiers = RDoc::METHOD_MODIFIERS)
              skip_tkspace_without_nl
              tk = get_tk
              end_token = get_end_token tk
          Severity: Major
          Found in lib/rdoc/parser/ruby.rb - About 2 hrs to fix

            Method parse_constant has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def parse_constant container, tk, comment, ignore_constants = false
                line_no = tk[:line_no]
            
                name = tk[:text]
                skip_tkspace_without_nl
            Severity: Minor
            Found in lib/rdoc/parser/ruby.rb - About 1 hr to fix

              Method get_class_or_module has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                def get_class_or_module container, ignore_constants = false
                  skip_tkspace
                  name_t = get_tk
                  given_name = ''.dup
              
              
              Severity: Minor
              Found in lib/rdoc/parser/ruby.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 parse_symbol_arg_space has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                def parse_symbol_arg_space no, tk # :nodoc:
                  args = []
              
                  unget_tk tk
                  if tk = parse_symbol_in_arg
              Severity: Minor
              Found in lib/rdoc/parser/ruby.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 parse_constant_body has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def parse_constant_body container, constant, is_array_or_hash # :nodoc:
                  nest     = 0
                  rhs_name = ''.dup
              
                  get_tkread
              Severity: Minor
              Found in lib/rdoc/parser/ruby.rb - About 1 hr to fix

                Method get_class_or_module has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def get_class_or_module container, ignore_constants = false
                    skip_tkspace
                    name_t = get_tk
                    given_name = ''.dup
                
                
                Severity: Minor
                Found in lib/rdoc/parser/ruby.rb - About 1 hr to fix

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

                    def parse_identifier container, single, tk, comment # :nodoc:
                      case tk[:text]
                      when 'private', 'protected', 'public', 'private_class_method',
                           'public_class_method', 'module_function' then
                        parse_visibility container, single, tk
                  Severity: Minor
                  Found in lib/rdoc/parser/ruby.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 parse_symbol_arg_paren has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def parse_symbol_arg_paren no # :nodoc:
                      args = []
                  
                      loop do
                        skip_tkspace_comment
                  Severity: Minor
                  Found in lib/rdoc/parser/ruby.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 parse_call_parameters has 35 lines of code (exceeds 25 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 1 hr to fix

                    Method parse_method has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def parse_method(container, single, tk, comment)
                        singleton = nil
                        added_container = false
                        name = nil
                        column  = tk[:char_no]
                    Severity: Minor
                    Found in lib/rdoc/parser/ruby.rb - About 1 hr to fix

                      Method update_visibility has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def update_visibility container, vis_type, vis, singleton # :nodoc:
                          new_methods = []
                      
                          case vis_type
                          when 'module_function' then
                      Severity: Minor
                      Found in lib/rdoc/parser/ruby.rb - About 1 hr to fix

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

                          def parse_class_regular container, declaration_context, single, # :nodoc:
                                                  name_t, given_name, comment
                            superclass = '::Object'
                        
                            if given_name =~ /^::/ then
                        Severity: Minor
                        Found in lib/rdoc/parser/ruby.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 parse_method_params_and_body has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def parse_method_params_and_body container, single, meth, added_container
                            token_listener meth do
                              parse_method_parameters meth
                        
                              if meth.document_self or not @track_visibility then
                        Severity: Minor
                        Found in lib/rdoc/parser/ruby.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 skip_optional_do_after_expression has 31 lines of code (exceeds 25 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 1 hr to fix

                          Method collect_first_comment has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def collect_first_comment
                              skip_tkspace
                              comment = ''.dup
                              comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding
                              first_line = true
                          Severity: Minor
                          Found in lib/rdoc/parser/ruby.rb - About 1 hr to fix

                            Method parse_identifier has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def parse_identifier container, single, tk, comment # :nodoc:
                                case tk[:text]
                                when 'private', 'protected', 'public', 'private_class_method',
                                     'public_class_method', 'module_function' then
                                  parse_visibility container, single, tk
                            Severity: Minor
                            Found in lib/rdoc/parser/ruby.rb - About 1 hr to fix

                              Method scan has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def scan
                                  reset
                              
                                  catch :eof do
                                    begin
                              Severity: Minor
                              Found in lib/rdoc/parser/ruby.rb - About 1 hr to fix

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

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

                                    def parse_method_name_singleton container, name_t # :nodoc:
                                      skip_tkspace
                                      name_t2 = get_tk
                                  
                                      if (:on_kw == name_t[:kind] && 'self' == name_t[:text]) || (:on_op == name_t[:kind] && '%' == name_t[:text]) then
                                  Severity: Minor
                                  Found in lib/rdoc/parser/ruby.rb - About 1 hr to fix

                                    Method parse_alias has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      def parse_alias(context, single, tk, comment)
                                        line_no = tk[:line_no]
                                    
                                        skip_tkspace
                                    
                                    
                                    Severity: Minor
                                    Found in lib/rdoc/parser/ruby.rb - About 1 hr to fix

                                      Method parse_meta_method has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                        def parse_meta_method(container, single, tk, comment)
                                          column  = tk[:char_no]
                                          line_no = tk[:line_no]
                                      
                                          start_collecting_tokens
                                      Severity: Minor
                                      Found in lib/rdoc/parser/ruby.rb - About 1 hr to fix

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

                                          def parse_meta_method_name comment, tk # :nodoc:
                                            if comment.text.sub!(/^# +:?method: *(\S*).*?\n/i, '') then
                                              return $1 unless $1.empty?
                                            end
                                        
                                        
                                        Severity: Minor
                                        Found in lib/rdoc/parser/ruby.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 parse_comment_ghost has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                          def parse_comment_ghost container, text, name, column, line_no, # :nodoc:
                                                                  comment
                                        Severity: Minor
                                        Found in lib/rdoc/parser/ruby.rb - About 45 mins to fix

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

                                            def look_for_directives_in container, comment
                                              @preprocess.handle comment, container do |directive, param|
                                                case directive
                                                when 'method', 'singleton-method',
                                                     'attr', 'attr_accessor', 'attr_reader', 'attr_writer' then
                                          Severity: Minor
                                          Found in lib/rdoc/parser/ruby.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 parse_attr has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                            def parse_attr(context, single, tk, comment)
                                              line_no = tk[:line_no]
                                          
                                              args = parse_symbol_arg 1
                                              if args.size > 0 then
                                          Severity: Minor
                                          Found in lib/rdoc/parser/ruby.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 parse_class_singleton has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                            def parse_class_singleton container, name, comment # :nodoc:
                                              other = @store.find_class_named name
                                          
                                              unless other then
                                                if name =~ /^::/ then
                                          Severity: Minor
                                          Found in lib/rdoc/parser/ruby.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 parse_class_regular has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                          Open

                                            def parse_class_regular container, declaration_context, single, # :nodoc:
                                                                    name_t, given_name, comment
                                          Severity: Minor
                                          Found in lib/rdoc/parser/ruby.rb - About 45 mins to fix

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

                                              def parse_meta_attr(context, single, tk, comment)
                                                args = parse_symbol_arg
                                                rw = "?"
                                            
                                                # If nodoc is given, don't document any of them
                                            Severity: Minor
                                            Found in lib/rdoc/parser/ruby.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

                                            Avoid deeply nested control flow statements.
                                            Open

                                                        comment << "\n" unless comment_body =~ /\n\z/
                                            Severity: Major
                                            Found in lib/rdoc/parser/ruby.rb - About 45 mins to fix

                                              Avoid deeply nested control flow statements.
                                              Open

                                                      if nest <= 0 and (next_tk.nil? || :on_nl == next_tk[:kind]) then
                                                        create_module_alias container, constant, rhs_name unless is_array_or_hash
                                                        break
                                                      end
                                              Severity: Major
                                              Found in lib/rdoc/parser/ruby.rb - About 45 mins to fix

                                                Avoid deeply nested control flow statements.
                                                Open

                                                            parse_comment container, tk, comment unless comment.empty?
                                                Severity: Major
                                                Found in lib/rdoc/parser/ruby.rb - About 45 mins to fix

                                                  Avoid deeply nested control flow statements.
                                                  Open

                                                              if comment_body.size > 1 && comment_body =~ /\n\z/ then
                                                                skip_tkspace_without_nl # leading spaces
                                                              end
                                                  Severity: Major
                                                  Found in lib/rdoc/parser/ruby.rb - About 45 mins to fix

                                                    Avoid deeply nested control flow statements.
                                                    Open

                                                                warn "Warning: yield outside of method" if container.document_self
                                                    Severity: Major
                                                    Found in lib/rdoc/parser/ruby.rb - About 45 mins to fix

                                                      Avoid deeply nested control flow statements.
                                                      Open

                                                                  if container.done_documenting then
                                                                    throw :eof if RDoc::TopLevel === container
                                                                    container.ongoing_visibility = save_visibility
                                                                  end
                                                      Severity: Major
                                                      Found in lib/rdoc/parser/ruby.rb - About 45 mins to fix

                                                        Avoid deeply nested control flow statements.
                                                        Open

                                                                    comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding
                                                        Severity: Major
                                                        Found in lib/rdoc/parser/ruby.rb - About 45 mins to fix

                                                          Avoid deeply nested control flow statements.
                                                          Open

                                                                      line_no = tk[:line_no] if comment.empty?
                                                          Severity: Major
                                                          Found in lib/rdoc/parser/ruby.rb - About 45 mins to fix

                                                            Avoid deeply nested control flow statements.
                                                            Open

                                                                        non_comment_seen = parse_comment container, tk, comment unless
                                                                          comment.empty?
                                                            Severity: Major
                                                            Found in lib/rdoc/parser/ruby.rb - About 45 mins to fix

                                                              Avoid deeply nested control flow statements.
                                                              Open

                                                                    elsif :on_nl == tk[:kind] then
                                                                      if nest <= 0 and RDoc::Parser::RipperStateLex.end?(tk) then
                                                                        unget_tk tk
                                                                        break
                                                                      end
                                                              Severity: Major
                                                              Found in lib/rdoc/parser/ruby.rb - About 45 mins to fix

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

                                                                  def create_attr container, single, name, rw, comment # :nodoc:
                                                                Severity: Minor
                                                                Found in lib/rdoc/parser/ruby.rb - About 35 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/ruby.rb - About 35 mins to fix

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

                                                                      def parse_meta_method_params container, single, meth, tk, comment # :nodoc:
                                                                    Severity: Minor
                                                                    Found in lib/rdoc/parser/ruby.rb - About 35 mins to fix

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

                                                                        def get_class_specification
                                                                          tk = peek_tk
                                                                          if tk.nil?
                                                                            return ''
                                                                          elsif :on_kw == tk[:kind] && 'self' == tk[:text]
                                                                      Severity: Minor
                                                                      Found in lib/rdoc/parser/ruby.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 parse_comment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                      Open

                                                                        def parse_comment container, tk, comment
                                                                          return parse_comment_tomdoc container, tk, comment if @markup == 'tomdoc'
                                                                          column  = tk[:char_no]
                                                                          line_no = comment.line.nil? ? tk[:line_no] : comment.line
                                                                      
                                                                      
                                                                      Severity: Minor
                                                                      Found in lib/rdoc/parser/ruby.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 skip_tkspace_comment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                      Open

                                                                        def skip_tkspace_comment(skip_nl = true)
                                                                          loop do
                                                                            skip_nl ? skip_tkspace : skip_tkspace_without_nl
                                                                            next_tk = peek_tk
                                                                            return if next_tk.nil? || (:on_comment != next_tk[:kind] and :on_embdoc != next_tk[:kind])
                                                                      Severity: Minor
                                                                      Found in lib/rdoc/parser/ruby.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 parse_rescue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                      Open

                                                                        def parse_rescue
                                                                          skip_tkspace_without_nl
                                                                      
                                                                          while tk = get_tk
                                                                            case tk[:kind]
                                                                      Severity: Minor
                                                                      Found in lib/rdoc/parser/ruby.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 parse_symbol_in_arg has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                                      Open

                                                                        def parse_symbol_in_arg
                                                                          tk = get_tk
                                                                          if :on_symbol == tk[:kind] then
                                                                            tk[:text].sub(/^:/, '')
                                                                          elsif :on_tstring == tk[:kind] then
                                                                      Severity: Minor
                                                                      Found in lib/rdoc/parser/ruby.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 res
                                                                      Severity: Major
                                                                      Found in lib/rdoc/parser/ruby.rb - About 30 mins to fix

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

                                                                          def get_bool
                                                                            skip_tkspace
                                                                            tk = get_tk
                                                                            if :on_kw == tk[:kind] && 'true' == tk[:text]
                                                                              true
                                                                        Severity: Minor
                                                                        Found in lib/rdoc/parser/ruby.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 parse_method_name_regular has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                        Open

                                                                          def parse_method_name_regular container, name_t # :nodoc:
                                                                            if :on_op == name_t[:kind] && (%w{* & [] []= <<}.include?(name_t[:text])) then
                                                                              name_t[:text]
                                                                            else
                                                                              unless [:on_kw, :on_const, :on_ident].include?(name_t[:kind]) then
                                                                        Severity: Minor
                                                                        Found in lib/rdoc/parser/ruby.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 parse_extend_or_include has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                        Open

                                                                          def parse_extend_or_include klass, container, comment # :nodoc:
                                                                            loop do
                                                                              skip_tkspace_comment
                                                                        
                                                                              name = get_included_module_with_optional_parens
                                                                        Severity: Minor
                                                                        Found in lib/rdoc/parser/ruby.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 parse_class has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                        Open

                                                                          def parse_class container, single, tk, comment
                                                                            line_no = tk[:line_no]
                                                                        
                                                                            declaration_context = container
                                                                            container, name_t, given_name, = get_class_or_module container
                                                                        Severity: Minor
                                                                        Found in lib/rdoc/parser/ruby.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 parse_visibility has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                        Open

                                                                          def parse_visibility(container, single, tk)
                                                                            vis_type, vis, singleton = get_visibility_information tk, single
                                                                        
                                                                            skip_tkspace_comment false
                                                                        
                                                                        
                                                                        Severity: Minor
                                                                        Found in lib/rdoc/parser/ruby.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 update_visibility has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                        Open

                                                                          def update_visibility container, vis_type, vis, singleton # :nodoc:
                                                                            new_methods = []
                                                                        
                                                                            case vis_type
                                                                            when 'module_function' then
                                                                        Severity: Minor
                                                                        Found in lib/rdoc/parser/ruby.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

                                                                        Identical blocks of code found in 2 locations. Consider refactoring.
                                                                        Open

                                                                                if :on_nl == end_token[:kind] and "\n" == tk[:text][-1] and
                                                                                  (!continue or (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) != 0) then
                                                                                  if method && method.block_params.nil? then
                                                                                    unget_tk tk
                                                                                    read_documentation_modifiers method, modifiers
                                                                        Severity: Minor
                                                                        Found in lib/rdoc/parser/ruby.rb and 1 other location - About 20 mins to fix
                                                                        lib/rdoc/parser/ruby.rb on lines 515..518

                                                                        Duplicated Code

                                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                        Tuning

                                                                        This issue has a mass of 27.

                                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                        Refactorings

                                                                        Further Reading

                                                                        Identical blocks of code found in 2 locations. Consider refactoring.
                                                                        Open

                                                                                if :on_nl == end_token[:kind] and "\n" == tk[:text][-1] and
                                                                                  (!continue or (tk[:state] & RDoc::Parser::RipperStateLex::EXPR_LABEL) != 0) then
                                                                                  break if !continue and nest <= 0
                                                                                end
                                                                        Severity: Minor
                                                                        Found in lib/rdoc/parser/ruby.rb and 1 other location - About 20 mins to fix
                                                                        lib/rdoc/parser/ruby.rb on lines 1664..1671

                                                                        Duplicated Code

                                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                        Tuning

                                                                        This issue has a mass of 27.

                                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                        Refactorings

                                                                        Further Reading

                                                                        There are no issues that match your filters.

                                                                        Category
                                                                        Status