Showing 79 of 79 total issues

Method define_statement_method has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def self.define_statement_method(mod, name, params, sql, &block)
Severity: Minor
Found in lib/db_mod/statements/statement.rb - About 35 mins to fix

    Method def_configurable has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def self.def_configurable(mod, name, definition, params = 0, &block)
    Severity: Minor
    Found in lib/db_mod/statements/configuration.rb - About 35 mins to fix

      Method attach_param_processor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.attach_param_processor(definition, params, config)
              wrapped =
                if params.is_a?(Array) && !params.empty?
                  define_named_args_method(definition, params)
      
      
      Severity: Minor
      Found in lib/db_mod/statements/configuration.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

      guard :rspec, cmd: 'bundle exec rspec' do
        require 'guard/rspec/dsl'
        dsl = Guard::RSpec::Dsl.new(self)
      
        # Feel free to open issues for suggestions and improvements
      Severity: Minor
      Found in Guardfile 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 use_named_defaults has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              def self.use_named_defaults(scope, args, defaults)
                # Special case when no args given.
                args << {} if args.empty?
      
                # If the args are weird, expect normal parameter validation
      Severity: Minor
      Found in lib/db_mod/statements/configuration/defaults.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

      Avoid rescuing without specifying an error class.
      Open

          rescue
      Severity: Minor
      Found in lib/db_mod/transaction.rb by rubocop

      This cop checks for rescuing StandardError. There are two supported styles implicit and explicit. This cop will not register an offense if any error other than StandardError is specified.

      Example: EnforcedStyle: implicit

      # `implicit` will enforce using `rescue` instead of
      # `rescue StandardError`.
      
      # bad
      begin
        foo
      rescue StandardError
        bar
      end
      
      # good
      begin
        foo
      rescue
        bar
      end
      
      # good
      begin
        foo
      rescue OtherError
        bar
      end
      
      # good
      begin
        foo
      rescue StandardError, SecurityError
        bar
      end

      Example: EnforcedStyle: explicit (default)

      # `explicit` will enforce using `rescue StandardError`
      # instead of `rescue`.
      
      # bad
      begin
        foo
      rescue
        bar
      end
      
      # good
      begin
        foo
      rescue StandardError
        bar
      end
      
      # good
      begin
        foo
      rescue OtherError
        bar
      end
      
      # good
      begin
        foo
      rescue StandardError, SecurityError
        bar
      end

      Omit parentheses for the empty lambda parameters.
      Open

                  ->() { instance_exec(&definition) }

      This cop checks for parentheses for empty lambda parameters. Parentheses for empty lambda parameters do not cause syntax errors, but they are redundant.

      Example:

      # bad
      -> () { do_something }
      
      # good
      -> { do_something }
      
      # good
      -> (arg) { do_something(arg) }

      private (on line 58) does not make singleton methods private. Use private_class_method or private inside a class << self block instead.
      Open

            def self.define_prepare_all_statements(mod)
      Severity: Minor
      Found in lib/db_mod/statements/prepared.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

      Always use raise to signal exceptions.
      Open

                fail ArgumentError, "#{args.size} args given, #{count} expected"
      Severity: Minor
      Found in lib/db_mod/statements/parameters.rb by rubocop

      This cop checks for uses of fail and raise.

      Example: EnforcedStyle: only_raise (default)

      # The `only_raise` style enforces the sole use of `raise`.
      # bad
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        # handle it
      end
      
      Kernel.fail
      
      # good
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        raise
      rescue Exception
        # handle it
      end
      
      Kernel.raise

      Example: EnforcedStyle: only_fail

      # The `only_fail` style enforces the sole use of `fail`.
      # bad
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        raise
      rescue Exception
        # handle it
      end
      
      Kernel.raise
      
      # good
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        # handle it
      end
      
      Kernel.fail

      Example: EnforcedStyle: semantic

      # The `semantic` style enforces the use of `fail` to signal an
      # exception, then will use `raise` to trigger an offense after
      # it has been rescued.
      # bad
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        # Error thrown
      rescue Exception
        fail
      end
      
      Kernel.fail
      Kernel.raise
      
      # good
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        raise 'Preferably with descriptive message'
      end
      
      explicit_receiver.fail
      explicit_receiver.raise

      private (on line 55) does not make singleton methods private. Use private_class_method or private inside a class << self block instead.
      Open

            def self.define_def_statement(mod)
      Severity: Minor
      Found in lib/db_mod/statements/statement.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

      private (on line 58) does not make singleton methods private. Use private_class_method or private inside a class << self block instead.
      Open

            def self.define_prepared_method_with_args(mod, name, params, &block)
      Severity: Minor
      Found in lib/db_mod/statements/prepared.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

      private (on line 79) does not make singleton methods private. Use private_class_method or private inside a class << self block instead.
      Open

            def self.parse_numbered_params!(params)
      Severity: Minor
      Found in lib/db_mod/statements/parameters.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

      Always use raise to signal exceptions.
      Open

                fail(ArgumentError, "missing arg #{arg}") unless args.key? arg
      Severity: Minor
      Found in lib/db_mod/statements/parameters.rb by rubocop

      This cop checks for uses of fail and raise.

      Example: EnforcedStyle: only_raise (default)

      # The `only_raise` style enforces the sole use of `raise`.
      # bad
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        # handle it
      end
      
      Kernel.fail
      
      # good
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        raise
      rescue Exception
        # handle it
      end
      
      Kernel.raise

      Example: EnforcedStyle: only_fail

      # The `only_fail` style enforces the sole use of `fail`.
      # bad
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        raise
      rescue Exception
        # handle it
      end
      
      Kernel.raise
      
      # good
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        # handle it
      end
      
      Kernel.fail

      Example: EnforcedStyle: semantic

      # The `semantic` style enforces the use of `fail` to signal an
      # exception, then will use `raise` to trigger an offense after
      # it has been rescued.
      # bad
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        # Error thrown
      rescue Exception
        fail
      end
      
      Kernel.fail
      Kernel.raise
      
      # good
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        raise 'Preferably with descriptive message'
      end
      
      explicit_receiver.fail
      explicit_receiver.raise

      Always use raise to signal exceptions.
      Open

                fail ArgumentError, 'too many defaults' if arity.min < 0

      This cop checks for uses of fail and raise.

      Example: EnforcedStyle: only_raise (default)

      # The `only_raise` style enforces the sole use of `raise`.
      # bad
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        # handle it
      end
      
      Kernel.fail
      
      # good
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        raise
      rescue Exception
        # handle it
      end
      
      Kernel.raise

      Example: EnforcedStyle: only_fail

      # The `only_fail` style enforces the sole use of `fail`.
      # bad
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        raise
      rescue Exception
        # handle it
      end
      
      Kernel.raise
      
      # good
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        # handle it
      end
      
      Kernel.fail

      Example: EnforcedStyle: semantic

      # The `semantic` style enforces the use of `fail` to signal an
      # exception, then will use `raise` to trigger an offense after
      # it has been rescued.
      # bad
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        # Error thrown
      rescue Exception
        fail
      end
      
      Kernel.fail
      Kernel.raise
      
      # good
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        raise 'Preferably with descriptive message'
      end
      
      explicit_receiver.fail
      explicit_receiver.raise

      Always use raise to signal exceptions.
      Open

                fail DbMod::Exceptions::DuplicateStatementName if statements.key? name
      Severity: Minor
      Found in lib/db_mod/statements/prepared.rb by rubocop

      This cop checks for uses of fail and raise.

      Example: EnforcedStyle: only_raise (default)

      # The `only_raise` style enforces the sole use of `raise`.
      # bad
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        # handle it
      end
      
      Kernel.fail
      
      # good
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        raise
      rescue Exception
        # handle it
      end
      
      Kernel.raise

      Example: EnforcedStyle: only_fail

      # The `only_fail` style enforces the sole use of `fail`.
      # bad
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        raise
      rescue Exception
        # handle it
      end
      
      Kernel.raise
      
      # good
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        # handle it
      end
      
      Kernel.fail

      Example: EnforcedStyle: semantic

      # The `semantic` style enforces the use of `fail` to signal an
      # exception, then will use `raise` to trigger an offense after
      # it has been rescued.
      # bad
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        # Error thrown
      rescue Exception
        fail
      end
      
      Kernel.fail
      Kernel.raise
      
      # good
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        raise 'Preferably with descriptive message'
      end
      
      explicit_receiver.fail
      explicit_receiver.raise

      private (on line 79) does not make singleton methods private. Use private_class_method or private inside a class << self block instead.
      Open

            def self.wrapped_hash!(args)
      Severity: Minor
      Found in lib/db_mod/statements/parameters.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

      Always use raise to signal exceptions.
      Open

                fail ArgumentError, "#{args.size} args given, #{expected.size} needed"
      Severity: Minor
      Found in lib/db_mod/statements/parameters.rb by rubocop

      This cop checks for uses of fail and raise.

      Example: EnforcedStyle: only_raise (default)

      # The `only_raise` style enforces the sole use of `raise`.
      # bad
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        # handle it
      end
      
      Kernel.fail
      
      # good
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        raise
      rescue Exception
        # handle it
      end
      
      Kernel.raise

      Example: EnforcedStyle: only_fail

      # The `only_fail` style enforces the sole use of `fail`.
      # bad
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        raise
      rescue Exception
        # handle it
      end
      
      Kernel.raise
      
      # good
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        # handle it
      end
      
      Kernel.fail

      Example: EnforcedStyle: semantic

      # The `semantic` style enforces the use of `fail` to signal an
      # exception, then will use `raise` to trigger an offense after
      # it has been rescued.
      # bad
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        # Error thrown
      rescue Exception
        fail
      end
      
      Kernel.fail
      Kernel.raise
      
      # good
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        raise 'Preferably with descriptive message'
      end
      
      explicit_receiver.fail
      explicit_receiver.raise

      Indent the first line of the right-hand-side of a multi-line assignment.
      Open

                      Configuration::MethodConfiguration.new

      This cop checks the indentation of the first line of the right-hand-side of a multi-line assignment.

      Example:

      # bad
      value =
      if foo
        'bar'
      end
      
      # good
      value =
        if foo
          'bar'
        end

      The indentation of the remaining lines can be corrected with other cops such as IndentationConsistency and EndAlignment.

      private (on line 63) does not make singleton methods private. Use private_class_method or private inside a class << self block instead.
      Open

              def self.value!(value, scope, args)

      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

      Always use raise to signal exceptions.
      Open

            fail DbMod::Exceptions::AlreadyInTransaction if @in_transaction
      Severity: Minor
      Found in lib/db_mod/transaction.rb by rubocop

      This cop checks for uses of fail and raise.

      Example: EnforcedStyle: only_raise (default)

      # The `only_raise` style enforces the sole use of `raise`.
      # bad
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        # handle it
      end
      
      Kernel.fail
      
      # good
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        raise
      rescue Exception
        # handle it
      end
      
      Kernel.raise

      Example: EnforcedStyle: only_fail

      # The `only_fail` style enforces the sole use of `fail`.
      # bad
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        raise
      rescue Exception
        # handle it
      end
      
      Kernel.raise
      
      # good
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        # handle it
      end
      
      Kernel.fail

      Example: EnforcedStyle: semantic

      # The `semantic` style enforces the use of `fail` to signal an
      # exception, then will use `raise` to trigger an offense after
      # it has been rescued.
      # bad
      begin
        raise
      rescue Exception
        # handle it
      end
      
      def watch_out
        # Error thrown
      rescue Exception
        fail
      end
      
      Kernel.fail
      Kernel.raise
      
      # good
      begin
        fail
      rescue Exception
        # handle it
      end
      
      def watch_out
        fail
      rescue Exception
        raise 'Preferably with descriptive message'
      end
      
      explicit_receiver.fail
      explicit_receiver.raise
      Severity
      Category
      Status
      Source
      Language