rastating/wordpress-exploit-framework

View on GitHub
lib/wpxf/net/http_client.rb

Summary

Maintainability
A
0 mins
Test Coverage

Module has too many lines. [121/100]
Open

    module HttpClient
      include Wpxf::Net::UserAgent
      include Wpxf::Net::HttpOptions
      include Wpxf::Net::TyphoeusHelper

Severity: Minor
Found in lib/wpxf/net/http_client.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for download_file is too high. [15.56/15]
Open

      def download_file(opts)
        target_file = File.open(opts[:local_filename], 'wb')
        req = create_typhoeus_request(opts)

        req.on_headers do |response|
Severity: Minor
Found in lib/wpxf/net/http_client.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 yield instead of callback.call.
Open

          callback.call(Wpxf::Net::HttpResponse.new(res)) if callback
Severity: Minor
Found in lib/wpxf/net/http_client.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

Use safe navigation (&.) instead of checking if an object exists before calling the method.
Open

          callback.call(Wpxf::Net::HttpResponse.new(res)) if callback
Severity: Minor
Found in lib/wpxf/net/http_client.rb by rubocop

This cop transforms usages of a method call safeguarded by a non nil check for the variable whose method is being called to safe navigation (&.).

Configuration option: ConvertCodeThatCanStartToReturnNil The default for this is false. When configured to true, this will check for code in the format !foo.nil? && foo.bar. As it is written, the return of this code is limited to false and whatever the return of the method is. If this is converted to safe navigation, foo&.bar can start returning nil as well as what the method returns.

Example:

# bad
foo.bar if foo
foo.bar(param1, param2) if foo
foo.bar { |e| e.something } if foo
foo.bar(param) { |e| e.something } if foo

foo.bar if !foo.nil?
foo.bar unless !foo
foo.bar unless foo.nil?

foo && foo.bar
foo && foo.bar(param1, param2)
foo && foo.bar { |e| e.something }
foo && foo.bar(param) { |e| e.something }

# good
foo&.bar
foo&.bar(param1, param2)
foo&.bar { |e| e.something }
foo&.bar(param) { |e| e.something }

foo.nil? || foo.bar
!foo || foo.bar

# Methods that `nil` will `respond_to?` should not be converted to
# use safe navigation
foo.to_i if foo

There are no issues that match your filters.

Category
Status