Showing 132 of 189 total issues
Method search
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def search(query_string, tags =[], options={})
query, team, author, bookmarked_by, execution, sorts= preprocess_query(query_string)
tags = [] if tags.nil?
tags = preprocess_tags(tags)
tag_ids = process_tags_for_search(tags)
Consider simplifying this complex logical expression. Open
unless query_string.nil?
query = query_string.dup
query.gsub!(/(\d+)\"/, "\\1\\\"") #handle 27" cases
team = query.gsub!(/(team:([0-9A-Z\-]+))/i, "") && $2
team = (team =~ /^[a-f0-9]+$/i && team.length == 24 ? team : Team.where(slug: team).first.try(:id))
Method upvote_ancestor
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def upvote_ancestor(link_identifier, link)
ProtipLink.where(identifier: link_identifier).order('created_at ASC').first.try(:tap) do |ancestor|
if (ancestor.protip != self) and (ancestor.protip.author.id != self.author.id) and (ancestor.url == link)
ancestor.protip.upvote_by(self.user, self.user.tracking_code, DEFAULT_IP_ADDRESS) unless ancestor.nil? || ancestor.protip.nil?
break
- 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 topics_to_query
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def topics_to_query(topics)
topics = topics.split(" + ") unless topics.nil? or topics.is_a? Array
topics.map do |topic|
if Protip::USER_SCOPE.include? topic or topic =~ /^team:/ or topic =~ /^author:/
topic
- 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 process_links
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def process_links
if self.body_changed?
self.links.each do |link|
link_identifier = ProtipLink.generate_identifier(link)
existing_link = self.protip_links.find_or_initialize_by_identifier(identifier: link_identifier, url: link.first(254))
- 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 record_visit
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def record_visit
if viewing_user
if viewing_user == current_user && (viewing_user.try(:last_request_at) || 1.week.ago) < 1.day.ago && viewing_user.active? && viewing_user.last_refresh_at < 2.days.ago
RefreshUserJob.perform_async(current_user.id)
end
- 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 accept
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def accept
apply_cache_buster
accept_params = params.permit(:id, :r, :email)
- 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 facts
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def facts
facts = []
profile.positions.each do |position|
name = build_name(position)
- 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 sanitize_tags!
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def sanitize_tags!
new_topics = self.topic_list.reject { |tag| tag.blank? }.map do |topic|
sanitized_topic = self.class.preprocess_tag(topic)
invalid_topic = topic.match("^((?!#{VALID_TAG}).)*$") && $1
errors[:topics] << "The tag '#{topic}' has invalid characters: #{invalid_topic unless invalid_topic.nil?}" if sanitized_topic.nil?
- 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 append!
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.append!(identity, owner, name, date, url, tags, metadata = nil)
Method visitor_data
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def visitor_data(exit_url, exit_target_type, furthest_scrolled, time_spent, user_id, visited_at, user)
Method initialize
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(context, query=nil, scope=nil, sort=nil, facet=nil, options={})
Method get_jobs_for
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_jobs_for(chosen_location, tag, page, query = nil, remote_allowed = false)
scope = Opportunity
escaped_query = query.nil? ? query : Regexp.escape(query)
- 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 deeply nested control flow statements. Open
expand_followers(user) unless user.nil?
Method event_audience
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def event_audience(event_type)
audience = {}
case event_type
when :protip_view, :protip_upvote
audience = Audience.user(self.author.id)
- 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 expand_reach
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.expand_reach(user_or_team)
audiences = []
audiences.concat(expand_followers(user_or_team))
if user_or_team.is_a?(Team)
- 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 index
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def index
current_user.seen(:jobs) if signed_in?
store_location! unless signed_in?
chosen_location = (params[:location] || closest_to_user(current_user)).try(:titleize)
chosen_location = nil if chosen_location == 'Worldwide'
- 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 add_skills_for_repo_facts!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add_skills_for_repo_facts!
repo_facts.each do |fact|
fact.metadata[:languages].try(:each) do |language|
unless self.deleted_skill?(language)
skill = add_skill(language)
- 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 deeply nested control flow statements. Open
elsif target == :team_followers
team = Team.find(audience[target])
expand_followers(team) unless team.nil?
elsif target == :all
expand_all_users
Method perform
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def perform(user_id, protip_ids, from, to)
fail "Only #{protip_ids.count} protips but expected 10" unless protip_ids.count == 10
begin
if REDIS.sismember(ProtipMailer::CAMPAIGN_ID, user_id.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"