Showing 7 of 7 total issues
Class Processor
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class Processor < ::SimpleDelegator
attr_accessor :url
attr_reader :config, :http, :redirect_count
Method initialize
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def initialize
@redirect_limit = 3
@user_agent = 'link_thumbnailer'
@verify_ssl = true
@http_open_timeout = 5
Method valid_response_format?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def valid_response_format?(response)
return true unless config.raise_on_invalid_format
return true if response['Content-Type'] =~ /text\/html/
return true if response['Content-Type'] =~ /application\/html/
return true if response['Content-Type'] =~ /application\/xhtml\+xml/
- Read upRead up
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 too many return
statements within this method. Open
Open
return true if response['Content-Type'] =~ /text\/plain/
Avoid too many return
statements within this method. Open
Open
return true if response['Content-Type'] =~ /text\/xml/
Avoid too many return
statements within this method. Open
Open
return true if response['Content-Type'] =~ /application\/xml/
Method abs_urls
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def abs_urls
urls.map do |url|
uri = validate_url(url)
next unless uri
- Read upRead up
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"