Showing 406 of 406 total issues

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

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

    utf8 = content.sub!(/\A\xef\xbb\xbf/, '')
Severity: Minor
Found in lib/rdoc/encoding.rb - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

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

    until @tokens.empty? do
      type, data, column, = get
Severity: Minor
Found in lib/rdoc/markup/parser.rb - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

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

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

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

      def setup_output_dir(dir, force)
        flag_file = output_flag_file dir
    
        last = {}
    
    
    Severity: Minor
    Found in lib/rdoc/rdoc.rb - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method 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 handle has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      def handle text, code_object = nil, &block
        first_line = 1
        if RDoc::Comment === text then
          comment = text
          text = text.text
    Severity: Minor
    Found in lib/rdoc/markup/pre_process.rb - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

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

      def override map # :nodoc:
        if map.has_key?('encoding')
          encoding = map['encoding']
          @encoding = encoding ? Encoding.find(encoding) : encoding
        end
    Severity: Minor
    Found in lib/rdoc/options.rb - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    File rdoc.rb has 305 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

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

        def parse_call_parameters(tk)
          end_token = case tk[:kind]
                      when :on_lparen
                        :on_rparen
                      when :on_rparen
      Severity: Minor
      Found in lib/rdoc/parser/ruby.rb - About 3 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

        def handle_meta_method_comment(comment, node)
          is_call_node = node.is_a?(Prism::CallNode)
          singleton_method = false
          visibility = @visibility
          attributes = rw = line_no = method_name = nil
      Severity: Minor
      Found in lib/rdoc/parser/prism_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

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

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

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

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

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

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

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

              def report_methods cm
                return if cm.method_list.empty?
            
                report = []
            
            
            Severity: Minor
            Found in lib/rdoc/stats.rb - About 3 hrs to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

              def handle_class_module(var_name, type, class_name, parent, in_module)
                parent_name = @known_classes[parent] || parent
            
                if in_module then
                  enclosure = @classes[in_module] || @store.find_c_enclosure(in_module)
            Severity: Minor
            Found in lib/rdoc/parser/c.rb - About 3 hrs to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

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

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

                for (var i=0, l = regexps.length; i < l; i++) {
                  result.title = result.title.replace(regexps[i], highlighters[i]);
                  result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
                };
            Severity: Major
            Found in lib/rdoc/generator/template/json_index/js/searcher.js and 1 other location - About 3 hrs to fix
            lib/rdoc/generator/template/json_index/js/searcher.js on lines 161..164

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

            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

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

                for (var i=1, l = regexps.length; i < l; i++) {
                  result.title = result.title.replace(regexps[i], highlighters[i]);
                  result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
                };
            Severity: Major
            Found in lib/rdoc/generator/template/json_index/js/searcher.js and 1 other location - About 3 hrs to fix
            lib/rdoc/generator/template/json_index/js/searcher.js on lines 139..142

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

            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

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

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

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

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