mashirozx/mastodon

View on GitHub

Showing 1,785 of 1,785 total issues

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

  handleBlockClick = () => {
    const { status, relationship, onBlock, onUnblock } = this.props;
    const account = status.get('account');

    if (relationship && relationship.get('blocking')) {
Severity: Major
Found in app/javascript/mastodon/components/status_action_bar.js and 3 other locations - About 2 hrs to fix
app/javascript/mastodon/components/status_action_bar.js on lines 171..180
app/javascript/mastodon/features/status/components/action_bar.js on lines 124..133
app/javascript/mastodon/features/status/components/action_bar.js on lines 135..144

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

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

        <div className={classNames('media-gallery__item', { standalone })} key={attachment.get('id')} style={{ left: left, top: top, right: right, bottom: bottom, width: `${width}%`, height: `${height}%` }}>
          <a className='media-gallery__item-thumbnail' href={attachment.get('remote_url') || attachment.get('url')} style={{ cursor: 'pointer' }} title={attachment.get('description')} target='_blank' rel='noopener noreferrer'>
            <Blurhash
              hash={attachment.get('blurhash')}
              className='media-gallery__preview'
Severity: Major
Found in app/javascript/mastodon/components/media_gallery.js and 1 other location - About 2 hrs to fix
app/javascript/mastodon/components/media_gallery.js on lines 353..362

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

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

  case LIST_ACCOUNTS_FETCH_SUCCESS:
    return state.update('accounts', accounts => accounts.withMutations(map => {
      map.set('isLoading', false);
      map.set('loaded', true);
      map.set('items', ImmutableList(action.accounts.map(item => item.id)));
Severity: Major
Found in app/javascript/mastodon/reducers/list_editor.js and 1 other location - About 2 hrs to fix
app/javascript/mastodon/reducers/list_adder.js on lines 34..39

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

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

  case LIST_ADDER_LISTS_FETCH_SUCCESS:
    return state.update('lists', lists => lists.withMutations(map => {
      map.set('isLoading', false);
      map.set('loaded', true);
      map.set('items', ImmutableList(action.lists.map(item => item.id)));
Severity: Major
Found in app/javascript/mastodon/reducers/list_adder.js and 1 other location - About 2 hrs to fix
app/javascript/mastodon/reducers/list_editor.js on lines 74..79

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

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

File feed_manager.rb has 289 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'singleton'

class FeedManager
  include Singleton
  include Redisable
Severity: Minor
Found in app/lib/feed_manager.rb - About 2 hrs to fix

    Function userLists has 73 lines of code (exceeds 25 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: Major
    Found in app/javascript/mastodon/reducers/user_lists.js - About 2 hrs to fix

      Method cull has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          def cull(*domains)
            skip_threshold = 7.days.ago
            dry_run        = options[:dry_run] ? ' (DRY RUN)' : ''
            skip_domains   = Concurrent::Set.new
      
      
      Severity: Minor
      Found in lib/mastodon/accounts_cli.rb - About 2 hrs to fix

      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 cleanup_concurrent_column_type_change has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def cleanup_concurrent_column_type_change(table, column)
            temp_column = rename_column_name(column)
      
            # Wait for the indices to be built
            indexes_for(table, column).each do |index|
      Severity: Major
      Found in lib/mastodon/migration_helpers.rb - About 2 hrs to fix

        File card.js has 286 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import React from 'react';
        import PropTypes from 'prop-types';
        import Immutable from 'immutable';
        import ImmutablePropTypes from 'react-immutable-proptypes';
        import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
        Severity: Minor
        Found in app/javascript/mastodon/features/status/components/card.js - About 2 hrs to fix

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

          const messages = defineMessages({
            title: { id: 'column.directory', defaultMessage: 'Browse profiles' },
            recentlyActive: { id: 'directory.recently_active', defaultMessage: 'Recently active' },
            newArrivals: { id: 'directory.new_arrivals', defaultMessage: 'New arrivals' },
            local: { id: 'directory.local', defaultMessage: 'From {domain} only' },
          Severity: Major
          Found in app/javascript/mastodon/features/directory/index.js and 4 other locations - About 2 hrs to fix
          app/javascript/mastodon/features/compose/components/compose_form.js on lines 33..39
          app/javascript/mastodon/features/compose/components/federation_dropdown.js on lines 11..17
          app/javascript/mastodon/features/list_timeline/index.js on lines 20..26
          app/javascript/mastodon/features/status/components/detailed_status.js on lines 21..27

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

          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

          const messages = defineMessages({
            public_short: { id: 'privacy.public.short', defaultMessage: 'Public' },
            unlisted_short: { id: 'privacy.unlisted.short', defaultMessage: 'Unlisted' },
            private_short: { id: 'privacy.private.short', defaultMessage: 'Followers-only' },
            direct_short: { id: 'privacy.direct.short', defaultMessage: 'Direct' },
          app/javascript/mastodon/features/compose/components/compose_form.js on lines 33..39
          app/javascript/mastodon/features/compose/components/federation_dropdown.js on lines 11..17
          app/javascript/mastodon/features/directory/index.js on lines 17..23
          app/javascript/mastodon/features/list_timeline/index.js on lines 20..26

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

          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

          const messages = defineMessages({
            federate_short: { id: 'federation.federated.short', defaultMessage: 'Federated' },
            federate_long: { id: 'federation.federated.long', defaultMessage: 'Allow toot to reach other instances' },
            local_only_short: { id: 'federation.local_only.short', defaultMessage: 'Local-only' },
            local_only_long: { id: 'federation.local_only.long', defaultMessage: 'Restrict this toot only to my instance' },
          app/javascript/mastodon/features/compose/components/compose_form.js on lines 33..39
          app/javascript/mastodon/features/directory/index.js on lines 17..23
          app/javascript/mastodon/features/list_timeline/index.js on lines 20..26
          app/javascript/mastodon/features/status/components/detailed_status.js on lines 21..27

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

          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

          const messages = defineMessages({
            placeholder: { id: 'compose_form.placeholder', defaultMessage: 'What is on your mind?' },
            spoiler_placeholder: { id: 'compose_form.spoiler_placeholder', defaultMessage: 'Write your warning here' },
            publish: { id: 'compose_form.publish', defaultMessage: 'Publish' },
            publishLoud: { id: 'compose_form.publish_loud', defaultMessage: '{publish}!' },
          app/javascript/mastodon/features/compose/components/federation_dropdown.js on lines 11..17
          app/javascript/mastodon/features/directory/index.js on lines 17..23
          app/javascript/mastodon/features/list_timeline/index.js on lines 20..26
          app/javascript/mastodon/features/status/components/detailed_status.js on lines 21..27

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

          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

          const messages = defineMessages({
            deleteMessage: { id: 'confirmations.delete_list.message', defaultMessage: 'Are you sure you want to permanently delete this list?' },
            deleteConfirm: { id: 'confirmations.delete_list.confirm', defaultMessage: 'Delete' },
            followed:   { id: 'lists.replies_policy.followed', defaultMessage: 'Any followed user' },
            none:    { id: 'lists.replies_policy.none', defaultMessage: 'No one' },
          Severity: Major
          Found in app/javascript/mastodon/features/list_timeline/index.js and 4 other locations - About 2 hrs to fix
          app/javascript/mastodon/features/compose/components/compose_form.js on lines 33..39
          app/javascript/mastodon/features/compose/components/federation_dropdown.js on lines 11..17
          app/javascript/mastodon/features/directory/index.js on lines 17..23
          app/javascript/mastodon/features/status/components/detailed_status.js on lines 21..27

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

          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

          File statuses.js has 285 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import api from '../api';
          
          import { deleteFromTimelines } from './timelines';
          import { importFetchedStatus, importFetchedStatuses, importFetchedAccount } from './importer';
          import { ensureComposeIsVisible, setComposeToStatus } from './compose';
          Severity: Minor
          Found in app/javascript/mastodon/actions/statuses.js - About 2 hrs to fix

            File media_attachment.rb has 285 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class MediaAttachment < ApplicationRecord
              self.inheritance_column = nil
            
              include Attachmentable
            
            
            Severity: Minor
            Found in app/models/media_attachment.rb - About 2 hrs to fix

              StatusActionBar has 25 functions (exceeds 20 allowed). Consider refactoring.
              Open

              export default @connect(mapStateToProps)
              @injectIntl
              class StatusActionBar extends ImmutablePureComponent {
              
                static contextTypes = {
              Severity: Minor
              Found in app/javascript/mastodon/components/status_action_bar.js - About 2 hrs to fix

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

                      if (action.status.get('spoiler_text').length > 0) {
                        map.set('spoiler', true);
                        map.set('spoiler_text', action.status.get('spoiler_text'));
                      } else {
                        map.set('spoiler', false);
                Severity: Major
                Found in app/javascript/mastodon/reducers/compose.js and 2 other locations - About 2 hrs to fix
                app/javascript/mastodon/reducers/compose.js on lines 372..378
                app/javascript/mastodon/reducers/compose.js on lines 391..397

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

                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 3 locations. Consider refactoring.
                Open

                      if (action.status.get('spoiler_text').length > 0) {
                        map.set('spoiler', true);
                        map.set('spoiler_text', action.status.get('spoiler_text'));
                      } else {
                        map.set('spoiler', false);
                Severity: Major
                Found in app/javascript/mastodon/reducers/compose.js and 2 other locations - About 2 hrs to fix
                app/javascript/mastodon/reducers/compose.js on lines 391..397
                app/javascript/mastodon/reducers/compose.js on lines 513..519

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

                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 3 locations. Consider refactoring.
                Open

                      if (action.status.get('spoiler_text').length > 0) {
                        map.set('spoiler', true);
                        map.set('spoiler_text', action.status.get('spoiler_text'));
                      } else {
                        map.set('spoiler', false);
                Severity: Major
                Found in app/javascript/mastodon/reducers/compose.js and 2 other locations - About 2 hrs to fix
                app/javascript/mastodon/reducers/compose.js on lines 372..378
                app/javascript/mastodon/reducers/compose.js on lines 513..519

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

                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

                Severity
                Category
                Status
                Source
                Language