Showing 132 of 189 total issues
Method facts
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def facts
facts = []
profile.positions.each do |position|
name = build_name(position)
Method expand
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.expand(audience)
audience.keys.map(&:to_sym).collect do |target|
if target == :user_reach
user = User.find(audience[target])
Method to_indexed_json
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def to_indexed_json
to_public_hash.deep_merge(
{
trending_score: trending_score,
popular_score: value_score,
Method user_update_params
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def user_update_params
params.require(:user).permit(:about,
:avatar,
:avatar_cache,
:banner,
Method weekly_digest
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def weekly_digest(username)
headers['X-Mailgun-Variables'] = {email_type: WEEKLY_DIGEST_EVENT}.to_json
track_campaign(WEEKLY_DIGEST_EVENT)
@user = User.find_by_username(username)
- 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 page_title
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def page_title(override_from_haml = nil)
return override_from_haml unless override_from_haml.blank?
if viewing_self?
if @user.pending?
"coderwall.com : your profile (in queue)"
- 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 upvote_velocity
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def upvote_velocity(since = Time.at(0))
Rails.logger.ap since if ENV['DEBUG']
us = upvotes_since(since)
Rails.logger.ap us if ENV['DEBUG']
- 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 create
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create
@user = (params[:user_id] && User.find(params[:user_id])) || current_user
return head(:forbidden) unless current_user == @user
if params[:skill][:name] == "skills separated by comma"
skill_names = []
- 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 search
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.search(query_string, country, page, per_page, search_type = :query_and_fetch)
country = query_string.gsub!(/country:(.+)/, '') && $1 if country.nil?
query = ''
if query_string.blank? or query_string =~ /:/
- 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 protip_topic_page_title
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def protip_topic_page_title(topics)
username = topics.is_a?(Array) ? (topics.size == 1 ? topics.first : nil) : topics
unless username.nil? or (user = User.find_by_username(username)).blank?
"Coderwall - Trending Pro tips by #{user.name}"
else
- 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 create
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
#FIXME
raise "OmniAuth returned error #{params[:error]}" unless params[:error].blank?
if signed_in?
current_user.apply_oauth(oauth)
Method show
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
@user = User.find_by_username!(params[:username])
respond_to do |format|
format.html do
Method perform
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform
# ArgumentError: Missing host to link to! Please provide the :host parameter, set default_path_options[:host], or set :only_path to true
SitemapGenerator::Sitemap.default_host = 'https://coderwall.com'
SitemapGenerator::Sitemap.public_path = 'tmp/'
SitemapGenerator::Sitemap.sitemaps_host = "http://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com/"
Method validate_each
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(object, attribute, value)
raise(ArgumentError, "A regular expression must be supplied as the :format option of the options hash") unless options[:format].nil? or options[:format].is_a?(Regexp)
configuration = {message: "is invalid or not responding", format: URI::regexp(%w(http https))}
configuration.update(options)
- 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_lanyrd_facts!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_skills_for_lanyrd_facts!
tokenized_lanyrd_tags.each do |lanyrd_tag|
if self.skills.any?
skill = skill_for(lanyrd_tag)
skill.apply_facts unless skill.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 upvote_by
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def upvote_by(voter, tracking_code, ip_address)
begin
unless already_voted?(voter, tracking_code, ip_address) or (self.author.id == voter.try(:id))
self.likes.create(user: voter, value: voter.nil? ? 1 : adjust_like_value(voter, voter.like_value), tracking_code: tracking_code, ip_address: ip_address)
generate_event(voter: voter.username) unless voter.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 viewed_by
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def viewed_by(viewer)
epoch_now = Time.now.to_i
Redis.current.incr(impressions_key)
if viewer.is_a?(User)
Redis.current.zadd(user_views_key, epoch_now, viewer.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 apply_oauth
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def apply_oauth(oauth)
case oauth[:provider]
when 'github'
self.github = oauth[:info][:nickname]
self.github_id = oauth[:uid]
- 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 perform
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform(id)
client = Octokit::Client.new
if ENV['TRAVIS'].blank? && client.ratelimit[:remaining] < 1000
# If we have less than 1000 request remaining, delay this job
# We leaving 1000 for more critical tasks
Method search_for_popular_protips
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.search_for_popular_protips(from, to, max_results=10)
url = "#{ENV['ELASTICSEARCH_URL']}/#{ENV['ELASTICSEARCH_PROTIPS_INDEX']}/_search"
query = {
'query' => {
'bool' => {