kaspernj/baza

View on GitHub

Showing 145 of 177 total issues

Method create has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def create(name, columns:, indexes: nil, return_sql: false)
    raise "No columns given" if !columns || columns.empty?

    sql = "CREATE TABLE `#{name}` ("

Severity: Minor
Found in lib/baza/driver/sqlite3/tables.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 sql has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def sql # rubocop:disable Metrics/AbcSize
    data.each_key do |key|
      raise "Invalid key: '#{key}' (#{key.class.name})." unless DATA_SQL_ALLOWED_KEYS.include?(key)
    end

Severity: Minor
Found in lib/baza/driver/mysql/sql/column.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 from_object has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def self.from_object(args)
    args = {object: args} unless args.is_a?(Hash)
    raise "No :object was given." unless args[:object]

    Baza::Db.drivers.each do |driver|
Severity: Minor
Found in lib/baza/db.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

Class Tiny has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

class Baza::Driver::Tiny < Baza::BaseSqlDriver
  SEPARATOR_DATABASE = "]".freeze
  SEPARATOR_TABLE = "]".freeze
  SEPARATOR_COLUMN = "]".freeze
  SEPARATOR_INDEX = "]".freeze
Severity: Minor
Found in lib/baza/driver/tiny.rb - About 2 hrs to fix

    Class Table has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Baza::Driver::Mysql::Table < Baza::Table
      attr_reader :list, :name
    
      def initialize(args)
        @db = args.fetch(:db)
    Severity: Minor
    Found in lib/baza/driver/mysql/table.rb - About 2 hrs to fix

      Method flush_real has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def flush_real(db = nil)
          return nil if @queries_count <= 0
          db = @db if db == nil
      
          @lock.synchronize do
      Severity: Minor
      Found in lib/baza/query_buffer.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 data_sql has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def data_sql(data)
          data.each_key do |key|
            raise "Invalid key: '#{key}' (#{key.class.name})." unless DATA_SQL_ALLOWED_KEYS.include?(key)
          end
      
      
      Severity: Minor
      Found in lib/baza/driver/mysql/columns.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 initialize has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def initialize(db)
          @db = db
          @conn = @db.opts.fetch(:conn)
      
          raise "No conn given" unless @conn
      Severity: Minor
      Found in lib/baza/driver/active_record.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 list has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def list(args = {})
          ret = [] unless block_given?
      
          @list_mutex.synchronize do
            tables_args = {type: "table"}
      Severity: Minor
      Found in lib/baza/driver/sqlite3/tables.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 insert_multi has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def insert_multi(tablename, arr_hashes, args = {})
          sql = "INSERT INTO `#{tablename}` ("
      
          first = true
          if args && args[:keys]
      Severity: Major
      Found in lib/baza/driver/mysql_java.rb - About 2 hrs to fix

        Method insert_multi has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def insert_multi(tablename, arr_hashes, args = {})
            sql = "INSERT INTO `#{tablename}` ("
        
            first = true
            if args && args[:keys]
        Severity: Major
        Found in lib/baza/mysql_base_driver.rb - About 2 hrs to fix

          Method initialize has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

            def initialize(args, &block)
              @args = args
              @db = args.fetch(:db)
              @ids = []
              @debug = @args[:debug]
          Severity: Minor
          Found in lib/baza/idquery.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 indexes has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def indexes(args = nil, &blk)
              ret = {}
          
              sql = "SHOW INDEX FROM #{@db.quote_table(name)}"
              sql << " WHERE #{@db.quote_column("Key_name")} = #{@db.quote_value(args.fetch(:name))}" if args && args.key?(:name)
          Severity: Minor
          Found in lib/baza/driver/mysql/table.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 types has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def types
              unless @types
                @types = []
                @result.fields.length.times do |count|
                  type_num = @result.ftype(count)
          Severity: Minor
          Found in lib/baza/driver/pg/result.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 reconnect has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def reconnect
              @mutex.synchronize do
                require "mysql2" unless ::Object.const_defined?(:Mysql2)
          
                args = {
          Severity: Minor
          Found in lib/baza/driver/mysql2.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 a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def fetch
              return nil unless @args
          
              if @res
                data = @res.fetch if @res
          Severity: Minor
          Found in lib/baza/idquery.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 create_column_programmatic has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def create_column_programmatic(col_data)
              temp_name = "temptable_#{Time.now.to_f.to_s.hash}"
              clone(temp_name)
              cols_cur = columns
              @db.query("DROP TABLE `#{name}`")
          Severity: Minor
          Found in lib/baza/driver/sqlite3/table.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 sql has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def sql
              sql = "CREATE"
              sql << " TEMPORARY" if @temporary
              sql << " TABLE #{Baza::Driver::Mysql.quote_table(@name)} ("
          
          
          Severity: Minor
          Found in lib/baza/driver/mysql/sql/create_table.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 initialize has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def initialize(db)
              @db = db
              @conn = @db.opts.fetch(:conn)
          
              raise "No conn given" unless @conn
          Severity: Major
          Found in lib/baza/driver/active_record.rb - About 2 hrs to fix

            Method list has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def list(database: nil, name: nil)
                ret = [] unless block_given?
            
                where_args = {}
                where_args["TABLE_NAME"] = name if name
            Severity: Minor
            Found in lib/baza/driver/mysql/tables.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

            Severity
            Category
            Status
            Source
            Language