cequel/cequel

View on GitHub

Showing 473 of 473 total issues

Method sync_schema has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def sync_schema
        record_classes.each do |record_class|
          begin
            record_class.synchronize_schema
            unless options[:quiet]
Severity: Minor
Found in lib/cequel/spec_support/preparation.rb - About 55 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 []= has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def []=(*args)
        if args[0].is_a?(Integer) && args.count == 2
          # single element set/replace
          elem = cast_element(args[1])

Severity: Minor
Found in lib/cequel/record/collection.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 client_options has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def client_options
        {hosts: hosts, port: port}.tap do |options|
          options.merge!(credentials) if credentials
          options.merge!(ssl_config) if ssl_config
          options.merge!(compression: client_compression) if client_compression
Severity: Minor
Found in lib/cequel/metal/keyspace.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

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

      define_method :execute_with_options_with_newrelic do |statement, options|

        operation = nil
        statement_txt = nil
        statement_words = nil

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

        def key(name, type, options = {})
          def_accessors(name)
          if options.fetch(:auto, false)
            unless Type[type].is_a?(Cequel::Type::Uuid)
              fail ArgumentError, ":auto option only valid for UUID columns"
Severity: Minor
Found in lib/cequel/record/properties.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

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

      def cast(value)
        if value.is_a? Cassandra::Uuid then value
        elsif defined?(SimpleUUID::UUID) && value.is_a?(SimpleUUID::UUID)
          Cassandra::Uuid.new(value.to_i)
        elsif value.is_a?(::Integer) || value.is_a?(::String)
Severity: Minor
Found in lib/cequel/type.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 clear_active_connections! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def clear_active_connections!
        synchronize do
          if defined? @client
            remove_instance_variable(:@client)
          end
Severity: Minor
Found in lib/cequel/metal/keyspace.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 save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def save(options = {})
        super.tap do |success|
          if success
            if self.respond_to?(:changes_applied)
              changes_applied
Severity: Minor
Found in lib/cequel/record/dirty.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 execute_stmt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

          def execute_stmt(keyspace)
            retries_remaining = max_retries
            begin
              yield
            rescue Cassandra::Errors::NoHostsAvailable,
Severity: Minor
Found in lib/cequel/metal/policy/cassandra_error.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 write_attribute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def write_attribute(name, value)
        column = self.class.reflect_on_column(name)
        fail UnknownAttributeError, "unknown attribute: #{name}" unless column
        value = column.cast(value) unless value.nil?

Severity: Minor
Found in lib/cequel/record/dirty.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 find_rows_in_single_batch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def find_rows_in_single_batch(options = {})
        if options.key?(:batch_size)
          fail ArgumentError,
               "Can't pass :batch_size argument with a limit in the scope"
        else
Severity: Minor
Found in lib/cequel/record/record_set.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 find_rows_in_batches has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def find_rows_in_batches(options = {}, &block)
        return find_rows_in_single_batch(options, &block) if row_limit
        options.assert_valid_keys(:batch_size)
        batch_size = options.fetch(:batch_size, 1000)
        batch_record_set = base_record_set = limit(batch_size)
Severity: Minor
Found in lib/cequel/record/record_set.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 assert_same_key_types!
        each_key_pair do |old_key, new_key|
          if old_key.type != new_key.type
            fail InvalidSchemaMigration,
                 "Can't change type of key column #{old_key.name} from " \
Severity: Minor
Found in lib/cequel/schema/migration_validator.rb and 1 other location - About 15 mins to fix
lib/cequel/schema/migration_validator.rb on lines 65..70

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

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 assert_same_clustering_order!
        each_clustering_column_pair do |old_key, new_key|
          if old_key.clustering_order != new_key.clustering_order
            fail InvalidSchemaMigration,
                 "Can't change the clustering order of #{old_key.name} from " \
Severity: Minor
Found in lib/cequel/schema/migration_validator.rb and 1 other location - About 15 mins to fix
lib/cequel/schema/migration_validator.rb on lines 55..60

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

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

unexpected token tLT (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
Open

class <%= class_name %>
Severity: Minor
Found in templates/record.rb by rubocop

protected (on line 54) does not make singleton methods protected. Use protected inside a class << self block instead.
Open

    def self.included(a_module)
Severity: Minor
Found in lib/cequel/instrumentation.rb by rubocop

This cop checks for private or protected access modifiers which are applied to a singleton method. These access modifiers do not make singleton methods private/protected. private_class_method can be used for that.

Example:

# bad

class C
  private

  def self.method
    puts 'hi'
  end
end

Example:

# good

class C
  def self.method
    puts 'hi'
  end

  private_class_method :method
end

Example:

# good

class C
  class << self
    private

    def method
      puts 'hi'
    end
  end
end

Line is too long. [98/80]
Open

          @cassandra_version = client_without_keyspace.execute(statement).first['release_version']
Severity: Minor
Found in lib/cequel/metal/keyspace.rb by rubocop

Unnecessary utf-8 encoding comment.
Open

# -*- encoding : utf-8 -*-
Severity: Minor
Found in lib/cequel/metal/keyspace.rb by rubocop

Line is too long. [100/80]
Open

      # @note A bug (CASSANDRA-8733) exists in Cassandra versions 0.3.0-2.0.12 and 2.1.0-2.1.2 which
Severity: Minor
Found in lib/cequel/metal/data_set.rb by rubocop

Use alias instead of alias_method in a class body.
Open

      alias_method :incr, :increment
Severity: Minor
Found in lib/cequel/metal/data_set.rb by rubocop

This cop enforces the use of either #alias or #alias_method depending on configuration. It also flags uses of alias :symbol rather than alias bareword.

Example: EnforcedStyle: prefer_alias (default)

# bad
alias_method :bar, :foo
alias :bar :foo

# good
alias bar foo

Example: EnforcedStyle: preferaliasmethod

# bad
alias :bar :foo
alias bar foo

# good
alias_method :bar, :foo
Severity
Category
Status
Source
Language