troessner/reek

View on GitHub
samples/smelly_source/inline.rb

Summary

Maintainability
F
4 days
Test Coverage

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

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

      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

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

        class C
      
          protected unless $TESTING
      
          MAGIC_ARITY_THRESHOLD = 15
      Severity: Minor
      Found in samples/smelly_source/inline.rb - About 2 hrs to fix

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

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

              def parse_signature(src, raw=false)
          
                sig = self.strip_comments(src)
                # strip preprocessor directives
                sig.gsub!(/^\s*\#.*(\\\n.*)*/, '')
          Severity: Minor
          Found in samples/smelly_source/inline.rb - About 1 hr to fix

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

              def inline(lang = :C, options={})
                case options
                when TrueClass, FalseClass then
                  warn "WAR\NING: 2nd argument to inline is now a hash, changing to {:testing=>#{options}}" unless options
                  options = { :testing => options  }
            Severity: Minor
            Found in samples/smelly_source/inline.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 rootdir has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.rootdir
                env = ENV['INLINEDIR'] || ENV['HOME']
            
                # in case both INLINEDIR and HOME aren't defined, and under Windows
                # default to HOMEDRIVE + HOMEPATH values
            Severity: Minor
            Found in samples/smelly_source/inline.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_signature has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def parse_signature(src, raw=false)
            
                  sig = self.strip_comments(src)
                  # strip preprocessor directives
                  sig.gsub!(/^\s*\#.*(\\\n.*)*/, '')
            Severity: Minor
            Found in samples/smelly_source/inline.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def initialize(mod)
                  raise ArgumentError, "Class/Module arg is required" unless Module === mod
                  # new (but not on some 1.8s) -> inline -> real_caller|eval
                  stack = caller
                  meth = stack.shift until meth =~ /in .(inline|test_|setup)/ or stack.empty?
            Severity: Minor
            Found in samples/smelly_source/inline.rb - About 25 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

            There are no issues that match your filters.

            Category
            Status