cequel/cequel

View on GitHub
lib/cequel/record/collection.rb

Summary

Maintainability
A
2 hrs
Test Coverage

File collection.rb has 252 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'delegate'

module Cequel
  module Record
    #
Severity: Minor
Found in lib/cequel/record/collection.rb - About 2 hrs to fix

    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

    Use yield instead of block.call.
    Open

              block.call
    Severity: Minor
    Found in lib/cequel/record/collection.rb by rubocop

    This cop identifies the use of a &block parameter and block.call where yield would do just as well.

    Example:

    # bad
    def method(&block)
      block.call
    end
    def another(&func)
      func.call 1, 2, 3
    end
    
    # good
    def method
      yield
    end
    def another
      yield 1, 2, 3
    end

    Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.
    Open

              BasicObject.instance_method(:method_missing))
    Severity: Minor
    Found in lib/cequel/record/collection.rb by rubocop

    This cop checks that the closing brace in a method call is either on the same line as the last method argument, or a new line.

    When using the symmetrical (default) style:

    If a method call's opening brace is on the same line as the first argument of the call, then the closing brace should be on the same line as the last argument of the call.

    If an method call's opening brace is on the line above the first argument of the call, then the closing brace should be on the line below the last argument of the call.

    When using the new_line style:

    The closing brace of a multi-line method call must be on the line after the last argument of the call.

    When using the same_line style:

    The closing brace of a multi-line method call must be on the same line as the last argument of the call.

    Example:

    # symmetrical: bad
      # new_line: good
      # same_line: bad
      foo(a,
        b
      )
    
      # symmetrical: bad
      # new_line: bad
      # same_line: good
      foo(
        a,
        b)
    
      # symmetrical: good
      # new_line: bad
      # same_line: good
      foo(a,
        b)
    
      # symmetrical: good
      # new_line: good
      # same_line: bad
      foo(
        a,
        b
      )

    Use alias instead of alias_method in a class body.
    Open

          alias_method :<<, :push
    Severity: Minor
    Found in lib/cequel/record/collection.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

    Use alias instead of alias_method in a class body.
    Open

          alias_method :<<, :add
    Severity: Minor
    Found in lib/cequel/record/collection.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

    Do not use parallel assignment.
    Open

            @model, @column = model, column
    Severity: Minor
    Found in lib/cequel/record/collection.rb by rubocop

    Checks for simple usages of parallel assignment. This will only complain when the number of variables being assigned matched the number of assigning variables.

    Example:

    # bad
    a, b, c = 1, 2, 3
    a, b, c = [1, 2, 3]
    
    # good
    one, two = *foo
    a, b = foo()
    a, b = b, a
    
    a = 1
    b = 2
    c = 3

    Use %i or %I for an array of symbols.
    Open

          NON_ATOMIC_MUTATORS = [
            :collect!,
            :delete_if,
            :fill,
            :flatten!,
    Severity: Minor
    Found in lib/cequel/record/collection.rb by rubocop

    This cop can check for array literals made up of symbols that are not using the %i() syntax.

    Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

    Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

    Example: EnforcedStyle: percent (default)

    # good
    %i[foo bar baz]
    
    # bad
    [:foo, :bar, :baz]

    Example: EnforcedStyle: brackets

    # good
    [:foo, :bar, :baz]
    
    # bad
    %i[foo bar baz]

    Line is too long. [87/80]
    Open

            prepared = @model.class.connection.bug8733_version? ? objects.reverse : objects
    Severity: Minor
    Found in lib/cequel/record/collection.rb by rubocop

    Use alias instead of alias_method in a class body.
    Open

          alias_method :append, :push
    Severity: Minor
    Found in lib/cequel/record/collection.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

    Use alias instead of alias_method in a class body.
    Open

          alias_method :prepend, :unshift
    Severity: Minor
    Found in lib/cequel/record/collection.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

    Use alias instead of alias_method in a class body.
    Open

          alias_method :update, :merge!
    Severity: Minor
    Found in lib/cequel/record/collection.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

    Use %i or %I for an array of symbols.
    Open

          NON_ATOMIC_MUTATORS = [
            :add?,
            :collect!,
            :delete?,
            :delete_if,
    Severity: Minor
    Found in lib/cequel/record/collection.rb by rubocop

    This cop can check for array literals made up of symbols that are not using the %i() syntax.

    Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

    Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

    Example: EnforcedStyle: percent (default)

    # good
    %i[foo bar baz]
    
    # bad
    [:foo, :bar, :baz]

    Example: EnforcedStyle: brackets

    # good
    [:foo, :bar, :baz]
    
    # bad
    %i[foo bar baz]

    Add an empty line after magic comments.
    Open

    require 'delegate'
    Severity: Minor
    Found in lib/cequel/record/collection.rb by rubocop

    Checks for a newline after the final magic comment.

    Example:

    # good
    # frozen_string_literal: true
    
    # Some documentation for Person
    class Person
      # Some code
    end
    
    # bad
    # frozen_string_literal: true
    # Some documentation for Person
    class Person
      # Some code
    end

    Use %i or %I for an array of symbols.
    Open

          NON_ATOMIC_MUTATORS = [
            :default,
            :default=,
            :default_proc,
            :default_proc=,
    Severity: Minor
    Found in lib/cequel/record/collection.rb by rubocop

    This cop can check for array literals made up of symbols that are not using the %i() syntax.

    Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

    Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

    Example: EnforcedStyle: percent (default)

    # good
    %i[foo bar baz]
    
    # bad
    [:foo, :bar, :baz]

    Example: EnforcedStyle: brackets

    # good
    [:foo, :bar, :baz]
    
    # bad
    %i[foo bar baz]

    Freeze mutable objects assigned to constants.
    Open

          NON_ATOMIC_MUTATORS = [
            :default,
            :default=,
            :default_proc,
            :default_proc=,
    Severity: Minor
    Found in lib/cequel/record/collection.rb by rubocop

    This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

    Example:

    # bad
    CONST = [1, 2, 3]
    
    # good
    CONST = [1, 2, 3].freeze

    Useless private access modifier.
    Open

          private
    Severity: Minor
    Found in lib/cequel/record/collection.rb by rubocop

    This cop checks for redundant access modifiers, including those with no code, those which are repeated, and leading public modifiers in a class or module body. Conditionally-defined methods are considered as always being defined, and thus access modifiers guarding such methods are not redundant.

    Example:

    class Foo
      public # this is redundant (default access is public)
    
      def method
      end
    
      private # this is not redundant (a method is defined)
      def method2
      end
    
      private # this is redundant (no following methods are defined)
    end

    Example:

    class Foo
      # The following is not redundant (conditionally defined methods are
      # considered as always defining a method)
      private
    
      if condition?
        def method
        end
      end
    
      protected # this is not redundant (method is defined)
    
      define_method(:method2) do
      end
    
      protected # this is redundant (repeated from previous modifier)
    
      [1,2,3].each do |i|
        define_method("foo#{i}") do
        end
      end
    
      # The following is redundant (methods defined on the class'
      # singleton class are not affected by the public modifier)
      public
    
      def self.method3
      end
    end

    Example:

    # Lint/UselessAccessModifier:
    #   ContextCreatingMethods:
    #     - concerning
    require 'active_support/concern'
    class Foo
      concerning :Bar do
        def some_public_method
        end
    
        private
    
        def some_private_method
        end
      end
    
      # this is not redundant because `concerning` created its own context
      private
    
      def some_other_private_method
      end
    end

    Example:

    # Lint/UselessAccessModifier:
    #   MethodCreatingMethods:
    #     - delegate
    require 'active_support/core_ext/module/delegation'
    class Foo
      # this is not redundant because `delegate` creates methods
      private
    
      delegate :method_a, to: :method_b
    end

    Unnecessary utf-8 encoding comment.
    Open

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

    Freeze mutable objects assigned to constants.
    Open

          NON_ATOMIC_MUTATORS = [
            :collect!,
            :delete_if,
            :fill,
            :flatten!,
    Severity: Minor
    Found in lib/cequel/record/collection.rb by rubocop

    This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

    Example:

    # bad
    CONST = [1, 2, 3]
    
    # good
    CONST = [1, 2, 3].freeze

    Line is too long. [93/80]
    Open

                        Kernel.raise ArgumentError, "[i]=elem or [i,count]=elems or [a..b]=elems"
    Severity: Minor
    Found in lib/cequel/record/collection.rb by rubocop

    Freeze mutable objects assigned to constants.
    Open

          NON_ATOMIC_MUTATORS = [
            :add?,
            :collect!,
            :delete?,
            :delete_if,
    Severity: Minor
    Found in lib/cequel/record/collection.rb by rubocop

    This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

    Example:

    # bad
    CONST = [1, 2, 3]
    
    # good
    CONST = [1, 2, 3].freeze

    Use alias instead of alias_method in a class body.
    Open

          alias_method :store, :[]=
    Severity: Minor
    Found in lib/cequel/record/collection.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

    There are no issues that match your filters.

    Category
    Status