mashirozx/mastodon

View on GitHub

Showing 1,785 of 1,785 total issues

Function render has 112 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render () {
    const { status, relationship, intl, withDismiss, withCounters, scrollKey } = this.props;

    const anonymousAccess    = !me;
    const publicStatus       = ['public', 'unlisted'].includes(status.get('visibility'));
Severity: Major
Found in app/javascript/mastodon/components/status_action_bar.js - About 4 hrs to fix

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

    const messages = defineMessages({
      close: { id: 'lightbox.close', defaultMessage: 'Close' },
      apply: { id: 'upload_modal.apply', defaultMessage: 'Apply' },
      applying: { id: 'upload_modal.applying', defaultMessage: 'Applying…' },
      placeholder: { id: 'upload_modal.description_placeholder', defaultMessage: 'A quick brown fox jumps over the lazy dog' },
    app/javascript/mastodon/features/direct_timeline/components/conversation.js on lines 17..25

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

    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

    const messages = defineMessages({
      more: { id: 'status.more', defaultMessage: 'More' },
      open: { id: 'conversation.open', defaultMessage: 'View conversation' },
      reply: { id: 'status.reply', defaultMessage: 'Reply' },
      markAsRead: { id: 'conversation.mark_as_read', defaultMessage: 'Mark as read' },
    app/javascript/mastodon/features/ui/components/focal_point_modal.js on lines 27..35

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

    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 interactions.js has 352 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import api from '../api';
    import { importFetchedAccounts, importFetchedStatus } from './importer';
    
    export const REBLOG_REQUEST = 'REBLOG_REQUEST';
    export const REBLOG_SUCCESS = 'REBLOG_SUCCESS';
    Severity: Minor
    Found in app/javascript/mastodon/actions/interactions.js - About 4 hrs to fix

      Method process_update has a Cognitive Complexity of 30 (exceeds 5 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')
      Severity: Minor
      Found in app/lib/user_settings_decorator.rb - About 4 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

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

        const searchContent = ([spoilerText, status.content].concat((status.poll && status.poll.options) ? status.poll.options.map(option => option.title) : [])).concat(status.media_attachments.map(att => att.description)).join('\n\n').replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n');
      Severity: Major
      Found in app/javascript/mastodon/actions/importer/normalizer.js and 1 other location - About 4 hrs to fix
      app/javascript/mastodon/actions/importer/normalizer.js on lines 89..89

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

      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

          const searchContent = ([spoilerText, status.content].concat((status.poll && status.poll.options) ? status.poll.options.map(option => option.title) : [])).concat(status.media_attachments.map(att => att.description)).join('\n\n').replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n');
      Severity: Major
      Found in app/javascript/mastodon/actions/importer/normalizer.js and 1 other location - About 4 hrs to fix
      app/javascript/mastodon/actions/importer/normalizer.js on lines 15..15

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

      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 emoji_picker_dropdown.js has 344 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import React from 'react';
      import PropTypes from 'prop-types';
      import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
      import { EmojiPicker as EmojiPickerAsync } from '../../ui/util/async-components';
      import Overlay from 'react-overlays/lib/Overlay';

        Function render has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

          render () {
            const status = (this.props.status && this.props.status.get('reblog')) ? this.props.status.get('reblog') : this.props.status;
            const outerStyle = { boxSizing: 'border-box' };
            const { intl, compact, pictureInPicture } = this.props;
        
        
        Severity: Minor
        Found in app/javascript/mastodon/features/status/components/detailed_status.js - About 4 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

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

            const visibilityIconInfo = {
              'public': { icon: 'globe', text: intl.formatMessage(messages.public_short) },
              'unlisted': { icon: 'unlock', text: intl.formatMessage(messages.unlisted_short) },
              'private': { icon: 'lock', text: intl.formatMessage(messages.private_short) },
              'direct': { icon: 'at', text: intl.formatMessage(messages.direct_short) },
        Severity: Major
        Found in app/javascript/mastodon/components/status.js and 2 other locations - About 4 hrs to fix
        app/javascript/mastodon/features/status/components/detailed_status.js on lines 296..301
        app/javascript/mastodon/features/ui/components/boost_modal.js on lines 87..92

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

        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

            const visibilityIconInfo = {
              'public': { icon: 'globe', text: intl.formatMessage(messages.public_short) },
              'unlisted': { icon: 'unlock', text: intl.formatMessage(messages.unlisted_short) },
              'private': { icon: 'lock', text: intl.formatMessage(messages.private_short) },
              'direct': { icon: 'at', text: intl.formatMessage(messages.direct_short) },
        app/javascript/mastodon/components/status.js on lines 549..554
        app/javascript/mastodon/features/ui/components/boost_modal.js on lines 87..92

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

        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

              if (action.status.get('poll')) {
                map.set('poll', ImmutableMap({
                  options: action.status.getIn(['poll', 'options']).map(x => x.get('title')),
                  multiple: action.status.getIn(['poll', 'multiple']),
                  expires_in: expiresInFromExpiresAt(action.status.getIn(['poll', 'expires_at'])),
        Severity: Major
        Found in app/javascript/mastodon/reducers/compose.js and 1 other location - About 4 hrs to fix
        app/javascript/mastodon/reducers/compose.js on lines 521..527

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

        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

              if (action.status.get('poll')) {
                map.set('poll', ImmutableMap({
                  options: action.status.getIn(['poll', 'options']).map(x => x.get('title')),
                  multiple: action.status.getIn(['poll', 'multiple']),
                  expires_in: expiresInFromExpiresAt(action.status.getIn(['poll', 'expires_at'])),
        Severity: Major
        Found in app/javascript/mastodon/reducers/compose.js and 1 other location - About 4 hrs to fix
        app/javascript/mastodon/reducers/compose.js on lines 552..558

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

        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

        Method update_column_in_batches has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_column_in_batches(table_name, column, value)
              if transaction_open?
                raise 'update_column_in_batches can not be run inside a transaction, ' \
                  'you can disable transactions by calling disable_ddl_transaction! ' \
                  'in the body of your migration class'
        Severity: Minor
        Found in lib/mastodon/migration_helpers.rb - About 4 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

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

            const visibilityIconInfo = {
              'public': { icon: 'globe', text: intl.formatMessage(messages.public_short) },
              'unlisted': { icon: 'unlock', text: intl.formatMessage(messages.unlisted_short) },
              'private': { icon: 'lock', text: intl.formatMessage(messages.private_short) },
              'direct': { icon: 'at', text: intl.formatMessage(messages.direct_short) },
        app/javascript/mastodon/components/status.js on lines 549..554
        app/javascript/mastodon/features/status/components/detailed_status.js on lines 296..301

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

        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 focal_point_modal.js has 343 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import React from 'react';
        import ImmutablePropTypes from 'react-immutable-proptypes';
        import PropTypes from 'prop-types';
        import ImmutablePureComponent from 'react-immutable-pure-component';
        import { connect } from 'react-redux';
        Severity: Minor
        Found in app/javascript/mastodon/features/ui/components/focal_point_modal.js - About 4 hrs to fix

          File detailed_status.js has 341 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import React from 'react';
          import PropTypes from 'prop-types';
          import ImmutablePropTypes from 'react-immutable-proptypes';
          import Avatar from '../../../components/avatar';
          import DisplayName from '../../../components/display_name';
          Severity: Minor
          Found in app/javascript/mastodon/features/status/components/detailed_status.js - About 4 hrs to fix

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

                return (
                  <div className='compose-form__poll-button'>
                  <IconButton
                    icon='theater-masks'
                    title={intl.formatMessage(active ? messages.marked : messages.unmarked)}
            app/javascript/mastodon/features/compose/components/poll_button.js on lines 39..52

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

            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

                return (
                  <div className='compose-form__poll-button'>
                    <IconButton
                      icon='tasks'
                      title={intl.formatMessage(active ? messages.remove_poll : messages.add_poll)}
            app/javascript/mastodon/features/compose/components/cw_mark_button.js on lines 39..52

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

            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

            Function getData has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
            Open

            function getData(emoji, skin, set) {
              let emojiData = {};
            
              if (typeof emoji === 'string') {
                let matches = emoji.match(COLONS_REGEX);
            Severity: Minor
            Found in app/javascript/mastodon/features/emoji/emoji_utils.js - About 4 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

            Severity
            Category
            Status
            Source
            Language