Showing 14 of 20 total issues
Method http_get
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
def http_get(uri, options = {})
found = false
remaining_redirects = options[:max_redirects] ? options[:max_redirects].to_i : 4
until found
http = Net::HTTP.new(uri.host, uri.port)
- 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
Method convert_json_to_yaml
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def convert_json_to_yaml(json) #:nodoc:
require 'strscan' unless defined? ::StringScanner
scanner, quoting, marks, pos = ::StringScanner.new(json), false, [], nil
scanner.scan_until(/\{/)
while scanner.scan_until(/(\\['"]|['":,\\]|\\.)/)
- 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
Method discover_provider
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def discover_provider(url, options = {})
uri = URI.parse(url)
res = http_get(uri, options)
format = options[:format]
- 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
Method convert_json_to_yaml
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def convert_json_to_yaml(json) #:nodoc:
require 'strscan' unless defined? ::StringScanner
scanner, quoting, marks, pos = ::StringScanner.new(json), false, [], nil
scanner.scan_until(/\{/)
while scanner.scan_until(/(\\['"]|['":,\\]|\\.)/)
Method http_get
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def http_get(uri, options = {})
found = false
remaining_redirects = options[:max_redirects] ? options[:max_redirects].to_i : 4
until found
http = Net::HTTP.new(uri.host, uri.port)
Method initialize
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def initialize(endpoint, positional_format = OEmbed::Formatter.default, format: nil, required_query_params: {})
endpoint_uri = URI.parse(endpoint.gsub(/[\{\}]/,'')) rescue nil
raise ArgumentError, "The given endpoint isn't a valid http(s) URI: #{endpoint.to_s}" unless endpoint_uri.is_a?(URI::HTTP)
@required_query_params = {}
- 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
Method test_backend
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_backend(backend_module)
expected = {
"version"=>1.0,
"string"=>"test",
"int"=>42,
Method add_official_provider
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def add_official_provider(provider_class, sub_type=nil, access_token: nil)
raise TypeError, "Expected OEmbed::Provider instance but was #{provider_class.class}" \
unless provider_class.is_a?(OEmbed::Provider)
@@to_register[sub_type.to_s] ||= []
- 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
Method backend=
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def backend=(new_backend)
new_backend_obj = case new_backend
when String
unless already_loaded?(new_backend)
load "oembed/formatter/#{backend_path}/#{new_backend.downcase}.rb"
- 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
Method unregister
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def unregister(*providers)
providers.each do |provider|
provider.urls.each do |url|
if @@urls[url].is_a?(Array)
@@urls[url].delete(provider)
- 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
Method test_backend
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def test_backend(new_backend)
raise LoadError, "The given backend must respond to the decode method: #{new_backend.inspect}" unless new_backend.respond_to?(:decode)
expected = {
"version"=>1.0,
- 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
Method decode
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def decode(format, value)
supported?(format)
begin
case format.to_s
- 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
Method find
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def find(url)
@@urls.keys.each do |url_regexp|
next unless url_regexp.match?(url)
matching_provider = @@urls[url_regexp].detect { |p| p.include?(url) }
- 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
Method build
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def build(url, query = {})
raise OEmbed::NotFound, url unless include?(url)
query.delete(:timeout)
query.delete(:max_redirects)
- 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"