kaspernj/baza

View on GitHub

Showing 177 of 177 total issues

Method clone has a Cognitive Complexity of 12 (exceeds 5 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

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 12 (exceeds 5 allowed). Consider refactoring.
Open

  def query(str)
    str = str.to_s
    str = str.force_encoding("UTF-8") if encoding == "utf8" && str.respond_to?(:force_encoding)
    tries = 0

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

  def query(str)
    str = str.to_s
    str = str.force_encoding("UTF-8") if @encoding == "utf8" && str.respond_to?(:force_encoding)
    tries = 0

Severity: Minor
Found in lib/baza/driver/mysql.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 data_sql has 34 lines of code (exceeds 25 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/pg/columns.rb - About 1 hr to fix

    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

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

        def create_foreign_key(args)
          fk_name = args[:name]
          fk_name ||= "fk_#{table_name}_#{name}"
      
          other_column = args.fetch(:column)
      Severity: Major
      Found in lib/baza/driver/mysql/column.rb and 1 other location - About 1 hr to fix
      lib/baza/driver/pg/column.rb on lines 14..30

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 55.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

        def create_foreign_key(args)
          fk_name = args[:name]
          fk_name ||= "fk_#{table_name}_#{name}"
      
          other_column = args.fetch(:column)
      Severity: Major
      Found in lib/baza/driver/pg/column.rb and 1 other location - About 1 hr to fix
      lib/baza/driver/mysql/column.rb on lines 18..34

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 55.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                      def referenced_foreign_keys(args = {})
                        sql = "
                          SELECT
                            tc.constraint_name,
                            tc.table_name,
                    Severity: Major
                    Found in lib/baza/driver/pg/table.rb and 1 other location - About 1 hr to fix
                    lib/baza/driver/pg/table.rb on lines 79..119

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 54.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 2 locations. Consider refactoring.
                    Open

                      def foreign_keys(args = {})
                        sql = "
                          SELECT
                            tc.constraint_name,
                            tc.table_name,
                    Severity: Major
                    Found in lib/baza/driver/pg/table.rb and 1 other location - About 1 hr to fix
                    lib/baza/driver/pg/table.rb on lines 122..162

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 54.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    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
                      Severity
                      Category
                      Status
                      Source
                      Language