mashirozx/mastodon

View on GitHub

Showing 1,785 of 1,785 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      <div tabIndex='0' role='button' className={classNames('report-reason-selector__category', { selected, disabled })} onClick={this.handleClick}>
        {selected && <input type='hidden' name='report[category]' value={id} />}

        <div className='report-reason-selector__category__label'>
          <span className={classNames('poll__input', { active: selected, disabled })} />
app/javascript/mastodon/components/admin/ReportReasonSelector.js on lines 77..81

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 49.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      <div tabIndex='0' role='button' className={classNames('report-reason-selector__rule', { selected, disabled })} onClick={this.handleClick}>
        <span className={classNames('poll__input', { checkbox: true, active: selected, disabled })} />
        {selected && <input type='hidden' name='report[rule_ids][]' value={id} />}
        {text}
      </div>
app/javascript/mastodon/components/admin/ReportReasonSelector.js on lines 36..49

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 49.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        {isLoading ? <LoadingIndicator /> : suggestions.map(suggestion => (
          <AccountCard key={suggestion.get('account')} id={suggestion.get('account')} />
        ))}
Severity: Minor
Found in app/javascript/mastodon/features/explore/suggestions.js and 1 other location - About 40 mins to fix
app/javascript/mastodon/features/follow_recommendations/index.js on lines 89..91

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 49.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        <div className='search-results__header'>
          <Icon id='search' fixedWidth />
          <FormattedMessage id='search_results.total' defaultMessage='{count, number} {count, plural, one {result} other {results}}' values={{ count }} />
        </div>
app/javascript/mastodon/features/filters/select_filter.js on lines 78..80

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 49.

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

Further Reading

Similar blocks of code found in 5 locations. Consider refactoring.
Open

  def perform_data_query
    sql = <<-SQL.squish
      SELECT axis.*, (
        WITH new_accounts AS (
          SELECT accounts.id
Severity: Major
Found in app/lib/admin/metrics/measure/instance_accounts_measure.rb and 4 other locations - About 40 mins to fix
app/lib/admin/metrics/measure/instance_followers_measure.rb on lines 26..45
app/lib/admin/metrics/measure/instance_follows_measure.rb on lines 26..45
app/lib/admin/metrics/measure/instance_media_attachments_measure.rb on lines 36..55
app/lib/admin/metrics/measure/instance_reports_measure.rb on lines 26..45

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 38.

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

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

  def queue_poll_notifications!
    poll = @status.preloadable_poll

    # If the poll had no expiration date set but now has, or now has a sooner
    # expiration date, and people have voted, schedule a notification
Severity: Minor
Found in app/services/update_status_service.rb and 1 other location - About 40 mins to fix
app/services/activitypub/process_status_update_service.rb on lines 281..290

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 38.

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

Further Reading

Similar blocks of code found in 5 locations. Consider refactoring.
Open

  def perform_data_query
    sql = <<-SQL.squish
      SELECT axis.*, (
        WITH new_followers AS (
          SELECT follows.id
Severity: Major
Found in app/lib/admin/metrics/measure/instance_followers_measure.rb and 4 other locations - About 40 mins to fix
app/lib/admin/metrics/measure/instance_accounts_measure.rb on lines 26..44
app/lib/admin/metrics/measure/instance_follows_measure.rb on lines 26..45
app/lib/admin/metrics/measure/instance_media_attachments_measure.rb on lines 36..55
app/lib/admin/metrics/measure/instance_reports_measure.rb on lines 26..45

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 38.

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

Further Reading

Similar blocks of code found in 5 locations. Consider refactoring.
Open

  def perform_data_query
    sql = <<-SQL.squish
      SELECT axis.*, (
        WITH new_media_attachments AS (
          SELECT COALESCE(media_attachments.file_file_size, 0) + COALESCE(media_attachments.thumbnail_file_size, 0) AS size
app/lib/admin/metrics/measure/instance_accounts_measure.rb on lines 26..44
app/lib/admin/metrics/measure/instance_followers_measure.rb on lines 26..45
app/lib/admin/metrics/measure/instance_follows_measure.rb on lines 26..45
app/lib/admin/metrics/measure/instance_reports_measure.rb on lines 26..45

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 38.

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

Further Reading

Similar blocks of code found in 5 locations. Consider refactoring.
Open

  def perform_data_query
    sql = <<-SQL.squish
      SELECT axis.*, (
        WITH new_reports AS (
          SELECT reports.id
Severity: Major
Found in app/lib/admin/metrics/measure/instance_reports_measure.rb and 4 other locations - About 40 mins to fix
app/lib/admin/metrics/measure/instance_accounts_measure.rb on lines 26..44
app/lib/admin/metrics/measure/instance_followers_measure.rb on lines 26..45
app/lib/admin/metrics/measure/instance_follows_measure.rb on lines 26..45
app/lib/admin/metrics/measure/instance_media_attachments_measure.rb on lines 36..55

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 38.

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

Further Reading

Similar blocks of code found in 5 locations. Consider refactoring.
Open

  def perform_data_query
    sql = <<-SQL.squish
      SELECT axis.*, (
        WITH new_follows AS (
          SELECT follows.id
Severity: Major
Found in app/lib/admin/metrics/measure/instance_follows_measure.rb and 4 other locations - About 40 mins to fix
app/lib/admin/metrics/measure/instance_accounts_measure.rb on lines 26..44
app/lib/admin/metrics/measure/instance_followers_measure.rb on lines 26..45
app/lib/admin/metrics/measure/instance_media_attachments_measure.rb on lines 36..55
app/lib/admin/metrics/measure/instance_reports_measure.rb on lines 26..45

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 38.

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

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

  def queue_poll_notifications!
    poll = @status.preloadable_poll

    # If the poll had no expiration date set but now has, or now has a sooner
    # expiration date, and people have voted, schedule a notification
Severity: Minor
Found in app/services/activitypub/process_status_update_service.rb and 1 other location - About 40 mins to fix
app/services/update_status_service.rb on lines 133..142

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 38.

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

Further Reading

Consider simplifying this complex logical expression.
Open

  if (normalOldStatus && normalOldStatus.get('content') === normalStatus.content && normalOldStatus.get('spoiler_text') === normalStatus.spoiler_text) {
    normalStatus.search_index = normalOldStatus.get('search_index');
    normalStatus.contentHtml = normalOldStatus.get('contentHtml');
    normalStatus.spoilerHtml = normalOldStatus.get('spoilerHtml');
    normalStatus.spoiler_text = normalOldStatus.get('spoiler_text');
Severity: Major
Found in app/javascript/mastodon/actions/importer/normalizer.js - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

        } else if (attachment.get('type') === 'image') {
          const previewUrl   = attachment.get('preview_url');
          const previewWidth = attachment.getIn(['meta', 'small', 'width']);
    
          const originalUrl   = attachment.get('url');
    Severity: Major
    Found in app/javascript/mastodon/components/media_gallery.js - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

          } else if(results.get('statuses') && results.get('statuses').size === 0 && !searchEnabled && !(searchTerm.startsWith('@') || searchTerm.startsWith('#') || searchTerm.includes(' '))) {
            statuses = (
              <div className='search-results__section'>
                <h5><Icon id='quote-right' fixedWidth /><FormattedMessage id='search_results.statuses' defaultMessage='Posts' /></h5>
      
      
      Severity: Major
      Found in app/javascript/mastodon/features/compose/components/search_results.js - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

          if (typeof hasBoundingRectBug !== 'boolean') {
            const boundingRect = entry.target.getBoundingClientRect();
            const observerRect = entry.boundingClientRect;
            hasBoundingRectBug = boundingRect.height !== observerRect.height ||
              boundingRect.top !== observerRect.top ||
        Severity: Major
        Found in app/javascript/mastodon/features/ui/util/get_rect_from_entry.js - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

              } else if (!statuses.isEmpty()) {
                usePendingItems = isLoadingRecent && (usePendingItems || !mMap.get('pendingItems').isEmpty());
          
                mMap.update(usePendingItems ? 'pendingItems' : 'items', ImmutableList(), oldIds => {
                  const newIds = statuses.map(status => status.get('id'));
          Severity: Major
          Found in app/javascript/mastodon/reducers/timelines.js - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                if (!items.isEmpty()) {
                  usePendingItems = isLoadingRecent && (usePendingItems || !mutable.get('pendingItems').isEmpty());
            
                  mutable.update(usePendingItems ? 'pendingItems' : 'items', list => {
                    const lastIndex = 1 + list.findLastIndex(
            Severity: Major
            Found in app/javascript/mastodon/reducers/notifications.js - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                  } else if(results.get('statuses') && results.get('statuses').size === 0 && !searchEnabled && !(searchTerm.startsWith('@') || searchTerm.startsWith('#') || searchTerm.includes(' '))) {
                    statuses = (
                      <div className='search-results__section'>
                        <h5><Icon id='quote-right' fixedWidth /><FormattedMessage id='search_results.statuses' defaultMessage='Posts' /></h5>
              
              
              Severity: Major
              Found in app/javascript/mastodon/features/compose/components/search_results.js - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                    if (filter[3] || filter[4]) {
                      warning = (
                        <span className='language-dropdown__dropdown__results__item__common-name'>
                          (
                          {filter[3] && <FormattedMessage id='filter_modal.select_filter.expired' defaultMessage='expired' />}
                Severity: Major
                Found in app/javascript/mastodon/features/filters/select_filter.js - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                      if preloaded.nil?
                        ids += mentions.where(account: Account.local, silent: false).pluck(:account_id)
                        ids += favourites.where(account: Account.local).pluck(:account_id)
                        ids += reblogs.where(account: Account.local).pluck(:account_id)
                        ids += bookmarks.where(account: Account.local).pluck(:account_id)
                  Severity: Major
                  Found in app/models/status.rb - About 40 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language