Showing 406 of 406 total issues

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

  private def get_string_tk(tk)
    string = tk[:text]
    state = nil
    kind = :on_tstring
    loop do
Severity: Minor
Found in lib/rdoc/parser/ripper_state_lex.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 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 build_paragraph has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def build_paragraph margin
    p :paragraph_start => margin if @debug

    paragraph = RDoc::Markup::Paragraph.new

Severity: Minor
Found in lib/rdoc/markup/parser.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 save_class has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def save_class klass
    full_name = klass.full_name

    FileUtils.mkdir_p class_path(full_name) unless @dry_run

Severity: Minor
Found in lib/rdoc/store.rb - About 1 hr to fix

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

          def get_squashed_tk
            if @buf.empty?
              tk = @tokens.shift
            else
              tk = @buf.shift
        Severity: Minor
        Found in lib/rdoc/parser/ripper_state_lex.rb - About 1 hr to fix

          Method read_file has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.read_file filename, encoding, force_transcode = false
              content = File.open filename, "rb" do |f| f.read end
              content.gsub!("\r\n", "\n") if RUBY_PLATFORM =~ /mswin|mingw/
          
              utf8 = content.sub!(/\A\xef\xbb\xbf/, '')
          Severity: Minor
          Found in lib/rdoc/encoding.rb - About 1 hr to fix

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

                for (var i=1, l = regexps.length; i < l; i++) {
                  if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
                    return false;
                };
            Severity: Major
            Found in lib/rdoc/generator/template/json_index/js/searcher.js and 2 other locations - About 1 hr to fix
            lib/rdoc/generator/template/json_index/js/searcher.js on lines 115..118
            lib/rdoc/generator/template/json_index/js/searcher.js on lines 128..131

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

            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 3 locations. Consider refactoring.
            Open

                for (var i=1, l = regexps.length; i < l; i++) {
                  if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
                    return false;
                };
            Severity: Major
            Found in lib/rdoc/generator/template/json_index/js/searcher.js and 2 other locations - About 1 hr to fix
            lib/rdoc/generator/template/json_index/js/searcher.js on lines 89..92
            lib/rdoc/generator/template/json_index/js/searcher.js on lines 128..131

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

            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 3 locations. Consider refactoring.
            Open

                for (var i=1, l = regexps.length; i < l; i++) {
                  if (!index.match(regexps[i]) && !longIndex.match(regexps[i]))
                    return false;
                };
            Severity: Major
            Found in lib/rdoc/generator/template/json_index/js/searcher.js and 2 other locations - About 1 hr to fix
            lib/rdoc/generator/template/json_index/js/searcher.js on lines 89..92
            lib/rdoc/generator/template/json_index/js/searcher.js on lines 115..118

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

            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

            Method get_symbol_tk has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private def get_symbol_tk(tk)
                is_symbol = true
                symbol_tk = Token.new(tk.line_no, tk.char_no, :on_symbol)
                if ":'" == tk[:text] or ':"' == tk[:text] or tk[:text].start_with?('%s')
                  tk1 = get_string_tk(tk)
            Severity: Minor
            Found in lib/rdoc/parser/ripper_state_lex.rb - About 1 hr to fix

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

                def self.can_parse_by_name file_name
                  _, parser = RDoc::Parser.parsers.find { |regexp,| regexp =~ file_name }
              
                  # The default parser must not parse binary files
                  ext_name = File.extname file_name
              Severity: Minor
              Found in lib/rdoc/parser.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 markup_code has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                def markup_code
                  return '' unless @token_stream
              
                  src = RDoc::TokenStream.to_html @token_stream
              
              
              Severity: Minor
              Found in lib/rdoc/generator/markup.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_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_file has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def parse_file filename
                  encoding = @options.encoding
                  filename = filename.encode encoding
              
                  @stats.add_file filename
              Severity: Minor
              Found in lib/rdoc/rdoc.rb - About 1 hr to fix

                Method init_ivars has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def init_ivars # :nodoc:
                    @dry_run = false
                    @embed_mixins = false
                    @exclude = %w[
                      ~\z \.orig\z \.rej\z \.bak\z
                Severity: Minor
                Found in lib/rdoc/options.rb - About 1 hr to fix

                  Method from_module has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def self.from_module class_type, mod
                      klass = class_type.new mod.name
                  
                      mod.comment_location.each do |comment, location|
                        klass.add_comment comment, location
                  Severity: Minor
                  Found in lib/rdoc/code_object/class_module.rb - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language