kaspernj/baza

View on GitHub

Showing 145 of 177 total issues

Method list has 32 lines of code (exceeds 25 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

    Method tables has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def tables(args = {})
        tables_list = [] unless block_given?
    
        where_args = {
          table_catalog: name,
    Severity: Minor
    Found in lib/baza/driver/pg/database.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 insert_multi has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def insert_multi(tablename, arr_hashes, args = {})
        return false if arr_hashes.empty?
    
        if @driver.respond_to?(:insert_multi)
          if args && args[:return_sql]
    Severity: Minor
    Found in lib/baza/db.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 translate_values_with_types has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def translate_values_with_types(values)
        values.collect!.with_index do |value, count|
          type_sym = types[count]
    
          if type_sym == :int
    Severity: Minor
    Found in lib/baza/driver/pg/result.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 foreign_keys has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def foreign_keys(args = {})
        sql = "
          SELECT
            tc.constraint_name,
            tc.table_name,
    Severity: Minor
    Found in lib/baza/driver/pg/table.rb - About 1 hr to fix

      Method create has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create(table_name, columns:, indexes: nil, return_sql: false, temp: false)
          table_name = table_name.to_s
          raise "Invalid table name: #{table_name}" if table_name.strip.empty?
          raise "No columns was given for '#{table_name}'." if !columns || columns.empty?
      
      
      Severity: Minor
      Found in lib/baza/driver/pg/tables.rb - About 1 hr to fix

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

          Method copy_to has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def copy_to(db, args = {})
              debug = args[:debug]
              raise "No tables given." unless data[:tables]
          
              data[:tables].each do |table|
          Severity: Minor
          Found in lib/baza/db.rb - About 1 hr to fix

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

              Method from_active_record_connection has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.from_active_record_connection(connection)
                  if connection.class.name.include?("Mysql2Adapter")
                    connection = connection.instance_variable_get(:@connection)
              
                    config = connection.instance_variable_get(:@query_options)
              Severity: Minor
              Found in lib/baza/cloner.rb - About 1 hr to fix

                Method referenced_foreign_keys has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def referenced_foreign_keys(args = {})
                    sql = "
                      SELECT
                        tc.constraint_name,
                        tc.table_name,
                Severity: Minor
                Found in lib/baza/driver/pg/table.rb - About 1 hr to fix

                  Method clone has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def clone(newname, args = nil)
                      raise "Invalid name." if newname.to_s.strip.empty?
                  
                      sql = "CREATE TABLE `#{newname}` ("
                      first = true
                  Severity: Minor
                  Found in lib/baza/driver/sqlite3/table.rb - About 1 hr to fix

                    Method create_indexes has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def create_indexes(index_arr, args = nil)
                        ret = [] if args && args[:return_sql]
                    
                        index_arr.each do |index_data|
                          if index_data.is_a?(String) || index_data.is_a?(Symbol)
                    Severity: Minor
                    Found in lib/baza/driver/sqlite3/table.rb - About 1 hr to fix

                      Method sql has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def sql
                          sql = ""
                          first = true
                      
                          @indexes.each do |index_data|
                      Severity: Minor
                      Found in lib/baza/driver/mysql/sql/create_indexes.rb - About 1 hr to fix

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

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

                            def indexes
                              @db.indexes
                              ret = [] unless block_given?
                          
                              @db.query("PRAGMA index_list(#{@db.quote_table(name)})") do |d_indexes|
                          Severity: Minor
                          Found in lib/baza/driver/sqlite3/table.rb - About 1 hr to fix

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

                              def initialize(args)
                                @args = args
                                @db = args.fetch(:db)
                                @queries = []
                                @inserts = {}
                            Severity: Minor
                            Found in lib/baza/query_buffer.rb - About 1 hr to fix

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

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

                                  def foreign_keys(args = {})
                                    sql = "
                                      SELECT
                                        TABLE_NAME,
                                        COLUMN_NAME,
                                Severity: Minor
                                Found in lib/baza/driver/mysql/table.rb - About 1 hr to fix

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

                                    def referenced_foreign_keys(args = {})
                                      sql = "
                                        SELECT
                                          TABLE_NAME,
                                          COLUMN_NAME,
                                  Severity: Minor
                                  Found in lib/baza/driver/mysql/table.rb - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language