Showing 56 of 56 total issues
Method data
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
def data
paras = []
text = ""
# Detect section Hash in the url and retrive the related paragraphs. if no hash provided the first few paragraphs will be used
- 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 data
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def data
og = ::Onebox::OpenGraph.new(raw)
if raw.at_css('#dp.book_mobile') #printed books
title = raw.at("h1#title")&.inner_text
- 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 resolve_url!
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def resolve_url!
@streetview = false
type, match = match_url
# Resolve shortened URL, if necessary
- 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 fetch_response
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def self.fetch_response(location, limit = nil, domain = nil, headers = nil)
limit ||= 5
limit = Onebox.options.redirect_limit if limit > Onebox.options.redirect_limit
- 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 default_allowed_domains
has 116 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.default_allowed_domains
%w(
23hq.com
500px.com
8tracks.com
Class AllowlistedGenericOnebox
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
class AllowlistedGenericOnebox
include Engine
include StandardEmbed
include LayoutSupport
File allowlisted_generic_onebox.rb
has 340 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'htmlentities'
module Onebox
module Engine
class AllowlistedGenericOnebox
Method calc_range
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def calc_range(m, contents_lines_size)
truncated = false
from = /\d+/.match(m[:from]) #get numeric should only match a positive interger
to = /\d+/.match(m[:to]) #get numeric should only match a positive interger
range_provided = !(from.nil? && to.nil?) #true if "from" or "to" provided in 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 paste_key
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def paste_key
if uri.path =~ /\/raw\//
match = uri.path.match(/\/raw\/([^\/]+)/)
return match[1] if match && match[1]
elsif uri.path =~ /\/download\//
- 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 data
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
def data
og = ::Onebox::OpenGraph.new(raw)
if raw.at_css('#dp.book_mobile') #printed books
title = raw.at("h1#title")&.inner_text
Method resolve_url!
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
def resolve_url!
@streetview = false
type, match = match_url
# Resolve shortened URL, if necessary
Method extract
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def extract(doc)
return {} if Onebox::Helpers::blank?(doc)
data = {}
- 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 raw
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def raw
return @raw if @raw
m = @url.match(self.raw_regexp)
- 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 raw
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def raw
return @raw if @raw
og = get_opengraph
twitter = get_twitter
- 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 data
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
def data
paras = []
text = ""
# Detect section Hash in the url and retrive the related paragraphs. if no hash provided the first few paragraphs will be used
Class TwitterStatusOnebox
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class TwitterStatusOnebox
include Engine
include LayoutSupport
include HTML
Method data
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def data
@data ||= begin
html_entities = HTMLEntities.new
d = { link: link }.merge(raw)
Method get_oembed_url
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def get_oembed_url
oembed_url = nil
StandardEmbed.oembed_providers.each do |regexp, endpoint|
if url =~ regexp
- 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 calc_range
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def calc_range(m, contents_lines_size)
truncated = false
from = /\d+/.match(m[:from]) #get numeric should only match a positive interger
to = /\d+/.match(m[:to]) #get numeric should only match a positive interger
range_provided = !(from.nil? && to.nil?) #true if "from" or "to" provided in URL
Method process_html
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def process_html(html)
return "" unless html
if @options[:max_width]
doc = Nokogiri::HTML5::fragment(html)
- 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"