glitch-soc/mastodon

View on GitHub

Showing 1,282 of 4,885 total issues

Method validate_target_account has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def validate_target_account
if target_account.nil?
errors.add(:acct, I18n.t('migrations.errors.not_found'))
else
errors.add(:acct, I18n.t('migrations.errors.missing_also_known_as')) unless target_account.also_known_as.include?(ActivityPub::TagManager.instance.uri_for(account))
Severity: Minor
Found in app/models/account_migration.rb - About 1 hr to fix

Method check_video_dimensions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def check_video_dimensions
return unless (video? || gifv?) && file.queued_for_write[:original].present?
 
movie = ffmpeg_data(file.queued_for_write[:original].path)
 
 
Severity: Minor
Found in app/models/media_attachment.rb - About 1 hr to fix

Function userLists has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export default function userLists(state = initialState, action) {
switch(action.type) {
case FOLLOWERS_FETCH_SUCCESS:
return normalizeList(state, ['followers', action.id], action.accounts, action.next);
case FOLLOWERS_EXPAND_SUCCESS:
Severity: Minor
Found in app/javascript/mastodon/reducers/user_lists.js - About 1 hr to fix

Method statuses_to_delete has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def statuses_to_delete(limit = 50, max_id = nil, min_id = nil)
scope = account_statuses
scope.merge!(old_enough_scope(max_id))
scope = scope.where(id: min_id..) if min_id.present?
scope.merge!(without_popular_scope) unless min_favs.nil? && min_reblogs.nil?
Severity: Minor
Found in app/models/account_statuses_cleanup_policy.rb - About 1 hr to fix

Method policies has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def policies
if suspend?
[:suspend]
else
[severity.to_sym, reject_media? ? :reject_media : nil, reject_reports? ? :reject_reports : nil]
Severity: Minor
Found in app/models/domain_block.rb - About 1 hr to fix

Method request_follow! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def request_follow!(other_account, reblogs: nil, notify: nil, languages: nil, uri: nil, rate_limit: false, bypass_limit: false)
rel = follow_requests.create_with(show_reblogs: reblogs.nil? || reblogs, notify: notify.nil? ? false : notify, uri: uri, languages: languages, rate_limit: rate_limit, bypass_follow_limit: bypass_limit)
.find_or_create_by!(target_account: other_account)
 
rel.show_reblogs = reblogs unless reblogs.nil?
Severity: Minor
Found in app/models/concerns/account/interactions.rb - About 1 hr to fix

Method relevant_account_timestamp has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def relevant_account_timestamp(account)
timestamp, exact = if account.user_current_sign_in_at && account.user_current_sign_in_at < 24.hours.ago
[account.user_current_sign_in_at, true]
elsif account.user_current_sign_in_at
[account.user_current_sign_in_at, false]
Severity: Minor
Found in app/helpers/admin/dashboard_helper.rb - About 1 hr to fix

Method show? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def show?
return false if author.unavailable?
return false if local_only? && (current_account.nil? || !current_account.local?)
 
if requires_mention?
Severity: Minor
Found in app/policies/status_policy.rb - About 1 hr to fix

Method actor_from_key_id has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def actor_from_key_id(key_id)
domain = key_id.start_with?('acct:') ? key_id.split('@').last : key_id
 
if domain_not_allowed?(domain)
@signature_verification_failure_code = 403
Severity: Minor
Found in app/controllers/concerns/signature_verification.rb - About 1 hr to fix

Method render_with_cache has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def render_with_cache(**options)
raise ArgumentError, 'Only JSON render calls are supported' unless options.key?(:json) || block_given?
 
key = options.delete(:key) || [[params[:controller], params[:action]].join('/'), options[:json].respond_to?(:cache_key) ? options[:json].cache_key : nil, options[:fields]&.join(',')].compact.join(':')
expires_in = options.delete(:expires_in) || 3.minutes
Severity: Minor
Found in app/controllers/concerns/cache_concern.rb - About 1 hr to fix

Method show has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def show
return not_found if @status.hidden?
 
if @status.local?
render json: @status, serializer: OEmbedSerializer
Severity: Minor
Found in app/controllers/api/web/embeds_controller.rb - About 1 hr to fix

Method update_account has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def update_account
@account.last_webfingered_at = Time.now.utc unless @options[:only_key]
@account.protocol = :activitypub
 
set_suspension!
Severity: Minor
Found in app/services/activitypub/process_account_service.rb - About 1 hr to fix

Method update_media_attachments! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def update_media_attachments!
previous_media_attachments = @status.media_attachments.to_a
previous_media_attachments_ids = @status.ordered_media_attachment_ids || previous_media_attachments.map(&:id)
@next_media_attachments = []
 
 
Severity: Minor
Found in app/services/activitypub/process_status_update_service.rb - About 1 hr to fix

Method update_counts! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def update_counts!
likes = @status_parser.favourites_count
shares = @status_parser.reblogs_count
return if likes.nil? && shares.nil?
 
 
Severity: Minor
Found in app/services/activitypub/process_status_update_service.rb - About 1 hr to fix

Method extend_csp_for_captcha! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def extend_csp_for_captcha!
policy = request.content_security_policy&.clone
 
return unless captcha_required? && policy.present?
 
 
Severity: Minor
Found in app/controllers/concerns/auth/captcha_concern.rb - About 1 hr to fix

Method update_metadata! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def update_metadata!
@raw_tags = []
@raw_mentions = []
@raw_emojis = []
 
 
Severity: Minor
Found in app/services/activitypub/process_status_update_service.rb - About 1 hr to fix

Method call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def call(status)
@status = status
@original_url = parse_urls
 
return if @original_url.nil? || @status.with_preview_card?
Severity: Minor
Found in app/services/fetch_link_card_service.rb - About 1 hr to fix

Method preprocess_attributes! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def preprocess_attributes!
fill_blank_text!
@sensitive = (@options[:sensitive].nil? ? @account.user&.setting_default_sensitive : @options[:sensitive]) || @options[:spoiler_text].present?
@visibility = @options[:visibility] || @account.user&.setting_default_privacy
@visibility = :unlisted if @visibility&.to_sym == :public && @account.silenced?
Severity: Minor
Found in app/services/post_status_service.rb - About 1 hr to fix

Method remove_from_feed has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def remove_from_feed(timeline_type, account_id, status, aggregate_reblogs: true)
timeline_key = key(timeline_type, account_id)
reblog_key = key(timeline_type, account_id, 'reblogs')
 
if status.reblog? && (aggregate_reblogs.nil? || aggregate_reblogs)
Severity: Minor
Found in app/lib/feed_manager.rb - About 1 hr to fix

Method perform has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def perform
target_account = account_from_uri(object_uri)
 
return if target_account.nil? || !target_account.local? || delete_arrived_first?(@json['id'])
 
 
Severity: Minor
Found in app/lib/activitypub/activity/follow.rb - About 1 hr to fix
Severity
Category
Status
Source
Language