maa123/mastodon

View on GitHub
app/javascript/mastodon/features/status/index.jsx

Summary

Maintainability
F
5 days
Test Coverage

File index.jsx has 628 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import PropTypes from 'prop-types';

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

import classNames from 'classnames';
Severity: Major
Found in app/javascript/mastodon/features/status/index.jsx - About 1 day to fix

    Status has 49 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Status extends ImmutablePureComponent {
    
      static contextTypes = {
        router: PropTypes.object,
        identity: PropTypes.object,
    Severity: Minor
    Found in app/javascript/mastodon/features/status/index.jsx - About 6 hrs to fix

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

        render () {
          let ancestors, descendants;
          const { isLoading, status, ancestorsIds, descendantsIds, intl, domain, multiColumn, pictureInPicture } = this.props;
          const { fullscreen } = this.state;
      
      
      Severity: Major
      Found in app/javascript/mastodon/features/status/index.jsx - About 3 hrs to fix

        Function makeMapStateToProps has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const makeMapStateToProps = () => {
          const getStatus = makeGetStatus();
          const getPictureInPicture = makeGetPictureInPicture();
        
          const getAncestorsIds = createSelector([
        Severity: Major
        Found in app/javascript/mastodon/features/status/index.jsx - About 2 hrs to fix

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

            render () {
              let ancestors, descendants;
              const { isLoading, status, ancestorsIds, descendantsIds, intl, domain, multiColumn, pictureInPicture } = this.props;
              const { fullscreen } = this.state;
          
          
          Severity: Minor
          Found in app/javascript/mastodon/features/status/index.jsx - About 55 mins 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 2 locations. Consider refactoring.
          Open

              if (signedIn) {
                if (status.get('favourited')) {
                  dispatch(unfavourite(status));
                } else {
                  dispatch(favourite(status));
          Severity: Major
          Found in app/javascript/mastodon/features/status/index.jsx and 1 other location - About 3 hrs to fix
          app/javascript/mastodon/features/picture_in_picture/components/footer.jsx on lines 104..119

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

          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

            handleConversationMuteClick = (status) => {
              if (status.get('muted')) {
                this.props.dispatch(unmuteStatus(status.get('id')));
              } else {
                this.props.dispatch(muteStatus(status.get('id')));
          Severity: Major
          Found in app/javascript/mastodon/features/status/index.jsx and 1 other location - About 2 hrs to fix
          app/javascript/mastodon/features/status/index.jsx on lines 407..413

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

          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

            handleToggleHidden = (status) => {
              if (status.get('hidden')) {
                this.props.dispatch(revealStatus(status.get('id')));
              } else {
                this.props.dispatch(hideStatus(status.get('id')));
          Severity: Major
          Found in app/javascript/mastodon/features/status/index.jsx and 1 other location - About 2 hrs to fix
          app/javascript/mastodon/features/status/index.jsx on lines 399..405

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

          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

            handleOpenMedia = (media, index, lang) => {
              this.props.dispatch(openModal({
                modalType: 'MEDIA',
                modalProps: { statusId: this.props.status.get('id'), media, index, lang },
              }));
          Severity: Major
          Found in app/javascript/mastodon/features/status/index.jsx and 1 other location - About 2 hrs to fix
          app/javascript/mastodon/features/status/index.jsx on lines 374..379

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

          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

            handleOpenVideo = (media, lang, options) => {
              this.props.dispatch(openModal({
                modalType: 'VIDEO',
                modalProps: { statusId: this.props.status.get('id'), media, lang, options },
              }));
          Severity: Major
          Found in app/javascript/mastodon/features/status/index.jsx and 1 other location - About 2 hrs to fix
          app/javascript/mastodon/features/status/index.jsx on lines 367..372

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

          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

            handleBookmarkClick = (status) => {
              if (status.get('bookmarked')) {
                this.props.dispatch(unbookmark(status));
              } else {
                this.props.dispatch(bookmark(status));
          Severity: Major
          Found in app/javascript/mastodon/features/status/index.jsx and 1 other location - About 1 hr to fix
          app/javascript/mastodon/features/status/index.jsx on lines 263..269

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

          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

            handlePin = (status) => {
              if (status.get('pinned')) {
                this.props.dispatch(unpin(status));
              } else {
                this.props.dispatch(pin(status));
          Severity: Major
          Found in app/javascript/mastodon/features/status/index.jsx and 1 other location - About 1 hr to fix
          app/javascript/mastodon/features/status/index.jsx on lines 330..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 68.

          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/features/status/index.jsx and 1 other location - About 1 hr to fix
          app/javascript/mastodon/containers/status_container.jsx on lines 182..186

          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

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

          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

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

              const { isLoading, status, ancestorsIds, descendantsIds, intl, domain, multiColumn, pictureInPicture } = this.props;
          Severity: Major
          Found in app/javascript/mastodon/features/status/index.jsx and 5 other locations - About 50 mins to fix
          app/javascript/mastodon/components/autosuggest_textarea.jsx on lines 200..200
          app/javascript/mastodon/features/audio/index.jsx on lines 468..468
          app/javascript/mastodon/features/home_timeline/index.jsx on lines 168..168
          app/javascript/mastodon/features/notifications/components/column_settings.jsx on lines 36..36
          app/javascript/mastodon/features/ui/components/report_modal.jsx on lines 138..147

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

          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