kaspernj/baza

View on GitHub

Showing 177 of 177 total issues

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

  def self.args
    [{
      label: "Host",
      name: "host"
    }, {
Severity: Minor
Found in lib/baza/mysql_base_driver.rb and 1 other location - About 35 mins to fix
lib/baza/driver/mysql_java.rb on lines 23..42

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

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 data
    ret = {
      name: name,
      columns: [],
      indexes: []
Severity: Minor
Found in lib/baza/driver/sqlite3/table.rb and 1 other location - About 35 mins to fix
lib/baza/driver/mysql/table.rb on lines 304..319

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

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 4 locations. Consider refactoring.
Open

  def column(name)
    name = name.to_s

    col = @list.get(name)
    return col if col
Severity: Major
Found in lib/baza/driver/mysql/table.rb and 3 other locations - About 35 mins to fix
lib/baza/driver/mysql/table.rb on lines 214..224
lib/baza/driver/mysql/tables.rb on lines 35..45
lib/baza/driver/sqlite3/tables.rb on lines 14..24

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

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 4 locations. Consider refactoring.
Open

  def [](table_name)
    table_name = table_name.to_s

    ret = @list.get(table_name)
    return ret if ret
Severity: Major
Found in lib/baza/driver/sqlite3/tables.rb and 3 other locations - About 35 mins to fix
lib/baza/driver/mysql/table.rb on lines 52..62
lib/baza/driver/mysql/table.rb on lines 214..224
lib/baza/driver/mysql/tables.rb on lines 35..45

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

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 4 locations. Consider refactoring.
Open

  def index(name)
    name = name.to_s

    index = @indexes_list.get(name)
    return index if index
Severity: Major
Found in lib/baza/driver/mysql/table.rb and 3 other locations - About 35 mins to fix
lib/baza/driver/mysql/table.rb on lines 52..62
lib/baza/driver/mysql/tables.rb on lines 35..45
lib/baza/driver/sqlite3/tables.rb on lines 14..24

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

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 update_set_sql
    sql = "SET "

    first = true
    @updates.each do |key, value|
Severity: Minor
Found in lib/baza/sql_queries/postgres_upsert_duplicate_key.rb and 1 other location - About 30 mins to fix
lib/baza/sql_queries/postgres_upsert_duplicate_key.rb on lines 116..126

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

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 update_where_sql
    sql = "WHERE "

    first = true
    @terms.each do |key, value|
Severity: Minor
Found in lib/baza/sql_queries/postgres_upsert_duplicate_key.rb and 1 other location - About 30 mins to fix
lib/baza/sql_queries/postgres_upsert_duplicate_key.rb on lines 103..113

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

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

Avoid too many return statements within this method.
Open

      return Date.parse(result.string(java_count))
Severity: Major
Found in lib/baza/jdbc_result.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return nil
    Severity: Major
    Found in lib/baza/jdbc_result.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return result.object(java_count)
      Severity: Major
      Found in lib/baza/jdbc_result.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return Date.parse(value)
        Severity: Major
        Found in lib/baza/driver/sqlite3/result.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return Time.parse(result.string(java_count))
          Severity: Major
          Found in lib/baza/jdbc_result.rb - About 30 mins to fix

            Method foreign_keys has a Cognitive Complexity of 6 (exceeds 5 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 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 method_missing has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def method_missing(func_name, *args)
                if (match = func_name.to_s.match(/^(\S+)\?$/)) && @data.key?(match[1].to_sym)
                  if @data.fetch(match[1].to_sym) == "1" || @data.fetch(match[1].to_sym) == "yes"
                    return true
                  elsif @data.fetch(match[1].to_sym) == "0" || @data.fetch(match[1].to_sym) == "no"
            Severity: Minor
            Found in lib/baza/row.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 list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def list(args = {})
                where_args = {}
                where_args[:datname] = args.fetch(:name) if args[:name]
            
                database_list = [] unless block_given?
            Severity: Minor
            Found in lib/baza/driver/pg/databases.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 limit_sql has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def limit_sql
                unless @count
                  if @page
                    @per_page ||= 30
                    sql = "LIMIT #{@db.quote_value(@per_page)} OFFSET #{@per_page * (current_page - 1)}"
            Severity: Minor
            Found in lib/baza/sql_queries/select.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

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

              def initialize(args)
                @db = args.fetch(:db)
            
                data = args.fetch(:data)
            
            
            Severity: Minor
            Found in lib/baza/driver/mysql/foreign_key.rb and 1 other location - About 25 mins to fix
            lib/baza/driver/pg/foreign_key.rb on lines 2..11

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

            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 fetch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def fetch
                row = @results[@index += 1]
                return unless row
            
                if @types
            Severity: Minor
            Found in lib/baza/driver/sqlite3/result.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 foreign_keys has a Cognitive Complexity of 6 (exceeds 5 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 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 quote_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.quote_value(val)
                if val.class.name == "Fixnum" || val.is_a?(Integer)
                  val.to_s
                elsif val == nil
                  "NULL"
            Severity: Minor
            Found in lib/baza/base_sql_driver.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

            Severity
            Category
            Status
            Source
            Language