appbot/kms_rails

View on GitHub

Showing 182 of 182 total issues

KmsRails::KmsClientMock#decrypt calls 'raise ::Aws::KMS::Errors::InvalidCiphertextException.new(nil, nil)' 2 times
Open

      raise ::Aws::KMS::Errors::InvalidCiphertextException.new(nil, nil) unless decoded_context == encryption_context

      ::Aws::KMS::Types::DecryptResponse.new(
        key_id: key_id,
        plaintext: plaintext,
Severity: Minor
Found in lib/kms_rails/kms_client_mock.rb by reek

Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

Reek implements a check for Duplicate Method Call.

Example

Here's a very much simplified and contrived example. The following method will report a warning:

def double_thing()
  @other.thing + @other.thing
end

One quick approach to silence Reek would be to refactor the code thus:

def double_thing()
  thing = @other.thing
  thing + thing
end

A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

class Other
  def double_thing()
    thing + thing
  end
end

The approach you take will depend on balancing other factors in your code.

KmsRails::ConfigurationBase::Configuration#arn_prefix is a writable attribute
Open

      attr_accessor :kms_client, :alias_prefix, :arn_prefix
Severity: Minor
Found in lib/kms_rails/configuration.rb by reek

A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

The same holds to a lesser extent for getters, but Reek doesn't flag those.

Example

Given:

class Klass
  attr_accessor :dummy
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Klass declares the writable attribute dummy (Attribute)

KmsRails::Core#decrypt64 performs a nil-check
Open

      return nil if data_obj.nil?
Severity: Minor
Found in lib/kms_rails/core.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

Avoid parameter lists longer than 5 parameters. [6/5]
Open

      def kms_attr(field, key_id:, retain: false, msgpack: false, context_key: nil, context_value: nil)
Severity: Minor
Found in lib/kms_rails/active_record.rb by rubocop

This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.

KmsRails::Core#self.to64 performs a nil-check
Open

      return nil if data_obj.nil?
Severity: Minor
Found in lib/kms_rails/core.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

KmsRails::Core#encrypt_attr doesn't depend on instance state (maybe move it to another class?)
Open

    def encrypt_attr(data, key)
Severity: Minor
Found in lib/kms_rails/core.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

KmsRails::ActiveRecord::InstanceMethods#clear_retained performs a nil-check
Open

        return if !@_retained.include?(field) || @_retained[field].nil?
Severity: Minor
Found in lib/kms_rails/active_record.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

KmsRails::ConfigurationBase#configuration is a writable attribute
Open

    attr_writer :configuration
Severity: Minor
Found in lib/kms_rails/configuration.rb by reek

A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

The same holds to a lesser extent for getters, but Reek doesn't flag those.

Example

Given:

class Klass
  attr_accessor :dummy
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Klass declares the writable attribute dummy (Attribute)

KmsRails::ConfigurationBase::Configuration#alias_prefix is a writable attribute
Open

      attr_accessor :kms_client, :alias_prefix, :arn_prefix
Severity: Minor
Found in lib/kms_rails/configuration.rb by reek

A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

The same holds to a lesser extent for getters, but Reek doesn't flag those.

Example

Given:

class Klass
  attr_accessor :dummy
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Klass declares the writable attribute dummy (Attribute)

KmsRails::Core#decrypt performs a nil-check
Open

      return nil if data_obj.nil?
Severity: Minor
Found in lib/kms_rails/core.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

KmsRails::ConfigurationBase::Configuration#kms_client is a writable attribute
Open

      attr_accessor :kms_client, :alias_prefix, :arn_prefix
Severity: Minor
Found in lib/kms_rails/configuration.rb by reek

A class that publishes a setter for an instance variable invites client classes to become too intimate with its inner workings, and in particular with its representation of state.

The same holds to a lesser extent for getters, but Reek doesn't flag those.

Example

Given:

class Klass
  attr_accessor :dummy
end

Reek would emit the following warning:

reek test.rb

test.rb -- 1 warning:
  [2]:Klass declares the writable attribute dummy (Attribute)

KmsRails::Core#apply_context doesn't depend on instance state (maybe move it to another class?)
Open

    def apply_context(args, key, value)
Severity: Minor
Found in lib/kms_rails/core.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

KmsRails::Core#encrypt performs a nil-check
Open

      return nil if data.nil?
Severity: Minor
Found in lib/kms_rails/core.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

KmsRails::Core#encrypt64 performs a nil-check
Open

      return nil if data.nil?
Severity: Minor
Found in lib/kms_rails/core.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

KmsRails::ActiveJob::ClassMethods#kms_args performs a nil-check
Open

            unless args[i].nil? || (args[i].class == Hash && args[i].keys.to_set == ['key', 'iv', 'blob'].to_set)
              args[i] = enc.encrypt64(args[i])
            end
          end

Severity: Minor
Found in lib/kms_rails/active_job.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

KmsRails::Core#self.from64 performs a nil-check
Open

      return nil if data_obj.nil?
Severity: Minor
Found in lib/kms_rails/core.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

KmsRails::Core#decrypt_attr doesn't depend on instance state (maybe move it to another class?)
Open

    def decrypt_attr(data, key, iv)
Severity: Minor
Found in lib/kms_rails/core.rb by reek

A Utility Function is any instance method that has no dependency on the state of the instance.

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

Gem::Specification.new do |spec|
  spec.name          = 'kms_rails'
  spec.version       = KmsRails::VERSION
  spec.authors       = ['Ash Tyndall', 'Justin Ouellette']
  spec.email         = ['ash@appbot.co']
Severity: Minor
Found in kms_rails.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.

KmsRails::Core#self.from64 has the variable name 'k'
Open

      data_obj.map { |k,v| [k, Base64.strict_decode64(v)] }.to_h
Severity: Minor
Found in lib/kms_rails/core.rb by reek

An Uncommunicative Variable Name is a variable name that doesn't communicate its intent well enough.

Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

KmsRails::Core#decrypt64 has the name 'decrypt64'
Open

    def decrypt64(data_obj)
Severity: Minor
Found in lib/kms_rails/core.rb by reek

An Uncommunicative Method Name is a method name that doesn't communicate its intent well enough.

Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.

Severity
Category
Status
Source
Language