glitch-soc/mastodon

View on GitHub

Showing 1,278 of 4,906 total issues

Method imagemagick_version has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def imagemagick_version
    return if Rails.configuration.x.use_vips

    imagemagick_binary = Paperclip.options[:is_windows] ? 'magick convert' : 'convert'

Severity: Minor
Found in app/lib/admin/metrics/dimension/software_versions_dimension.rb - About 55 mins 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 confirmation_instructions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def confirmation_instructions(user, token, *, **)
    @resource = user
    @token    = token

    return unless @resource.active_for_authentication?
Severity: Minor
Found in app/mailers/user_mailer.rb - About 55 mins 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 perform has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def perform
    return if origin_account.uri != object_uri
    return unless mark_as_processing!

    target_account = ActivityPub::FetchRemoteAccountService.new.call(target_uri)
Severity: Minor
Found in app/lib/activitypub/activity/move.rb - About 55 mins 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 perform has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def perform(receiver_account_id, activity_id = nil, activity_class_name = nil, type = nil)
    if activity_id.nil? && activity_class_name.nil?
      activity = Mention.find(receiver_account_id)
      receiver = activity.account
    else
Severity: Minor
Found in app/workers/local_notification_worker.rb - About 55 mins 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 around_create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def self.around_create(record)
      now = Time.now.utc

      if record.created_at.nil? || record.created_at >= now || record.created_at == record.updated_at || record.override_timestamps
        yield
Severity: Minor
Found in lib/mastodon/snowflake.rb - About 55 mins 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 upgrade_storage_s3 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def upgrade_storage_s3(progress, attachment, style)
      previous_storage_schema_version = attachment.storage_schema_version
      object                          = attachment.s3_object(style)
      success                         = true

Severity: Minor
Found in lib/mastodon/cli/upgrade.rb - About 55 mins 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 remove has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def remove
      time_ago = options[:days].days.ago
      link     = options[:link] ? 'link-type ' : ''
      scope    = PreviewCard.cached
      scope    = scope.where(type: :link) if options[:link]
Severity: Minor
Found in lib/mastodon/cli/preview_cards.rb - About 55 mins 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 export has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def export(path)
      exported         = 0
      category         = CustomEmojiCategory.find_by(name: options[:category])
      export_file_name = File.join(path, 'export.tar.gz')

Severity: Minor
Found in lib/mastodon/cli/emoji.rb - About 55 mins 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 expandTimelineSuccess has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

export function expandTimelineSuccess(timeline, statuses, next, partial, isLoadingRecent, isLoadingMore, usePendingItems) {
Severity: Major
Found in app/javascript/flavours/glitch/actions/timelines.js - About 50 mins to fix

    Function expandTimelineSuccess has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    export function expandTimelineSuccess(timeline, statuses, next, partial, isLoadingRecent, isLoadingMore, usePendingItems) {
    Severity: Major
    Found in app/javascript/mastodon/actions/timelines.js - About 50 mins to fix

      Function renderOption has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        renderOption (option, optionIndex, showResults) {
          const { poll, lang, disabled, intl } = this.props;
          const pollVotesCount  = poll.get('voters_count') || poll.get('votes_count');
          const percent         = pollVotesCount === 0 ? 0 : (option.get('votes_count') / pollVotesCount) * 100;
          const leading         = poll.get('options').filterNot(other => other.get('title') === option.get('title')).every(other => option.get('votes_count') >= other.get('votes_count'));
      Severity: Minor
      Found in app/javascript/flavours/glitch/components/poll.jsx - About 45 mins 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 getDerivedStateFromProps has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        static getDerivedStateFromProps(nextProps, prevState) {
          let update = {};
          let updated = false;
      
          // Make sure the state mirrors props we track…
      Severity: Minor
      Found in app/javascript/flavours/glitch/components/status.jsx - About 45 mins 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

      Avoid deeply nested control flow statements.
      Open

                  if (statusAdminLink !== undefined) {
                    menu.push({ text: intl.formatMessage(messages.admin_status), href: statusAdminLink(status.getIn(['account', 'id']), status.get('id')) });
                  }
      Severity: Major
      Found in app/javascript/flavours/glitch/components/status_action_bar.jsx - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    if (subIndex !== -1) {
                      let score = subIndex + 1;
                      if (sub === id) score = 0;
        
                      aIndex.results.push(emojisList[id]);
        Severity: Major
        Found in app/javascript/flavours/glitch/features/emoji/emoji_mart_search_light.js - About 45 mins to fix

          Function Story has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          export const Story = ({
            url,
            title,
            lang,
            publisher,
          Severity: Minor
          Found in app/javascript/flavours/glitch/features/explore/components/story.jsx - About 45 mins 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

          Avoid deeply nested control flow statements.
          Open

                      switch (url.protocol) {
                      case 'xmpp:':
                        tag.textContent = `[${url.href}]`;
                        break;
                      case 'magnet:':
          Severity: Major
          Found in app/javascript/flavours/glitch/components/status_content.jsx - About 45 mins to fix

            Function connectPublicStream has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export const connectPublicStream = ({ onlyMedia, onlyRemote, allowLocalOnly } = {}) =>
              connectTimelineStream(`public${onlyRemote ? ':remote' : (allowLocalOnly ? ':allow_local_only' : '')}${onlyMedia ? ':media' : ''}`, `public${onlyRemote ? ':remote' : (allowLocalOnly ? ':allow_local_only' : '')}${onlyMedia ? ':media' : ''}`, {}, { fillGaps: () => fillPublicTimelineGaps({ onlyMedia, onlyRemote, allowLocalOnly }) });
            Severity: Minor
            Found in app/javascript/flavours/glitch/actions/streaming.js - About 45 mins 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

            Avoid deeply nested control flow statements.
            Open

                        if (accountAdminLink !== undefined) {
                          menu.push({ text: intl.formatMessage(messages.admin_account, { name: status.getIn(['account', 'username']) }), href: accountAdminLink(status.getIn(['account', 'id'])) });
                        }
            Severity: Major
            Found in app/javascript/flavours/glitch/components/status_action_bar.jsx - About 45 mins to fix

              Function addReaction has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              export const addReaction = (announcementId, name) => (dispatch, getState) => {
                const announcement = getState().getIn(['announcements', 'items']).find(x => x.get('id') === announcementId);
              
                let alreadyAdded = false;
              
              
              Severity: Minor
              Found in app/javascript/flavours/glitch/actions/announcements.js - About 45 mins 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

              Avoid deeply nested control flow statements.
              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 });
                        }
              Severity: Major
              Found in app/javascript/flavours/glitch/features/account/components/header.jsx - About 45 mins to fix
                Severity
                Category
                Status
                Source
                Language