maa123/mastodon

View on GitHub

Showing 1,813 of 1,813 total issues

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

        if (relationship && relationship.get('muting')) {
          menu.push({ text: intl.formatMessage(messages.unmute, { name: account.get('username') }), action: this.handleMuteClick });
        } else {
          menu.push({ text: intl.formatMessage(messages.mute, { name: account.get('username') }), action: this.handleMuteClick, dangerous: true });
        }
app/javascript/mastodon/components/status_action_bar.jsx on lines 290..294
app/javascript/mastodon/components/status_action_bar.jsx on lines 296..300
app/javascript/mastodon/features/status/components/action_bar.jsx on lines 236..240

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

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 account.rb has 372 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 4 hrs to fix

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

      def call(uri, id: true, prefetched_body: nil, break_on_redirect: false, only_key: false, suppress_errors: true, request_id: nil)
        return if domain_not_allowed?(uri)
        return ActivityPub::TagManager.instance.uri_to_actor(uri) if ActivityPub::TagManager.instance.local_uri?(uri)
    
        @json = begin
    Severity: Minor
    Found in app/services/activitypub/fetch_remote_actor_service.rb - About 4 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

    export const fetchFollowedHashtags = () => (dispatch, getState) => {
      dispatch(fetchFollowedHashtagsRequest());
    
      api(getState).get('/api/v1/followed_tags').then(response => {
        const next = getLinks(response).refs.find(link => link.rel === 'next');
    Severity: Major
    Found in app/javascript/mastodon/actions/tags.js and 1 other location - About 4 hrs to fix
    app/javascript/mastodon/actions/domain_blocks.js on lines 95..104

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

    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

      return (dispatch, getState) => {
        dispatch(fetchDomainBlocksRequest());
    
        api(getState).get('/api/v1/domain_blocks').then(response => {
          const next = getLinks(response).refs.find(link => link.rel === 'next');
    Severity: Major
    Found in app/javascript/mastodon/actions/domain_blocks.js and 1 other location - About 4 hrs to fix
    app/javascript/mastodon/actions/tags.js on lines 48..57

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

    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

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

    class Video extends PureComponent {
    
      static propTypes = {
        preview: PropTypes.string,
        frameRate: PropTypes.string,
    Severity: Minor
    Found in app/javascript/mastodon/features/video/index.jsx - About 4 hrs to fix

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

      class ActivityPub::Activity::Create < ActivityPub::Activity
        include FormattingHelper
      
        def perform
          @account.schedule_refresh_if_stale!
      Severity: Minor
      Found in app/lib/activitypub/activity/create.rb - About 4 hrs to fix

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

          render () {
            const { status, relationship, intl, withDismiss, withCounters, scrollKey } = this.props;
            const { signedIn, permissions } = this.context.identity;
        
            const publicStatus       = ['public', 'unlisted'].includes(status.get('visibility'));
        Severity: Major
        Found in app/javascript/mastodon/components/status_action_bar.jsx - About 4 hrs to fix

          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 69..80
          app/javascript/mastodon/actions/interactions.js on lines 145..156
          app/javascript/mastodon/actions/interactions.js on lines 444..455

          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 69..80
          app/javascript/mastodon/actions/interactions.js on lines 145..156
          app/javascript/mastodon/actions/interactions.js on lines 482..493

          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 69..80
          app/javascript/mastodon/actions/interactions.js on lines 444..455
          app/javascript/mastodon/actions/interactions.js on lines 482..493

          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 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 145..156
          app/javascript/mastodon/actions/interactions.js on lines 444..455
          app/javascript/mastodon/actions/interactions.js on lines 482..493

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

          import PropTypes from 'prop-types';
          import { PureComponent } from 'react';
          
          import { defineMessages, injectIntl, FormattedMessage, FormattedDate } from 'react-intl';
          
          

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

                      {statuses.size > 0 && (
                        <SearchSection key='statuses' title={<><Icon id='quote-right' fixedWidth /><FormattedMessage id='search_results.statuses' defaultMessage='Posts' /></>} onClickMore={this.handleLoadMoreStatuses}>
                          {statuses.take(INITIAL_DISPLAY).map(id => <Status key={id} id={id} />)}
                        </SearchSection>
                      )}
            Severity: Major
            Found in app/javascript/mastodon/features/explore/results.jsx and 1 other location - About 4 hrs to fix
            app/javascript/mastodon/features/explore/results.jsx on lines 167..171

            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

                      {accounts.size > 0 && (
                        <SearchSection key='accounts' title={<><Icon id='users' fixedWidth /><FormattedMessage id='search_results.accounts' defaultMessage='Profiles' /></>} onClickMore={this.handleLoadMoreAccounts}>
                          {accounts.take(INITIAL_DISPLAY).map(id => <Account key={id} id={id} />)}
                        </SearchSection>
                      )}
            Severity: Major
            Found in app/javascript/mastodon/features/explore/results.jsx and 1 other location - About 4 hrs to fix
            app/javascript/mastodon/features/explore/results.jsx on lines 179..183

            Duplicated Code

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

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

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

            Tuning

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

            File zoomable_image.jsx has 364 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import PropTypes from 'prop-types';
            import { PureComponent } from 'react';
            
            import { defineMessages, injectIntl } from 'react-intl';
            
            
            Severity: Minor
            Found in app/javascript/mastodon/features/ui/components/zoomable_image.jsx - About 4 hrs to fix

              UI has 36 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class UI extends PureComponent {
              
                static contextTypes = {
                  router: PropTypes.object.isRequired,
                  identity: PropTypes.object.isRequired,
              Severity: Minor
              Found in app/javascript/mastodon/features/ui/index.jsx - About 4 hrs to fix

                Function listener has 116 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    const listener = message => {
                      const { event, payload } = message;
                
                      // Streaming only needs to apply filtering to some channels and only to
                      // some events. This is because majority of the filtering happens on the
                Severity: Major
                Found in streaming/index.js - About 4 hrs to fix

                  Method crawl has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def crawl(start = nil)
                        stats           = Concurrent::Hash.new
                        processed       = Concurrent::AtomicFixnum.new(0)
                        failed          = Concurrent::AtomicFixnum.new(0)
                        start_at        = Time.now.to_f
                  Severity: Minor
                  Found in lib/mastodon/cli/domains.rb - About 4 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

                  const mapStateToProps = (state, { columnId }) => {
                    const uuid = columnId;
                    const columns = state.getIn(['settings', 'columns']);
                    const index = columns.findIndex(c => c.get('uuid') === uuid);
                  
                  
                  app/javascript/mastodon/features/public_timeline/containers/column_settings_container.js on lines 7..15

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

                  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