kaspernj/baza

View on GitHub

Showing 145 of 177 total issues

Method type has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def type
    unless @type
      if (match = @data.fetch(:type).match(/^([A-z]+)$/))
        @maxlength = false
        type = match[0].downcase.to_sym
Severity: Minor
Found in lib/baza/driver/sqlite3/column.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 add_order_sql has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def add_order_sql
    return if @args.nil?

    if @args[:orderby]
      @sql << " ORDER BY"
Severity: Minor
Found in lib/baza/commands/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 initialize has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize(args)
    @args = {}
    args.each do |key, value|
      @args[key.to_sym] = value
    end
Severity: Minor
Found in lib/baza/row.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 execute has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def execute
    sql = ""

    @io.each_line do |line|
      next if line.strip.blank?
Severity: Minor
Found in lib/baza/commands/importer.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 select_sql has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def select_sql
    sql = "SELECT"

    if @count
      sql << " COUNT(*) AS count"
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 has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def clone(newname, args = {})
    raise "Invalid name." if newname.to_s.strip.empty?

    sql = "CREATE TABLE #{@db.quote_table(newname)} ("
    first = true
Severity: Minor
Found in lib/baza/driver/mysql/table.rb - About 1 hr to fix

    Method change has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def change(data)
        newdata = data.clone
    
        newdata[:name] = name unless newdata.key?(:name)
        newdata[:type] = type unless newdata.key?(:type)
    Severity: Minor
    Found in lib/baza/driver/mysql/column.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 indexes has a Cognitive Complexity of 13 (exceeds 5 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

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

      def fetch
        if @enum
          begin
            ret = @enum.next
          rescue StopIteration
    Severity: Minor
    Found in lib/baza/driver/mysql/unbuffered_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 insert_or_handle_duplicate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def insert_or_handle_duplicate
        @db.insert(@table_name, @updates)
        return @db.last_id if @return_id
      rescue => e
        if (match = e.message.match(/UNIQUE constraint failed: #{Regexp.escape(@table_name)}\.(.+?)(:|\Z|\))/))
    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 change has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def change(data)
        newdata = data.clone
    
        newdata[:name] = name unless newdata.key?(:name)
        newdata[:type] = type unless newdata.key?(:type)
    Severity: Minor
    Found in lib/baza/driver/sqlite3/column.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 save_model! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def save_model!(model, args = {})
        raise ActiveRecord::InvalidRecord, model if (!args.key?(:validate) || args[:validate]) && !model.valid?
    
        attributes = {}
        model.changes.each do |column_name, value_array|
    Severity: Minor
    Found in lib/baza/driver/active_record.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 create_sql has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def create_sql(index_data, args)
        sql = ""
        sql << "CREATE" if args[:create] || !args.key?(:create)
    
        if index_data.is_a?(String) || index_data.is_a?(Symbol)
    Severity: Minor
    Found in lib/baza/driver/pg/create_index_sql_creator.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 copy has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def copy(args = {})
        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 1 hr to fix

      Method change has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def change(data)
          if data.key?(:name) && data.fetch(:name).to_s != name
            @db.query("#{alter_table_sql} RENAME #{@db.quote_column(name)} TO #{@db.quote_column(data.fetch(:name))}")
            @name = data.fetch(:name).to_s
          end
      Severity: Minor
      Found in lib/baza/driver/pg/column.rb - About 1 hr to fix

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

          def self.create_indexes(index_arr, args = {})
            db = args[:db]
        
            if args[:return_sql]
              sql = ""
        Severity: Minor
        Found in lib/baza/driver/mysql/table.rb - About 1 hr to fix

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