maa123/mastodon

View on GitHub

Showing 1,813 of 1,813 total issues

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

  onDelete (status, history, withRedraft = false) {
    if (!deleteModal) {
      dispatch(deleteStatus(status.get('id'), history, withRedraft));
    } else {
      dispatch(openModal({
Severity: Major
Found in app/javascript/mastodon/containers/status_container.jsx and 1 other location - About 5 hrs to fix
app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 119..132

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

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

  onDelete (status, history, withRedraft = false) {
    if (!deleteModal) {
      dispatch(deleteStatus(status.get('id'), history, withRedraft));
    } else {
      dispatch(openModal({
app/javascript/mastodon/containers/status_container.jsx on lines 148..161

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

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

  render () {
    const { settings, pushSettings, onChange, onClear, alertsEnabled, browserSupport, browserPermission, onRequestNotificationPermission } = this.props;

    const unreadMarkersShowStr = <FormattedMessage id='notifications.column_settings.unread_notifications.highlight' defaultMessage='Highlight unread notifications' />;
    const filterBarShowStr = <FormattedMessage id='notifications.column_settings.filter_bar.show_bar' defaultMessage='Show filter bar' />;

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

                <tr className={classNames('dimension__item', { negative: !loading && data[1].total > 0 })}>
                  <td className='dimension__item__key'>
                    <FormattedMessage id='admin.impact_report.instance_follows' defaultMessage='Followers their users would lose' />
                  </td>
    
    
    Severity: Major
    Found in app/javascript/mastodon/components/admin/ImpactReport.jsx and 1 other location - About 5 hrs to fix
    app/javascript/mastodon/components/admin/ImpactReport.jsx on lines 76..84

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

    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

                <tr className={classNames('dimension__item', { negative: !loading && data[2].total > 0 })}>
                  <td className='dimension__item__key'>
                    <FormattedMessage id='admin.impact_report.instance_followers' defaultMessage='Followers our users would lose' />
                  </td>
    
    
    Severity: Major
    Found in app/javascript/mastodon/components/admin/ImpactReport.jsx and 1 other location - About 5 hrs to fix
    app/javascript/mastodon/components/admin/ImpactReport.jsx on lines 66..74

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

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

      const streamFrom = (ids, req, output, attachCloseHandler, destinationType, needsFiltering = false) => {
        const accountId = req.accountId || req.remoteAddress;
    
        log.verbose(req.requestId, `Starting stream from ${ids.join(', ')} for ${accountId}`);
    
    
    Severity: Major
    Found in streaming/index.js - About 5 hrs to fix

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

        handleMouseDown = e => {
          document.addEventListener('mousemove', this.handleMouseMove, true);
          document.addEventListener('mouseup', this.handleMouseUp, true);
          document.addEventListener('touchmove', this.handleMouseMove, true);
          document.addEventListener('touchend', this.handleMouseUp, true);
      Severity: Major
      Found in app/javascript/mastodon/features/video/index.jsx and 1 other location - About 5 hrs to fix
      app/javascript/mastodon/features/audio/index.jsx on lines 244..256

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

      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

            if (account.getIn(['relationship', 'muting'])) {
              menu.push({ text: intl.formatMessage(messages.unmute, { name: account.get('username') }), action: this.props.onMute });
            } else {
              menu.push({ text: intl.formatMessage(messages.mute, { name: account.get('username') }), action: this.props.onMute, dangerous: true });
            }
      app/javascript/mastodon/features/account/components/header.jsx on lines 338..342

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

      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

            if (account.getIn(['relationship', 'blocking'])) {
              menu.push({ text: intl.formatMessage(messages.unblock, { name: account.get('username') }), action: this.props.onBlock });
            } else {
              menu.push({ text: intl.formatMessage(messages.block, { name: account.get('username') }), action: this.props.onBlock, dangerous: true });
            }
      app/javascript/mastodon/features/account/components/header.jsx on lines 332..336

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

      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

        handleMouseDown = e => {
          document.addEventListener('mousemove', this.handleMouseMove, true);
          document.addEventListener('mouseup', this.handleMouseUp, true);
          document.addEventListener('touchmove', this.handleMouseMove, true);
          document.addEventListener('touchend', this.handleMouseUp, true);
      Severity: Major
      Found in app/javascript/mastodon/features/audio/index.jsx and 1 other location - About 5 hrs to fix
      app/javascript/mastodon/features/video/index.jsx on lines 227..239

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

      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 mapDispatchToProps has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

      const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
      
        onReply (status, router) {
          dispatch((_, getState) => {
            let state = getState();
      Severity: Minor
      Found in app/javascript/mastodon/containers/status_container.jsx - About 5 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

      File notification.jsx has 384 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import PropTypes from 'prop-types';
      
      import { injectIntl, FormattedMessage, defineMessages } from 'react-intl';
      
      import classNames from 'classnames';

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

          render () {
            const { media, intl, account, onClose, isUploadingThumbnail, description, lang, focusX, focusY, dirty, is_changing_upload } = this.props;
            const { dragging, detecting, progress, ocrStatus } = this.state;
            const x = (focusX /  2) + .5;
            const y = (focusY / -2) + .5;
        Severity: Major
        Found in app/javascript/mastodon/features/ui/components/focal_point_modal.jsx - About 5 hrs to fix

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

            def publish_media_attachments!
              attachment_names = MediaAttachment.attachment_definitions.keys
          
              @account.media_attachments.reorder(nil).find_each do |media_attachment|
                attachment_names.each do |attachment_name|
          Severity: Minor
          Found in app/services/unsuspend_account_service.rb - About 5 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 privatize_media_attachments! has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
          Open

            def privatize_media_attachments!
              attachment_names = MediaAttachment.attachment_definitions.keys
          
              @account.media_attachments.reorder(nil).find_each do |media_attachment|
                attachment_names.each do |attachment_name|
          Severity: Minor
          Found in app/services/suspend_account_service.rb - About 5 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 storage_schema has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
          Open

              def storage_schema
                progress = create_progress_bar(nil)
                records  = 0
          
                klasses = [
          Severity: Minor
          Found in lib/mastodon/cli/upgrade.rb - About 5 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

          Class ProcessAccountService has 38 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class ActivityPub::ProcessAccountService < BaseService
            include JsonLdHelper
            include DomainControlHelper
            include Redisable
            include Lockable
          Severity: Minor
          Found in app/services/activitypub/process_account_service.rb - About 5 hrs to fix

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

                    if (relationship && relationship.get('blocking')) {
                      menu.push({ text: intl.formatMessage(messages.unblock, { name: account.get('username') }), action: this.handleBlockClick });
                    } else {
                      menu.push({ text: intl.formatMessage(messages.block, { name: account.get('username') }), action: this.handleBlockClick, dangerous: true });
                    }
            Severity: Major
            Found in app/javascript/mastodon/components/status_action_bar.jsx and 3 other locations - About 4 hrs to fix
            app/javascript/mastodon/components/status_action_bar.jsx on lines 290..294
            app/javascript/mastodon/features/status/components/action_bar.jsx on lines 230..234
            app/javascript/mastodon/features/status/components/action_bar.jsx on lines 236..240

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

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

                    if (relationship && relationship.get('blocking')) {
                      menu.push({ text: intl.formatMessage(messages.unblock, { name: account.get('username') }), action: this.handleBlockClick });
                    } else {
                      menu.push({ text: intl.formatMessage(messages.block, { name: account.get('username') }), action: this.handleBlockClick, dangerous: true });
                    }
            app/javascript/mastodon/components/status_action_bar.jsx on lines 290..294
            app/javascript/mastodon/components/status_action_bar.jsx on lines 296..300
            app/javascript/mastodon/features/status/components/action_bar.jsx on lines 230..234

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

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

                    if (relationship && relationship.get('muting')) {
                      menu.push({ text: intl.formatMessage(messages.unmute, { name: account.get('username') }), action: this.handleMuteClick });
                    } else {
                      menu.push({ text: intl.formatMessage(messages.mute, { name: account.get('username') }), action: this.handleMuteClick, dangerous: true });
                    }
            Severity: Major
            Found in app/javascript/mastodon/components/status_action_bar.jsx and 3 other locations - About 4 hrs to fix
            app/javascript/mastodon/components/status_action_bar.jsx on lines 296..300
            app/javascript/mastodon/features/status/components/action_bar.jsx on lines 230..234
            app/javascript/mastodon/features/status/components/action_bar.jsx on lines 236..240

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

            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