mashirozx/mastodon

View on GitHub

Showing 1,785 of 1,785 total issues

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

    if (results.get('statuses') && results.get('statuses').size > 0) {
      count   += results.get('statuses').size;
      statuses = (
        <div className='search-results__section'>
          <h5><Icon id='quote-right' fixedWidth /><FormattedMessage id='search_results.statuses' defaultMessage='Posts' /></h5>
app/javascript/mastodon/features/compose/components/search_results.js on lines 77..88

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

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 status.rb has 464 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Status < ApplicationRecord
  before_destroy :unlink_from_conversations

  include Discard::Model
  include Paginable
Severity: Minor
Found in app/models/status.rb - About 7 hrs to fix

    File index.js has 455 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import classNames from 'classnames';
    import React from 'react';
    import { HotKeys } from 'react-hotkeys';
    import { defineMessages, injectIntl } from 'react-intl';
    import { connect } from 'react-redux';
    Severity: Minor
    Found in app/javascript/mastodon/features/ui/index.js - About 6 hrs to fix

      File account.rb has 453 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class Account < ApplicationRecord
        self.ignored_columns = %w(
          subscription_expires_at
          secret
          remote_url
      Severity: Minor
      Found in app/models/account.rb - About 6 hrs to fix

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

        const messages = defineMessages({
          start: { id: 'getting_started.heading', defaultMessage: 'Getting started' },
          home_timeline: { id: 'tabs_bar.home', defaultMessage: 'Home' },
          notifications: { id: 'tabs_bar.notifications', defaultMessage: 'Notifications' },
          public: { id: 'navigation_bar.public_timeline', defaultMessage: 'Federated timeline' },
        Severity: Major
        Found in app/javascript/mastodon/features/compose/index.js and 1 other location - About 6 hrs to fix
        app/javascript/mastodon/features/report/category.js on lines 9..20

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

        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({
          dislike: { id: 'report.reasons.dislike', defaultMessage: 'I don\'t like it' },
          dislike_description: { id: 'report.reasons.dislike_description', defaultMessage: 'It is not something you want to see' },
          spam: { id: 'report.reasons.spam', defaultMessage: 'It\'s spam' },
          spam_description: { id: 'report.reasons.spam_description', defaultMessage: 'Malicious links, fake engagement, or repetitive replies' },
        Severity: Major
        Found in app/javascript/mastodon/features/report/category.js and 1 other location - About 6 hrs to fix
        app/javascript/mastodon/features/compose/index.js on lines 21..32

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

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

          render () {
            let media = null;
            let statusAvatar, prepend, rebloggedByText, unlistedQuoteText;
        
            const { intl, hidden, featured, unread, showThread, scrollKey, pictureInPicture, contextType } = this.props;
        Severity: Minor
        Found in app/javascript/mastodon/components/status.js - About 6 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 remotable_attachment has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
        Open

            def remotable_attachment(attachment_name, limit, suppress_errors: true, download_on_assign: true, attribute_name: nil)
              attribute_name ||= "#{attachment_name}_remote_url".to_sym
        
              define_method("download_#{attachment_name}!") do |url = nil|
                url ||= self[attribute_name]
        Severity: Minor
        Found in app/models/concerns/remotable.rb - About 6 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

            if (me !== account.get('id') && account.getIn(['relationship', 'muting'])) {
              info.push(<span key='muted' className='relationship-tag'><FormattedMessage id='account.muted' defaultMessage='Muted' /></span>);
            } else if (me !== account.get('id') && account.getIn(['relationship', 'domain_blocking'])) {
              info.push(<span key='domain_blocked' className='relationship-tag'><FormattedMessage id='account.domain_blocked' defaultMessage='Domain blocked' /></span>);
            }
        app/javascript/mastodon/features/account/components/header.js on lines 146..150

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

        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 (me !== account.get('id') && account.getIn(['relationship', 'followed_by'])) {
              info.push(<span key='followed_by' className='relationship-tag'><FormattedMessage id='account.follows_you' defaultMessage='Follows you' /></span>);
            } else if (me !== account.get('id') && account.getIn(['relationship', 'blocking'])) {
              info.push(<span key='blocked' className='relationship-tag'><FormattedMessage id='account.blocked' defaultMessage='Blocked' /></span>);
            }
        app/javascript/mastodon/features/account/components/header.js on lines 152..156

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

        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 media_gallery.js has 434 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 { is } from 'immutable';
        import IconButton from './icon_button';
        Severity: Minor
        Found in app/javascript/mastodon/components/media_gallery.js - About 6 hrs to fix

          Audio has 46 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export default @injectIntl
          class Audio extends React.PureComponent {
          
            static propTypes = {
              src: PropTypes.string.isRequired,
          Severity: Minor
          Found in app/javascript/mastodon/features/audio/index.js - About 6 hrs to fix

            Function render has a Cognitive Complexity of 41 (exceeds 5 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: Minor
            Found in app/javascript/mastodon/components/status_action_bar.js - About 6 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 3 locations. Consider refactoring.
            Open

              _selectChild (index, align_top) {
                const container = this.node.node;
                const element = container.querySelector(`article:nth-of-type(${index + 1}) .focusable`);
            
                if (element) {
            app/javascript/mastodon/components/status_list.js on lines 62..74
            app/javascript/mastodon/features/notifications/index.js on lines 158..170

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

              _selectChild (index, align_top) {
                const container = this.column.node;
                const element = container.querySelector(`article:nth-of-type(${index + 1}) .focusable`);
            
                if (element) {
            Severity: Major
            Found in app/javascript/mastodon/features/notifications/index.js and 2 other locations - About 6 hrs to fix
            app/javascript/mastodon/components/status_list.js on lines 62..74
            app/javascript/mastodon/features/direct_timeline/components/conversations_list.js on lines 31..43

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

              _selectChild (index, align_top) {
                const container = this.node.node;
                const element = container.querySelector(`article:nth-of-type(${index + 1}) .focusable`);
            
                if (element) {
            Severity: Major
            Found in app/javascript/mastodon/components/status_list.js and 2 other locations - About 6 hrs to fix
            app/javascript/mastodon/features/direct_timeline/components/conversations_list.js on lines 31..43
            app/javascript/mastodon/features/notifications/index.js on lines 158..170

            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 6 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? Favourites and boosts will be lost, and replies to the original post will be orphaned.' },
            Severity: Major
            Found in app/javascript/mastodon/containers/status_container.js and 5 other locations - About 6 hrs to fix
            app/javascript/mastodon/components/account.js on lines 13..23
            app/javascript/mastodon/features/compose/components/poll_form.js on lines 11..21
            app/javascript/mastodon/features/compose/components/privacy_dropdown.js on lines 12..22
            app/javascript/mastodon/features/notifications/components/notification.js on lines 16..26
            app/javascript/mastodon/features/video/index.js on lines 12..22

            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

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

            const messages = defineMessages({
              play: { id: 'video.play', defaultMessage: 'Play' },
              pause: { id: 'video.pause', defaultMessage: 'Pause' },
              mute: { id: 'video.mute', defaultMessage: 'Mute sound' },
              unmute: { id: 'video.unmute', defaultMessage: 'Unmute sound' },
            Severity: Major
            Found in app/javascript/mastodon/features/video/index.js and 5 other locations - About 6 hrs to fix
            app/javascript/mastodon/components/account.js on lines 13..23
            app/javascript/mastodon/containers/status_container.js on lines 54..64
            app/javascript/mastodon/features/compose/components/poll_form.js on lines 11..21
            app/javascript/mastodon/features/compose/components/privacy_dropdown.js on lines 12..22
            app/javascript/mastodon/features/notifications/components/notification.js on lines 16..26

            Duplicated Code

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

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

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

            Tuning

            This issue has a mass of 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

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

            const messages = defineMessages({
              follow: { id: 'account.follow', defaultMessage: 'Follow' },
              unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
              requested: { id: 'account.requested', defaultMessage: 'Awaiting approval' },
              unblock: { id: 'account.unblock', defaultMessage: 'Unblock @{name}' },
            Severity: Major
            Found in app/javascript/mastodon/components/account.js and 5 other locations - About 6 hrs to fix
            app/javascript/mastodon/containers/status_container.js on lines 54..64
            app/javascript/mastodon/features/compose/components/poll_form.js on lines 11..21
            app/javascript/mastodon/features/compose/components/privacy_dropdown.js on lines 12..22
            app/javascript/mastodon/features/notifications/components/notification.js on lines 16..26
            app/javascript/mastodon/features/video/index.js on lines 12..22

            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

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

            const messages = defineMessages({
              favourite: { id: 'notification.favourite', defaultMessage: '{name} favourited your status' },
              follow: { id: 'notification.follow', defaultMessage: '{name} followed you' },
              ownPoll: { id: 'notification.own_poll', defaultMessage: 'Your poll has ended' },
              poll: { id: 'notification.poll', defaultMessage: 'A poll you have voted in has ended' },
            app/javascript/mastodon/components/account.js on lines 13..23
            app/javascript/mastodon/containers/status_container.js on lines 54..64
            app/javascript/mastodon/features/compose/components/poll_form.js on lines 11..21
            app/javascript/mastodon/features/compose/components/privacy_dropdown.js on lines 12..22
            app/javascript/mastodon/features/video/index.js on lines 12..22

            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

            Severity
            Category
            Status
            Source
            Language