Showing 1,785 of 1,785 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
def collection_presenter
if page_requested?
ActivityPub::CollectionPresenter.new(
id: account_followers_url(@account, page: params.fetch(:page, 1)),
type: :ordered,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 55.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def collection_presenter
if page_requested?
ActivityPub::CollectionPresenter.new(
id: account_following_index_url(@account, page: params.fetch(:page, 1)),
type: :ordered,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 55.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function selectComposeSuggestion
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function selectComposeSuggestion(position, token, suggestion, path) {
return (dispatch, getState) => {
let completion, startPosition;
if (suggestion.type === 'emoji') {
Function expandTimeline
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function expandTimeline(timelineId, path, params = {}, done = noOp) {
return (dispatch, getState) => {
const timeline = getState().getIn(['timelines', timelineId], ImmutableMap());
const isLoadingMore = !!params.max_id;
Function render
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
render () {
const { src, width, height, alt } = this.props;
const { loading } = this.state;
return (
Function expandNormalizedNotifications
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
const expandNormalizedNotifications = (state, notifications, next, isLoadingRecent, usePendingItems) => {
const lastReadId = state.get('lastReadId');
let items = ImmutableList();
notifications.forEach((n, i) => {
Function render
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
render () {
const { value, intl } = this.props;
const { open, placement } = this.state;
const valueOption = this.options.find(item => item.value === value);
Function push_subscriptions
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function push_subscriptions(state = initialState, action) {
switch(action.type) {
case STORE_HYDRATE: {
const push_subscription = action.state.get('push_subscription');
Function render
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
render () {
const { isPollMultiple, title, index, autoFocus, intl } = this.props;
return (
<li>
Method remotable_attachment
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def remotable_attachment(attachment_name, limit, suppress_errors: true, download_on_assign: true, attribute_name: nil)
attribute_name ||= "#{attachment_name}_remote_url".to_sym
define_method("download_#{attachment_name}!") do |url = nil|
url ||= self[attribute_name]
Function render
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
render () {
const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus, className, id, maxLength } = this.props;
const { suggestionsHidden } = this.state;
return (
Function renderVideo
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
renderVideo () {
const { card, intl } = this.props;
const content = { __html: this.addAutoPlay(card.get('html')) };
const { width } = this.state;
const ratio = card.get('width') / card.get('height');
Function onChange
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
onChange (path, checked) {
if (path[0] === 'push') {
if (checked && typeof window.Notification !== 'undefined' && Notification.permission !== 'granted') {
dispatch(requestBrowserPermission((permission) => {
if (permission === 'granted') {
Method update_count!
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_count!(key, value)
raise ArgumentError, "Invalid key #{key}" unless ALLOWED_COUNTER_KEYS.include?(key)
raise ArgumentError, 'Do not call update_count! on dirty objects' if association(:account_stat).loaded? && account_stat&.changed? && account_stat.changed_attribute_names_to_save == %w(id)
value = value.to_i
Method calculate_scores
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def calculate_scores(preview_cards, at_time)
global_items = []
locale_items = Hash.new { |h, key| h[key] = [] }
preview_cards.each do |preview_card|
Function conversations
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function conversations(state = initialState, action) {
switch (action.type) {
case CONVERSATIONS_FETCH_REQUEST:
return state.set('isLoading', true);
case CONVERSATIONS_FETCH_FAIL:
Method process_update
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_update
user.settings['notification_emails'] = merged_notification_emails if change?('notification_emails')
user.settings['interactions'] = merged_interactions if change?('interactions')
user.settings['default_privacy'] = default_privacy_preference if change?('setting_default_privacy')
user.settings['default_sensitive'] = default_sensitive_preference if change?('setting_default_sensitive')
Method call
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def call(username, domain, json, options = {})
return if json['inbox'].blank? || unsupported_uri_scheme?(json['id']) || domain_not_allowed?(domain)
@options = options
@json = json
Method klass
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def klass
case @json['type']
when 'Create'
ActivityPub::Activity::Create
when 'Announce'
Method perform
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform
# Maintaining a materialized view speeds-up subsequent queries significantly
AccountSummary.refresh
FollowRecommendation.refresh