marcelobarreto/postgrest-rb

View on GitHub
lib/postgrest/http.rb

Summary

Maintainability
A
0 mins
Test Coverage

Assignment Branch Condition size for call is too high. [16.16/15]
Open

    def call
      raise InvalidHTTPMethod unless valid_http_method?

      @response = Net::HTTP.start(uri.host, uri.port, use_ssl: use_ssl?) do |http|
        @request = create_request
Severity: Minor
Found in lib/postgrest/http.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

Use #key? instead of #keys.include?.
Open

      METHODS.keys.include?(http_method)
Severity: Minor
Found in lib/postgrest/http.rb by rubocop

This cop checks for inefficient searching of keys and values within hashes.

Hash#keys.include? is less efficient than Hash#key? because the former allocates a new array and then performs an O(n) search through that array, while Hash#key? does not allocate any array and performs a faster O(1) search for the key.

Hash#values.include? is less efficient than Hash#value?. While they both perform an O(n) search through all of the values, calling values allocates a new array while using value? does not.

Example:

# bad
{ a: 1, b: 2 }.keys.include?(:a)
{ a: 1, b: 2 }.keys.include?(:z)
h = { a: 1, b: 2 }; h.keys.include?(100)

# good
{ a: 1, b: 2 }.key?(:a)
{ a: 1, b: 2 }.has_key?(:z)
h = { a: 1, b: 2 }; h.key?(100)

# bad
{ a: 1, b: 2 }.values.include?(2)
{ a: 1, b: 2 }.values.include?('garbage')
h = { a: 1, b: 2 }; h.values.include?(nil)

# good
{ a: 1, b: 2 }.value?(2)
{ a: 1, b: 2 }.has_value?('garbage')
h = { a: 1, b: 2 }; h.value?(nil)

Line is too long. [82/80]
Open

      @response = Net::HTTP.start(uri.host, uri.port, use_ssl: use_ssl?) do |http|
Severity: Minor
Found in lib/postgrest/http.rb by rubocop

This cop checks the length of lines in the source code. The maximum length is configurable. The tab size is configured in the IndentationWidth of the Layout/Tab cop.

Freeze mutable objects assigned to constants.
Open

    USER_AGENT = 'PostgREST Ruby Client'
Severity: Minor
Found in lib/postgrest/http.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

# good
CONST = <<~TESTING.freeze
This is a heredoc
TESTING

There are no issues that match your filters.

Category
Status