archan937/clickhouse

View on GitHub

Showing 339 of 339 total issues

Module has too many lines. [125/100]
Open

    module Query

      def execute(query, body = nil)
        body = post(query, body)
        body.empty? ? true : body
Severity: Minor
Found in lib/clickhouse/connection/query.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Module has too many lines. [103/100]
Open

    module Client
      include ActiveSupport::NumberHelper

      def connect!
        ping! unless connected?
Severity: Minor
Found in lib/clickhouse/connection/client.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for initialize is too high. [28.79/15]
Open

    def initialize(config)
      config = config.dup
      urls = config.delete(:urls) || config.delete("urls")
      urls.collect!{|url| ::Clickhouse::Utils.normalize_url(url)}

Severity: Minor
Found in lib/clickhouse/cluster.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [20/10]
Open

        def parse_value(type, value)
          if value
            case type
            when "UInt8", "UInt16", "UInt32", "UInt64", "Int8", "Int16", "Int32", "Int64"
              parse_int_value value

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [20/10]
Open

    def initialize(config)
      config = config.dup
      urls = config.delete(:urls) || config.delete("urls")
      urls.collect!{|url| ::Clickhouse::Utils.normalize_url(url)}

Severity: Minor
Found in lib/clickhouse/cluster.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [17/10]
Open

      def write_log(duration, query, stats)
        duration = number_to_human_duration(duration)

        rows,
        elapsed,
Severity: Minor
Found in lib/clickhouse/connection/client.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for request is too high. [21.19/15]
Open

      def request(method, query, body = nil)
        connect!
        query = query.strip
        start = Time.now

Severity: Minor
Found in lib/clickhouse/connection/client.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for parse_stats is too high. [21.56/15]
Open

      def parse_stats(response)
        return {} unless response.is_a?(Hash)

        options = {:locale => :en, :precision => 2, :significant => false}
        stats = response["statistics"].merge("rows" => response["rows"])
Severity: Minor
Found in lib/clickhouse/connection/client.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [16/10]
Open

      def to_condition_statements(value)
        value.collect do |attr, val|
          if val == :empty
            "empty(#{attr})"
          elsif val.is_a?(Range)
Severity: Minor
Found in lib/clickhouse/connection/query.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Class Connection has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Connection
    module Query

      def execute(query, body = nil)
        body = post(query, body)
Severity: Minor
Found in lib/clickhouse/connection/query.rb - About 2 hrs to fix

    Method has too many lines. [14/10]
    Open

          def request(method, query, body = nil)
            connect!
            query = query.strip
            start = Time.now
    
    
    Severity: Minor
    Found in lib/clickhouse/connection/client.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Cyclomatic complexity for parse_value is too high. [9/6]
    Open

            def parse_value(type, value)
              if value
                case type
                when "UInt8", "UInt16", "UInt32", "UInt64", "Int8", "Int16", "Int32", "Int64"
                  parse_int_value value

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    Assignment Branch Condition size for to_condition_statements is too high. [17.46/15]
    Open

          def to_condition_statements(value)
            value.collect do |attr, val|
              if val == :empty
                "empty(#{attr})"
              elsif val.is_a?(Range)
    Severity: Minor
    Found in lib/clickhouse/connection/query.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [12/10]
    Open

        def normalize_config(config)
          config = config.inject({}) do |hash, (key, value)|
            hash[key.to_sym] = value
            hash
          end
    Severity: Minor
    Found in lib/clickhouse/connection.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Assignment Branch Condition size for to_select_query is too high. [16.52/15]
    Open

          def to_select_query(options)
            to_select_options(options).collect do |(key, value)|
              next if value.nil? || (value.respond_to?(:empty?) && value.empty?)
    
              statement = [key.to_s.upcase]
    Severity: Minor
    Found in lib/clickhouse/connection/query.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for to_sql is too high. [16.25/15]
    Open

            def to_sql
              raise Clickhouse::InvalidQueryError, "Missing table engine" unless @engine
              length = @columns.collect{|x| x[0].to_s.size}.max
    
              sql = []

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method generate_csv has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def generate_csv(rows, names = nil)
            hashes = rows[0].is_a?(Hash)
    
            if hashes
              names ||= rows[0].keys
    Severity: Minor
    Found in lib/clickhouse/connection/query.rb - About 45 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 to_select_query has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def to_select_query(options)
            to_select_options(options).collect do |(key, value)|
              next if value.nil? || (value.respond_to?(:empty?) && value.empty?)
    
              statement = [key.to_s.upcase]
    Severity: Minor
    Found in lib/clickhouse/connection/query.rb - About 35 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

    Block has too many lines. [27/25]
    Open

    Gem::Specification.new do |gem|
      gem.authors       = ["Paul Engel"]
      gem.email         = ["pm_engel@icloud.com"]
      gem.summary       = %q{A Ruby database driver for ClickHouse (also Clickhouse CLI and web GUI included)}
      gem.description   = %q{A Ruby database driver for ClickHouse (also Clickhouse CLI and web GUI included)}
    Severity: Minor
    Found in clickhouse.gemspec by rubocop

    This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

    Method to_condition_statements has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def to_condition_statements(value)
            value.collect do |attr, val|
              if val == :empty
                "empty(#{attr})"
              elsif val.is_a?(Range)
    Severity: Minor
    Found in lib/clickhouse/connection/query.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