glitch-soc/mastodon

View on GitHub

Showing 4,906 of 4,906 total issues

Method link_to_mention has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  def link_to_mention(entity)
    MastodonOTELTracer.in_span('TextFormatter#link_to_mention') do
      username, domain = entity[:screen_name].split('@')
      domain           = nil if local_domain?(domain)
      account          = nil
Severity: Minor
Found in app/lib/text_formatter.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

Method process_note_items has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  def process_note_items(items)
    status_ids = items.filter_map do |item|
      next unless item.is_a?(String) || item['type'] == 'Note'

      uri = value_or_id(item)
Severity: Minor
Found in app/services/activitypub/fetch_featured_collection_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

Method import has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def import(path)
      imported = 0
      skipped  = 0
      failed   = 0
      category = options[:category] ? CustomEmojiCategory.find_or_create_by(name: options[:category]) : nil
Severity: Minor
Found in lib/mastodon/cli/emoji.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 ColumnHeader has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

export const ColumnHeader: React.FC<Props> = ({
  title,
  icon,
  iconComponent,
  active,
Severity: Minor
Found in app/javascript/flavours/glitch/components/column_header.tsx - 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 ColumnHeader has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

export const ColumnHeader: React.FC<Props> = ({
  title,
  icon,
  iconComponent,
  active,
Severity: Minor
Found in app/javascript/mastodon/components/column_header.tsx - 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 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render () {
    const { handleChange } = this;
    const { settings, item, id, inputProps, options, children, dependsOn, dependsOnNot, placeholder, disabled } = this.props;
    let enabled = !disabled;

    File notifications.js has 294 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { fromJS, Map as ImmutableMap, List as ImmutableList } from 'immutable';
    
    import { blockDomainSuccess } from 'flavours/glitch/actions/domain_blocks';
    import { timelineDelete } from 'flavours/glitch/actions/timelines_typed';
    
    
    Severity: Minor
    Found in app/javascript/flavours/glitch/reducers/notifications.js - About 3 hrs to fix

      File index.tsx has 294 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { useCallback, useEffect, useMemo, useRef } from 'react';
      
      import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
      
      import { Helmet } from 'react-helmet';
      Severity: Minor
      Found in app/javascript/flavours/glitch/features/notifications_v2/index.tsx - About 3 hrs to fix

        File index.tsx has 294 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { useCallback, useEffect, useMemo, useRef } from 'react';
        
        import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
        
        import { Helmet } from 'react-helmet';
        Severity: Minor
        Found in app/javascript/mastodon/features/notifications_v2/index.tsx - About 3 hrs to fix

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

          const mapStateToProps = (state, props) => ({
            accountIds: state.getIn(['user_lists', 'reblogged_by', props.params.statusId, 'items']),
            hasMore: !!state.getIn(['user_lists', 'reblogged_by', props.params.statusId, 'next']),
            isLoading: state.getIn(['user_lists', 'reblogged_by', props.params.statusId, 'isLoading'], true),
          });
          Severity: Major
          Found in app/javascript/flavours/glitch/features/reblogs/index.jsx and 3 other locations - About 3 hrs to fix
          app/javascript/flavours/glitch/features/favourites/index.jsx on lines 28..32
          app/javascript/mastodon/features/favourites/index.jsx on lines 26..30
          app/javascript/mastodon/features/reblogs/index.jsx on lines 27..31

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

          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

          const mapStateToProps = (state, props) => ({
            accountIds: state.getIn(['user_lists', 'reblogged_by', props.params.statusId, 'items']),
            hasMore: !!state.getIn(['user_lists', 'reblogged_by', props.params.statusId, 'next']),
            isLoading: state.getIn(['user_lists', 'reblogged_by', props.params.statusId, 'isLoading'], true),
          });
          Severity: Major
          Found in app/javascript/mastodon/features/reblogs/index.jsx and 3 other locations - About 3 hrs to fix
          app/javascript/flavours/glitch/features/favourites/index.jsx on lines 28..32
          app/javascript/flavours/glitch/features/reblogs/index.jsx on lines 29..33
          app/javascript/mastodon/features/favourites/index.jsx on lines 26..30

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

          export default class GrantPermissionButton extends PureComponent {
          
            static propTypes = {
              onClick: PropTypes.func.isRequired,
            };
          app/javascript/flavours/glitch/features/notifications/components/grant_permission_button.jsx on lines 6..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 96.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

              if (status.get('collapsed', null) === null && onCollapsedToggle) {
                const { collapsible, onClick } = this.props;
          
                const collapsed =
                    collapsible
          Severity: Major
          Found in app/javascript/flavours/glitch/components/status_content.jsx and 1 other location - About 3 hrs to fix
          app/javascript/mastodon/components/status_content.jsx on lines 124..134

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

              if (status.get('collapsed', null) === null && onCollapsedToggle) {
                const { collapsible, onClick } = this.props;
          
                const collapsed =
                    collapsible
          Severity: Major
          Found in app/javascript/mastodon/components/status_content.jsx and 1 other location - About 3 hrs to fix
          app/javascript/flavours/glitch/components/status_content.jsx on lines 221..231

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

          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

            it('can search for woman-facepalming', () => {
              const expected = [
                {
                  id: 'woman-facepalming',
                  unified: '1f926-200d-2640-fe0f',
          app/javascript/mastodon/features/emoji/__tests__/emoji_index-test.js on lines 9..19
          app/javascript/mastodon/features/emoji/__tests__/emoji_index-test.js on lines 154..164

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

          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

          const mapStateToProps = (state, props) => ({
            accountIds: state.getIn(['user_lists', 'favourited_by', props.params.statusId, 'items']),
            hasMore: !!state.getIn(['user_lists', 'favourited_by', props.params.statusId, 'next']),
            isLoading: state.getIn(['user_lists', 'favourited_by', props.params.statusId, 'isLoading'], true),
          });
          Severity: Major
          Found in app/javascript/mastodon/features/favourites/index.jsx and 3 other locations - About 3 hrs to fix
          app/javascript/flavours/glitch/features/favourites/index.jsx on lines 28..32
          app/javascript/flavours/glitch/features/reblogs/index.jsx on lines 29..33
          app/javascript/mastodon/features/reblogs/index.jsx on lines 27..31

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

          export default class GrantPermissionButton extends PureComponent {
          
            static propTypes = {
              onClick: PropTypes.func.isRequired,
            };
          app/javascript/mastodon/features/notifications/components/grant_permission_button.jsx on lines 6..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 96.

          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

          const mapStateToProps = (state, props) => ({
            accountIds: state.getIn(['user_lists', 'favourited_by', props.params.statusId, 'items']),
            hasMore: !!state.getIn(['user_lists', 'favourited_by', props.params.statusId, 'next']),
            isLoading: state.getIn(['user_lists', 'favourited_by', props.params.statusId, 'isLoading'], true),
          });
          app/javascript/flavours/glitch/features/reblogs/index.jsx on lines 29..33
          app/javascript/mastodon/features/favourites/index.jsx on lines 26..30
          app/javascript/mastodon/features/reblogs/index.jsx on lines 27..31

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

          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 (isRemote && (permissions & PERMISSION_MANAGE_FEDERATION) === PERMISSION_MANAGE_FEDERATION) {
                      const domain = account.get('acct').split('@')[1];
                      menu.push({ text: intl.formatMessage(messages.admin_domain, { domain: domain }), href: `/admin/instances/${domain}` });
                    }
          Severity: Major
          Found in app/javascript/mastodon/components/status_action_bar.jsx and 1 other location - About 3 hrs to fix
          app/javascript/mastodon/features/status/components/action_bar.jsx on lines 270..273

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

          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

            it('should give same result for emoji_index_light and emoji-mart', () => {
              const expected = [
                {
                  id: 'pineapple',
                  unified: '1f34d',
          app/javascript/mastodon/features/emoji/__tests__/emoji_index-test.js on lines 154..164
          app/javascript/mastodon/features/emoji/__tests__/emoji_index-test.js on lines 166..176

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

          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