mashirozx/mastodon

View on GitHub

Showing 1,785 of 1,785 total issues

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.js and 1 other location - About 5 hrs to fix
app/javascript/mastodon/features/video/index.js on lines 241..253

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

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

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

    const publicStatus       = ['public', 'unlisted'].includes(status.get('visibility'));
    const pinnableStatus     = ['public', 'unlisted', 'private'].includes(status.get('visibility'));
Severity: Minor
Found in app/javascript/mastodon/features/status/components/action_bar.js - 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

Video has 39 functions (exceeds 20 allowed). Consider refactoring.
Open

export default @injectIntl
class Video extends React.PureComponent {

  static propTypes = {
    preview: PropTypes.string,
Severity: Minor
Found in app/javascript/mastodon/features/video/index.js - About 5 hrs to fix

    Similar blocks of code found in 3 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 });
          }
    app/javascript/mastodon/features/account/components/header.js on lines 210..214
    app/javascript/mastodon/features/account/components/header.js on lines 222..226

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

    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

              if (account.getIn(['relationship', 'showing_reblogs'])) {
                menu.push({ text: intl.formatMessage(messages.hideReblogs, { name: account.get('username') }), action: this.props.onReblogToggle });
              } else {
                menu.push({ text: intl.formatMessage(messages.showReblogs, { name: account.get('username') }), action: this.props.onReblogToggle });
              }
    app/javascript/mastodon/features/account/components/header.js on lines 222..226
    app/javascript/mastodon/features/account/components/header.js on lines 228..232

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

    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

          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 });
          }
    app/javascript/mastodon/features/account/components/header.js on lines 210..214
    app/javascript/mastodon/features/account/components/header.js on lines 228..232

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

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

      const streamFrom = (ids, req, output, attachCloseHandler, 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

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

      export default @injectIntl
      class Status extends ImmutablePureComponent {
      
        static contextTypes = {
          router: PropTypes.object,
      Severity: Minor
      Found in app/javascript/mastodon/components/status.js - About 5 hrs to fix

        File notification.js has 370 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import React from 'react';
        import ImmutablePropTypes from 'react-immutable-proptypes';
        import { injectIntl, FormattedMessage, defineMessages } from 'react-intl';
        import { HotKeys } from 'react-hotkeys';
        import PropTypes from 'prop-types';

          Class ProcessAccountService has 37 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 4 hrs to fix

            Class UserSettingsDecorator has 37 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class UserSettingsDecorator
              attr_reader :user, :settings
            
              def initialize(user)
                @user = user
            Severity: Minor
            Found in app/lib/user_settings_decorator.rb - About 4 hrs to fix

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

              export function unreblog(status) {
                return (dispatch, getState) => {
                  dispatch(unreblogRequest(status));
              
                  api(getState).post(`/api/v1/statuses/${status.get('id')}/unreblog`).then(response => {
              Severity: Major
              Found in app/javascript/mastodon/actions/interactions.js and 3 other locations - About 4 hrs to fix
              app/javascript/mastodon/actions/interactions.js on lines 135..146
              app/javascript/mastodon/actions/interactions.js on lines 340..351
              app/javascript/mastodon/actions/interactions.js on lines 378..389

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

              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

              export function unpin (status) {
                return (dispatch, getState) => {
                  dispatch(unpinRequest(status));
              
                  api(getState).post(`/api/v1/statuses/${status.get('id')}/unpin`).then(response => {
              Severity: Major
              Found in app/javascript/mastodon/actions/interactions.js and 3 other locations - About 4 hrs to fix
              app/javascript/mastodon/actions/interactions.js on lines 59..70
              app/javascript/mastodon/actions/interactions.js on lines 135..146
              app/javascript/mastodon/actions/interactions.js on lines 340..351

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

              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

              export function unfavourite(status) {
                return (dispatch, getState) => {
                  dispatch(unfavouriteRequest(status));
              
                  api(getState).post(`/api/v1/statuses/${status.get('id')}/unfavourite`).then(response => {
              Severity: Major
              Found in app/javascript/mastodon/actions/interactions.js and 3 other locations - About 4 hrs to fix
              app/javascript/mastodon/actions/interactions.js on lines 59..70
              app/javascript/mastodon/actions/interactions.js on lines 340..351
              app/javascript/mastodon/actions/interactions.js on lines 378..389

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

              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

              export function pin(status) {
                return (dispatch, getState) => {
                  dispatch(pinRequest(status));
              
                  api(getState).post(`/api/v1/statuses/${status.get('id')}/pin`).then(response => {
              Severity: Major
              Found in app/javascript/mastodon/actions/interactions.js and 3 other locations - About 4 hrs to fix
              app/javascript/mastodon/actions/interactions.js on lines 59..70
              app/javascript/mastodon/actions/interactions.js on lines 135..146
              app/javascript/mastodon/actions/interactions.js on lines 378..389

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

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

              import React from 'react';
              import ImmutablePureComponent from 'react-immutable-pure-component';
              import ReactSwipeableViews from 'react-swipeable-views';
              import ImmutablePropTypes from 'react-immutable-proptypes';
              import PropTypes from 'prop-types';

                Function mapDispatchToProps has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
                Open

                const mapDispatchToProps = (dispatch, { intl }) => ({
                
                  onReply (status, router) {
                    dispatch((_, getState) => {
                      let state = getState();

                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

                          <a href={quote_status.getIn(['account', 'url'])} onClick={this.handleQuoteAccountClick} className='detailed-status__display-name'>
                            <div className='detailed-status__display-avatar'><Avatar account={quote_status.get('account')} size={18} /></div>
                            <DisplayName account={quote_status.get('account')} localDomain={this.props.domain} />
                          </a>
                app/javascript/mastodon/features/status/components/detailed_status.js on lines 370..373

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

                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

                          <a href={status.getIn(['account', 'url'])} onClick={this.handleAccountClick} className='detailed-status__display-name'>
                            <div className='detailed-status__display-avatar'><Avatar account={status.get('account')} size={48} /></div>
                            <DisplayName account={status.get('account')} localDomain={this.props.domain} />
                          </a>
                app/javascript/mastodon/features/status/components/detailed_status.js on lines 221..224

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

                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