Showing 10 of 23 total issues

Method print has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

      def print(output)
        output.puts "---- MEMORY THRESHOLD ----"
        output.puts "THRESHOLD: #{@threshold/1024} MB\n"

        output.puts "\n-- REQUESTS --\n" if @format == :verbose
Severity: Minor
Found in lib/oink/reports/memory_usage_report.rb - About 5 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 print has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

      def print(output)
        output.puts "---- OINK FOR ACTIVERECORD ----"
        output.puts "THRESHOLD: #{@threshold} Active Record objects per request\n"

        output.puts "\n-- REQUESTS --\n" if @format == :verbose
Severity: Minor
Found in lib/oink/reports/active_record_instantiation_report.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 process has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def process
      options = { :format => :short_summary, :type => :memory }

      op = OptionParser.new do |opts|
        opts.banner = "Usage: oink [options] files"
Severity: Minor
Found in lib/oink/cli.rb - About 1 hr to fix

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

          def print(output)
            output.puts "---- MEMORY THRESHOLD ----"
            output.puts "THRESHOLD: #{@threshold/1024} MB\n"
    
            output.puts "\n-- REQUESTS --\n" if @format == :verbose
    Severity: Minor
    Found in lib/oink/reports/memory_usage_report.rb - About 1 hr to fix

      Method print has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def print(output)
              output.puts "---- OINK FOR ACTIVERECORD ----"
              output.puts "THRESHOLD: #{@threshold} Active Record objects per request\n"
      
              output.puts "\n-- REQUESTS --\n" if @format == :verbose
      Severity: Minor
      Found in lib/oink/reports/active_record_instantiation_report.rb - About 1 hr to fix

        Method included has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def self.included(klass)
                klass.class_eval do
        
                  def self.reset_instance_type_count
                    self.instantiated_hash = {}
        Severity: Minor
        Found in lib/oink/instrumentation/active_record.rb - About 1 hr to fix

          Method print_summary has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def print_summary(output)
                  output.puts "\n-- SUMMARY --\n"
                  output.puts "Worst Requests:"
                  @bad_requests.each_with_index do |offender, index|
                    output.puts "#{index + 1}. #{offender.datetime}, #{offender.display_oink_number}, #{offender.action}"
          Severity: Minor
          Found in lib/oink/reports/base.rb - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                              if @format == :verbose
                                @pids[pid][:buffer].each { |b| output.puts b }
                                output.puts "---------------------------------------------------------------------"
                              end
            Severity: Major
            Found in lib/oink/reports/memory_usage_report.rb - About 45 mins to fix

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

                  def process
                    options = { :format => :short_summary, :type => :memory }
              
                    op = OptionParser.new do |opts|
                      opts.banner = "Usage: oink [options] files"
              Severity: Minor
              Found in lib/oink/cli.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 get_file_listing has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def get_file_listing(args)
                    listing = []
                    args.each do |file|
                      unless File.exist?(file)
                        raise "Could not find \"#{file}\""
              Severity: Minor
              Found in lib/oink/cli.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

              Severity
              Category
              Status
              Source
              Language