mashirozx/mastodon

View on GitHub

Showing 1,785 of 1,785 total issues

Method call has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  def call(query, account, limit, options = {})
    @query   = query&.strip
    @account = account
    @options = options
    @limit   = limit.to_i
Severity: Minor
Found in app/services/search_service.rb - About 3 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 85 lines of code (exceeds 25 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: Major
Found in app/javascript/mastodon/features/status/components/action_bar.js - About 3 hrs to fix

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

        api(getState).post('/api/v1/domain_blocks', { domain }).then(() => {
          const at_domain = '@' + domain;
          const accounts = getState().get('accounts').filter(item => item.get('acct').endsWith(at_domain)).valueSeq().map(item => item.get('id'));
    
          dispatch(blockDomainSuccess(domain, accounts));
    Severity: Major
    Found in app/javascript/mastodon/actions/domain_blocks.js and 1 other location - About 3 hrs to fix
    app/javascript/mastodon/actions/domain_blocks.js on lines 61..65

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

    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

      handleProgress = () => {
        const lastTimeRange = this.audio.buffered.length - 1;
    
        if (lastTimeRange > -1) {
          this.setState({ buffer: Math.ceil(this.audio.buffered.end(lastTimeRange) / this.audio.duration * 100) });
    Severity: Major
    Found in app/javascript/mastodon/features/audio/index.js and 1 other location - About 3 hrs to fix
    app/javascript/mastodon/features/video/index.js on lines 488..494

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

    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 (this.searchForm && !this.props.singleColumn) {
          const { left, right } = this.searchForm.getBoundingClientRect();
          if (left < 0 || right > (window.innerWidth || document.documentElement.clientWidth)) {
            this.searchForm.scrollIntoView();
          }
    app/javascript/mastodon/features/compose/components/compose_form.js on lines 139..144

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

    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

      handleProgress = () => {
        const lastTimeRange = this.video.buffered.length - 1;
    
        if (lastTimeRange > -1) {
          this.setState({ buffer: Math.ceil(this.video.buffered.end(lastTimeRange) / this.video.duration * 100) });
    Severity: Major
    Found in app/javascript/mastodon/features/video/index.js and 1 other location - About 3 hrs to fix
    app/javascript/mastodon/features/audio/index.js on lines 193..199

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

    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 (this.composeForm && !this.props.singleColumn) {
          const { left, right } = this.composeForm.getBoundingClientRect();
          if (left < 0 || right > (window.innerWidth || document.documentElement.clientWidth)) {
            this.composeForm.scrollIntoView();
          }
    app/javascript/mastodon/features/compose/components/search.js on lines 104..109

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

    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

      onSuggestionClick = (e) => {
        const suggestion = this.props.suggestions.get(e.currentTarget.getAttribute('data-index'));
        e.preventDefault();
        this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestion);
        this.input.focus();
    Severity: Major
    Found in app/javascript/mastodon/components/autosuggest_input.js and 1 other location - About 3 hrs to fix
    app/javascript/mastodon/components/autosuggest_textarea.js on lines 148..153

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

    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

      onSuggestionClick = (e) => {
        const suggestion = this.props.suggestions.get(e.currentTarget.getAttribute('data-index'));
        e.preventDefault();
        this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestion);
        this.textarea.focus();
    Severity: Major
    Found in app/javascript/mastodon/components/autosuggest_textarea.js and 1 other location - About 3 hrs to fix
    app/javascript/mastodon/components/autosuggest_input.js on lines 148..153

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

    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

        api(getState).delete('/api/v1/domain_blocks', { params: { domain } }).then(() => {
          const at_domain = '@' + domain;
          const accounts = getState().get('accounts').filter(item => item.get('acct').endsWith(at_domain)).valueSeq().map(item => item.get('id'));
          dispatch(unblockDomainSuccess(domain, accounts));
        }).catch(err => {
    Severity: Major
    Found in app/javascript/mastodon/actions/domain_blocks.js and 1 other location - About 3 hrs to fix
    app/javascript/mastodon/actions/domain_blocks.js on lines 23..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 103.

    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 header.js has 307 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 { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
    import Button from 'mastodon/components/button';
    Severity: Minor
    Found in app/javascript/mastodon/features/account/components/header.js - About 3 hrs to fix

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

        onBlockDomain (domain) {
          dispatch(openModal('CONFIRM', {
            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> }} />,
            confirm: intl.formatMessage(messages.blockDomainConfirm),
            onConfirm: () => dispatch(blockDomain(domain)),
      Severity: Major
      Found in app/javascript/mastodon/containers/status_container.js and 2 other locations - About 3 hrs to fix
      app/javascript/mastodon/containers/domain_container.js on lines 19..25
      app/javascript/mastodon/features/account_timeline/containers/header_container.js on lines 112..118

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

      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

        onBlockDomain (domain) {
          dispatch(openModal('CONFIRM', {
            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> }} />,
            confirm: intl.formatMessage(messages.blockDomainConfirm),
            onConfirm: () => dispatch(blockDomain(domain)),
      app/javascript/mastodon/containers/domain_container.js on lines 19..25
      app/javascript/mastodon/containers/status_container.js on lines 236..242

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

      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

        onBlockDomain (domain) {
          dispatch(openModal('CONFIRM', {
            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.' values={{ domain: <strong>{domain}</strong> }} />,
            confirm: intl.formatMessage(messages.blockDomainConfirm),
            onConfirm: () => dispatch(blockDomain(domain)),
      Severity: Major
      Found in app/javascript/mastodon/containers/domain_container.js and 2 other locations - About 3 hrs to fix
      app/javascript/mastodon/containers/status_container.js on lines 236..242
      app/javascript/mastodon/features/account_timeline/containers/header_container.js on lines 112..118

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

      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

      Class DeleteAccountService has 28 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class DeleteAccountService < BaseService
        include Payloadable
      
        ASSOCIATIONS_ON_SUSPEND = %w(
          account_notes
      Severity: Minor
      Found in app/services/delete_account_service.rb - About 3 hrs to fix

        Class MaintenanceCLI has 28 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class MaintenanceCLI < Thor
            include CLIHelper
        
            def self.exit_on_failure?
              true
        Severity: Minor
        Found in lib/mastodon/maintenance_cli.rb - About 3 hrs to fix

          Class ActorSerializer has 28 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class ActivityPub::ActorSerializer < ActivityPub::Serializer
            include RoutingHelper
            include FormattingHelper
          
            context :security
          Severity: Minor
          Found in app/serializers/activitypub/actor_serializer.rb - About 3 hrs to fix

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

              render () {
                const { intl, results, suggestions, dismissSuggestion, searchTerm } = this.props;
            
                if (searchTerm === '' && !suggestions.isEmpty()) {
                  return (
            Severity: Major
            Found in app/javascript/mastodon/features/compose/components/search_results.js - About 3 hrs to fix

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

                render () {
                  const { intl, notifications, isLoading, isUnread, columnId, multiColumn, hasMore, numPending, showFilterBar, lastReadId, canMarkAsRead, needsNotificationPermission } = this.props;
                  const pinned = !!columnId;
                  const emptyMessage = <FormattedMessage id='empty_column.notifications' defaultMessage="You don't have any notifications yet. When other people interact with you, you will see it here." />;
              
              
              Severity: Major
              Found in app/javascript/mastodon/features/notifications/index.js - About 3 hrs to fix

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

                                <NavLink exact activeClassName='active' to={`/@${account.get('acct')}/followers`} title={intl.formatNumber(account.get('followers_count'))}>
                                  <ShortNumber
                                    value={account.get('followers_count')}
                                    renderer={counterRenderer('followers')}
                                  />
                app/javascript/mastodon/features/account/components/header.js on lines 340..345

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

                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