maa123/mastodon

View on GitHub
app/javascript/mastodon/containers/status_container.jsx

Summary

Maintainability
F
5 days
Test Coverage

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 status_container.jsx has 251 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';

import { connect } from 'react-redux';

import {
Severity: Minor
Found in app/javascript/mastodon/containers/status_container.jsx - About 2 hrs to fix

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

      onReply (status, router) {
        dispatch((_, getState) => {
          let state = getState();
    
          if (state.getIn(['compose', 'text']).trim().length !== 0) {
    Severity: Major
    Found in app/javascript/mastodon/containers/status_container.jsx and 2 other locations - About 6 hrs to fix
    app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js on lines 39..56
    app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 59..75

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

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

    const messages = defineMessages({
      deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
      deleteMessage: { id: 'confirmations.delete.message', defaultMessage: 'Are you sure you want to delete this status?' },
      redraftConfirm: { id: 'confirmations.redraft.confirm', defaultMessage: 'Delete & redraft' },
      redraftMessage: { id: 'confirmations.redraft.message', defaultMessage: 'Are you sure you want to delete this status and re-draft it? Favorites and boosts will be lost, and replies to the original post will be orphaned.' },
    Severity: Major
    Found in app/javascript/mastodon/containers/status_container.jsx and 6 other locations - About 6 hrs to fix
    app/javascript/mastodon/components/account.jsx on lines 24..34
    app/javascript/mastodon/features/compose/components/poll_form.jsx on lines 15..25
    app/javascript/mastodon/features/compose/components/privacy_dropdown.jsx on lines 15..25
    app/javascript/mastodon/features/directory/components/account_card.jsx on lines 26..36
    app/javascript/mastodon/features/notifications/components/notification.jsx on lines 22..32
    app/javascript/mastodon/features/video/index.jsx on lines 18..28

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

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

      onBlockDomain (domain) {
        dispatch(openModal({
          modalType: 'CONFIRM',
          modalProps: {
            message: <FormattedMessage id='confirmations.domain_block.message' defaultMessage='Are you really, really sure you want to block the entire {domain}? In most cases a few targeted blocks or mutes are sufficient and preferable. You will not see content from that domain in any public timelines or your notifications. Your followers from that domain will be removed.' values={{ domain: <strong>{domain}</strong> }} />,
    Severity: Major
    Found in app/javascript/mastodon/containers/status_container.jsx and 2 other locations - About 3 hrs to fix
    app/javascript/mastodon/containers/domain_container.jsx on lines 20..29
    app/javascript/mastodon/features/account_timeline/containers/header_container.jsx on lines 143..152

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

    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 (status.get('translation')) {
          dispatch(undoStatusTranslation(status.get('id'), status.get('poll')));
        } else {
          dispatch(translateStatus(status.get('id')));
        }
    Severity: Major
    Found in app/javascript/mastodon/containers/status_container.jsx and 1 other location - About 1 hr to fix
    app/javascript/mastodon/features/status/index.jsx on lines 429..433

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

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

      onMuteConversation (status) {
        if (status.get('muted')) {
          dispatch(unmuteStatus(status.get('id')));
        } else {
          dispatch(muteStatus(status.get('id')));
    Severity: Major
    Found in app/javascript/mastodon/containers/status_container.jsx and 6 other locations - About 1 hr to fix
    app/javascript/mastodon/containers/status_container.jsx on lines 244..250
    app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js on lines 62..68
    app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js on lines 70..76
    app/javascript/mastodon/features/notifications/containers/notification_container.js on lines 65..71
    app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 169..175
    app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 177..183

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

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

      onToggleHidden (status) {
        if (status.get('hidden')) {
          dispatch(revealStatus(status.get('id')));
        } else {
          dispatch(hideStatus(status.get('id')));
    Severity: Major
    Found in app/javascript/mastodon/containers/status_container.jsx and 6 other locations - About 1 hr to fix
    app/javascript/mastodon/containers/status_container.jsx on lines 236..242
    app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js on lines 62..68
    app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js on lines 70..76
    app/javascript/mastodon/features/notifications/containers/notification_container.js on lines 65..71
    app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 169..175
    app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 177..183

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

    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

      onReblog (status, e) {
        if ((e && e.shiftKey) || !boostModal) {
          this.onModalReblog(status);
        } else {
          dispatch(initBoostModal({ status, onReblog: this.onModalReblog }));
    Severity: Major
    Found in app/javascript/mastodon/containers/status_container.jsx and 1 other location - About 1 hr to fix
    app/javascript/mastodon/features/status/index.jsx on lines 311..317

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

    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

      onEmbed (status) {
        dispatch(openModal({
          modalType: 'EMBED',
          modalProps: {
            id: status.get('id'),
    Severity: Major
    Found in app/javascript/mastodon/containers/status_container.jsx and 1 other location - About 1 hr to fix
    app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 109..117

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

    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

      onOpenVideo (statusId, media, lang, options) {
        dispatch(openModal({
          modalType: 'VIDEO',
          modalProps: { statusId, media, lang, options },
        }));
    Severity: Major
    Found in app/javascript/mastodon/containers/status_container.jsx and 1 other location - About 1 hr to fix
    app/javascript/mastodon/containers/status_container.jsx on lines 197..202

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 55.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

      onOpenMedia (statusId, media, index, lang) {
        dispatch(openModal({
          modalType: 'MEDIA',
          modalProps: { statusId, media, index, lang },
        }));
    Severity: Major
    Found in app/javascript/mastodon/containers/status_container.jsx and 1 other location - About 1 hr to fix
    app/javascript/mastodon/containers/status_container.jsx on lines 204..209

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 55.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

      onPin (status) {
        if (status.get('pinned')) {
          dispatch(unpin(status));
        } else {
          dispatch(pin(status));
    Severity: Major
    Found in app/javascript/mastodon/containers/status_container.jsx and 5 other locations - About 45 mins to fix
    app/javascript/mastodon/containers/status_container.jsx on lines 114..120
    app/javascript/mastodon/containers/status_container.jsx on lines 122..128
    app/javascript/mastodon/features/notifications/containers/notification_container.js on lines 57..63
    app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 93..99
    app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 101..107

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

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

      onFavourite (status) {
        if (status.get('favourited')) {
          dispatch(unfavourite(status));
        } else {
          dispatch(favourite(status));
    Severity: Major
    Found in app/javascript/mastodon/containers/status_container.jsx and 5 other locations - About 45 mins to fix
    app/javascript/mastodon/containers/status_container.jsx on lines 122..128
    app/javascript/mastodon/containers/status_container.jsx on lines 130..136
    app/javascript/mastodon/features/notifications/containers/notification_container.js on lines 57..63
    app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 93..99
    app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 101..107

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

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

      onBookmark (status) {
        if (status.get('bookmarked')) {
          dispatch(unbookmark(status));
        } else {
          dispatch(bookmark(status));
    Severity: Major
    Found in app/javascript/mastodon/containers/status_container.jsx and 5 other locations - About 45 mins to fix
    app/javascript/mastodon/containers/status_container.jsx on lines 114..120
    app/javascript/mastodon/containers/status_container.jsx on lines 130..136
    app/javascript/mastodon/features/notifications/containers/notification_container.js on lines 57..63
    app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 93..99
    app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 101..107

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

    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

    There are no issues that match your filters.

    Category
    Status