rapid7/metasploit-framework

View on GitHub
lib/rbmysql.rb

Summary

Maintainability
F
4 days
Test Coverage

File rbmysql.rb has 686 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class RbMysql

  require "rbmysql/constants"
  require "rbmysql/error"
  require "rbmysql/charset"
Severity: Major
Found in lib/rbmysql.rb - About 1 day to fix

    Class RbMysql has 51 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class RbMysql
    
      require "rbmysql/constants"
      require "rbmysql/error"
      require "rbmysql/charset"
    Severity: Major
    Found in lib/rbmysql.rb - About 7 hrs to fix

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

          def fetch
            row = @result.fetch
            return row unless @bind_result
            row.zip(@bind_result).map do |col, type|
              if col.nil?
      Severity: Minor
      Found in lib/rbmysql.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 query has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def query(str, &block)
          check_connection
          @fields = nil
          begin
            nfields = @protocol.query_command str
      Severity: Minor
      Found in lib/rbmysql.rb - About 2 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 fetch has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def fetch
            row = @result.fetch
            return row unless @bind_result
            row.zip(@bind_result).map do |col, type|
              if col.nil?
      Severity: Minor
      Found in lib/rbmysql.rb - About 1 hr to fix

        Method connect has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def connect(host=nil, user=nil, passwd=nil, db=nil, port=nil, socket=nil, flag=0)
            if flag & CLIENT_COMPRESS != 0
              warn 'unsupported flag: CLIENT_COMPRESS' if $VERBOSE
              flag &= ~CLIENT_COMPRESS
            end
        Severity: Minor
        Found in lib/rbmysql.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 initialize has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def initialize(year=0, month=0, day=0, hour=0, minute=0, second=0, neg=false, second_part=0)
        Severity: Major
        Found in lib/rbmysql.rb - About 1 hr to fix

          Method connect has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def connect(host=nil, user=nil, passwd=nil, db=nil, port=nil, socket=nil, flag=0)
          Severity: Major
          Found in lib/rbmysql.rb - About 50 mins to fix

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

                def fetch_hash(with_table=nil)
                  row = fetch
                  return nil unless row
                  if with_table and @fieldname_with_table.nil?
                    @fieldname_with_table = @fields.map{|f| [f.table, f.name].join(".")}
            Severity: Minor
            Found in lib/rbmysql.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 to_s has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def to_s
                  if @date_flag
                    sprintf "%04d-%02d-%02d", year, mon, day
                  elsif year == 0 and mon == 0 and day == 0
                    h = neg ? hour * -1 : hour
            Severity: Minor
            Found in lib/rbmysql.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 calculate_field_max_length has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def calculate_field_max_length
                  max_length = Array.new(@fields.size, 0)
                  @records.each_with_index do |rec, i|
                    rec = @records[i] = rec.to_a if rec.is_a? RawRecord
                    max_length.each_index do |j|
            Severity: Minor
            Found in lib/rbmysql.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

            Method execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def execute(*values)
                  raise ClientError, "not prepared" unless @param_count
                  raise ClientError, "parameter count mismatch" if values.length != @param_count
                  values = values.map{|v| @charset.convert v}
                  begin
            Severity: Minor
            Found in lib/rbmysql.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