kaspernj/baza

View on GitHub

Showing 177 of 177 total issues

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

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

      def referenced_foreign_keys(args = {})
        sql = "
          SELECT
            TABLE_NAME,
            COLUMN_NAME,
    Severity: Major
    Found in lib/baza/driver/mysql/table.rb and 1 other location - About 1 hr to fix
    lib/baza/driver/mysql/table.rb on lines 98..133

    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 53.

    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
            TABLE_NAME,
            COLUMN_NAME,
    Severity: Major
    Found in lib/baza/driver/mysql/table.rb and 1 other location - About 1 hr to fix
    lib/baza/driver/mysql/table.rb on lines 136..171

    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 53.

    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 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

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

                    def sql_make_where(arr_terms, _driver = nil)
                      sql = ""
                  
                      first = true
                      arr_terms.each do |key, value|
                  Severity: Minor
                  Found in lib/baza/base_sql_driver.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 update_sql has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def update_sql
                      sql = "UPDATE OR IGNORE #{@db.quote_table(@table_name)} SET "
                  
                      first = true
                      @updates.each do |key, value|
                  Severity: Minor
                  Found in lib/baza/sql_queries/sqlite_upsert_duplicate_key.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 where_sql has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def where_sql
                      return if @wheres.empty?
                  
                      sql = " WHERE"
                  
                  
                  Severity: Minor
                  Found in lib/baza/sql_queries/select.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 clone_insert_from_original_table has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def clone_insert_from_original_table(newname, columns_list)
                      sql_clone = "INSERT INTO #{@db.quote_table(newname)} ("
                  
                      first = true
                      columns_list.each do |column_data|
                  Severity: Minor
                  Found in lib/baza/driver/pg/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 insert_sql has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def insert_sql
                      sql = "INSERT OR IGNORE INTO #{@db.quote_table(@table_name)} ("
                  
                      combined_data = @updates.merge(@terms)
                  
                  
                  Severity: Minor
                  Found in lib/baza/sql_queries/sqlite_upsert_duplicate_key.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 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def query(string, args = nil, &block)
                      if @debug
                        print "SQL: #{string}\n"
                  
                        if @debug.class.name == "Fixnum" && @debug >= 2
                  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 columns has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def columns(args = nil)
                      @db.columns
                      ret = []
                      sql = "SHOW FULL COLUMNS FROM #{@db.quote_table(name)}"
                      sql << " WHERE `Field` = '#{@db.esc(args.fetch(:name))}'" if args && args.key?(:name)
                  Severity: Minor
                  Found in lib/baza/driver/mysql/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 insert_sql has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def insert_sql
                      sql = "INSERT INTO #{@db.quote_table(@table_name)} ("
                  
                      combined_data = @updates.merge(@terms)
                  
                  
                  Severity: Minor
                  Found in lib/baza/sql_queries/postgres_upsert_duplicate_key.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 reconnect has 27 lines of code (exceeds 25 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 1 hr to fix

                    Method flush_real has 27 lines of code (exceeds 25 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 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language