troessner/reek

View on GitHub

Showing 77 of 77 total issues

Method scan_tokens has a Cognitive Complexity of 273 (exceeds 5 allowed). Consider refactoring.
Open

    def scan_tokens tokens, options
      last_token_dot = false
      value_expected = true
      heredocs = nil
      last_state = nil
Severity: Minor
Found in samples/smelly_source/ruby.rb - About 5 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

File optparse.rb has 869 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class OptionParser
  # :stopdoc:
  RCSID = %w$Id: optparse.rb 11798 2007-02-20 06:53:16Z knu $[1..-1].each {|s| s.freeze}.freeze
  Version = (RCSID[1].split('.').collect {|s| s.to_i}.extend(Comparable).freeze if RCSID[1])
  LastModified = (Time.gm(*RCSID[2, 2].join('-').scan(/\d+/).collect {|s| s.to_i}) if RCSID[2])
Severity: Major
Found in samples/smelly_source/optparse.rb - About 2 days to fix

    Method make_switch has a Cognitive Complexity of 94 (exceeds 5 allowed). Consider refactoring.
    Open

      def make_switch(opts, block = nil)
        short, long, nolong, style, pattern, conv, not_pattern, not_conv, not_style = [], [], []
        ldesc, sdesc, desc, arg = [], [], []
        default_style = Switch::NoArgument
        default_pattern = nil
    Severity: Minor
    Found in samples/smelly_source/optparse.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_in_order has a Cognitive Complexity of 88 (exceeds 5 allowed). Consider refactoring.
    Open

      def parse_in_order(argv = default_argv, setter = nil, &nonopt)  # :nodoc:
        opt, arg, sw, val, rest = nil
        nonopt ||= proc {|arg| throw :terminate, arg}
        argv.unshift(arg) if arg = catch(:terminate) {
          while arg = argv.shift
    Severity: Minor
    Found in samples/smelly_source/optparse.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

    File redcloth.rb has 720 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class RedCloth < String
    
        VERSION = '3.0.4'
        DEFAULT_RULES = [:textile, :markdown]
    
    
    Severity: Major
    Found in samples/smelly_source/redcloth.rb - About 1 day to fix

      Method build has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
      Open

          def build
            so_name = self.so_name
            so_exists = File.file? so_name
            unless so_exists and File.mtime(rb_file) < File.mtime(so_name) then
      
      
      Severity: Minor
      Found in samples/smelly_source/inline.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 scan_tokens has 283 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def scan_tokens tokens, options
            last_token_dot = false
            value_expected = true
            heredocs = nil
            last_state = nil
      Severity: Major
      Found in samples/smelly_source/ruby.rb - About 1 day to fix

        Class OptionParser has 59 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class OptionParser
          # :stopdoc:
          RCSID = %w$Id: optparse.rb 11798 2007-02-20 06:53:16Z knu $[1..-1].each {|s| s.freeze}.freeze
          Version = (RCSID[1].split('.').collect {|s| s.to_i}.extend(Comparable).freeze if RCSID[1])
          LastModified = (Time.gm(*RCSID[2, 2].join('-').scan(/\d+/).collect {|s| s.to_i}) if RCSID[2])
        Severity: Major
        Found in samples/smelly_source/optparse.rb - About 1 day to fix

          File inline.rb has 440 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require "rbconfig"
          require "digest/md5"
          require 'fileutils'
          require 'rubygems'
          
          
          Severity: Minor
          Found in samples/smelly_source/inline.rb - About 6 hrs to fix

            Method rip_offtags has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
            Open

                def rip_offtags( text )
                    if text =~ /<.*>/
                        ## strip and encode <pre> content
                        codepre, used_offtags = 0, {}
                        text.gsub!( OFFTAG_MATCH ) do |line|
            Severity: Minor
            Found in samples/smelly_source/redcloth.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 block_textile_lists has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
            Open

                def block_textile_lists( text ) 
                    text.gsub!( LISTS_RE ) do |match|
                        lines = match.split( /\n/ )
                        last_line = -1
                        depth = []
            Severity: Minor
            Found in samples/smelly_source/redcloth.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

            Class RedCloth has 44 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class RedCloth < String
            
                VERSION = '3.0.4'
                DEFAULT_RULES = [:textile, :markdown]
            
            
            Severity: Minor
            Found in samples/smelly_source/redcloth.rb - About 6 hrs to fix

              Method complete has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
              Open

                  def complete(key, icase = false, pat = nil)
                    pat ||= Regexp.new('\A' + Regexp.quote(key).gsub(/\w+\b/, '\&\w*'),
                                       icase)
                    canon, sw, k, v, cn = nil
                    candidates = []
              Severity: Minor
              Found in samples/smelly_source/optparse.rb - About 4 hrs to fix

              Cognitive Complexity

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

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

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

              Further reading

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

                  def blocks( text, deep_code = false )
                      text.replace( text.split( BLOCKS_GROUP_RE ).collect do |blk|
                          plain = blk !~ /\A[#*> ]/
              
                          # skip blocks that are complex HTML
              Severity: Minor
              Found in samples/smelly_source/redcloth.rb - About 4 hrs to fix

              Cognitive Complexity

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

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

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

              Further reading

              Method make_switch has 109 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def make_switch(opts, block = nil)
                  short, long, nolong, style, pattern, conv, not_pattern, not_conv, not_style = [], [], []
                  ldesc, sdesc, desc, arg = [], [], []
                  default_style = Switch::NoArgument
                  default_pattern = nil
              Severity: Major
              Found in samples/smelly_source/optparse.rb - About 4 hrs to fix

                Method clean_html has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                Open

                    def clean_html( text, tags = BASIC_TAGS )
                        text.gsub!( /<!\[CDATA\[/, '' )
                        text.gsub!( /<(\/*)(\w+)([^>]*)>/ ) do
                            raw = $~
                            tag = raw[2].downcase
                Severity: Minor
                Found in samples/smelly_source/redcloth.rb - About 4 hrs to fix

                Cognitive Complexity

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

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

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

                Further reading

                Method build has 106 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def build
                      so_name = self.so_name
                      so_exists = File.file? so_name
                      unless so_exists and File.mtime(rb_file) < File.mtime(so_name) then
                
                
                Severity: Major
                Found in samples/smelly_source/inline.rb - About 4 hrs to fix

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

                    class ContextBuilder
                      attr_reader :context_tree
                  
                      def initialize(syntax_tree)
                        @exp = syntax_tree
                  Severity: Minor
                  Found in lib/reek/context_builder.rb - About 4 hrs to fix

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

                        def block_textile_table( text ) 
                            text.gsub!( TABLE_RE ) do |matches|
                    
                                tatts, fullrow = $~[1..2]
                                tatts = pba( tatts, 'table' )
                    Severity: Minor
                    Found in samples/smelly_source/redcloth.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 generate has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def generate(src, options={})
                          options = {:expand_types=>options} unless Hash === options
                    
                          expand_types = options[:expand_types]
                          singleton = options[:singleton]
                    Severity: Minor
                    Found in samples/smelly_source/inline.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

                    Severity
                    Category
                    Status
                    Source
                    Language