mashirozx/mastodon

View on GitHub

Showing 1,785 of 1,785 total issues

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

  def call(account, params, raise_error: false)
    was_locked    = account.locked
    update_method = raise_error ? :update! : :update

    account.send(update_method, params).tap do |ret|
Severity: Minor
Found in app/services/update_account_service.rb - About 1 hr 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 update_poll! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def update_poll!(allow_significant_changes: true)
    previous_poll        = @status.preloadable_poll
    @previous_expires_at = previous_poll&.expires_at
    poll_parser          = ActivityPub::Parser::PollParser.new(@json)

Severity: Minor
Found in app/services/activitypub/process_status_update_service.rb - About 1 hr 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 update_emojis! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def update_emojis!
    return if skip_download?

    @raw_emojis.each do |raw_emoji|
      custom_emoji_parser = ActivityPub::Parser::CustomEmojiParser.new(raw_emoji)
Severity: Minor
Found in app/services/activitypub/process_status_update_service.rb - About 1 hr 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 blocked? has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def blocked?
    blocked   = @recipient.suspended?
    blocked ||= from_self? && @notification.type != :poll

    return blocked if message? && from_staff?
Severity: Minor
Found in app/services/notify_service.rb - About 1 hr 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 call has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def call(status, **options)
    @payload  = Oj.dump(event: :delete, payload: status.id.to_s)
    @status   = status
    @account  = status.account
    @options  = options
Severity: Minor
Found in app/services/remove_status_service.rb - About 1 hr 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 add_to_feed has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def add_to_feed(timeline_type, account_id, status, aggregate_reblogs: true)
    timeline_key = key(timeline_type, account_id)
    reblog_key   = key(timeline_type, account_id, 'reblogs')

    if status.reblog? && (aggregate_reblogs.nil? || aggregate_reblogs)
Severity: Minor
Found in app/lib/feed_manager.rb - About 1 hr 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 13 (exceeds 5 allowed). Consider refactoring.
Open

  def import!
    # The idea is that instead of iterating over all statuses in the database
    # and calculating the searchable_by for each of them (majority of which
    # would be empty), we approach the index from the other end

Severity: Minor
Found in app/lib/importer/statuses_index_importer.rb - About 1 hr 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 filter_from_home? has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def filter_from_home?(status, receiver_id, crutches)
    return false if receiver_id == status.account_id
    return true  if status.reply? && (status.in_reply_to_id.nil? || status.in_reply_to_account_id.nil?)

    check_for_blocks = crutches[:active_mentions][status.id] || []
Severity: Minor
Found in app/lib/feed_manager.rb - About 1 hr 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 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render () {
    const { isLoading, results } = this.props;
    const { type } = this.state;

    let filteredResults = ImmutableList();
Severity: Minor
Found in app/javascript/mastodon/features/explore/results.js - About 1 hr to fix

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

      render () {
        const { type, src, currentTime, accountId, statusId } = this.props;
    
        if (!currentTime) {
          return null;
    Severity: Minor
    Found in app/javascript/mastodon/features/picture_in_picture/index.js - About 1 hr to fix

      Method advanced_search_for_sql_template has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def advanced_search_for_sql_template(following)
            if following
              <<-SQL.squish
                WITH first_degree AS (
                  SELECT target_account_id
      Severity: Minor
      Found in app/models/account.rb - About 1 hr to fix

        Method meta has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def meta
            store = {
              streaming_api_base_url: Rails.configuration.x.streaming_api_base_url,
              access_token: object.token,
              locale: I18n.locale,
        Severity: Minor
        Found in app/serializers/initial_state_serializer.rb - About 1 hr to fix

          Method create has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def create(username)
                role_id  = nil
          
                if options[:role]
                  role = UserRole.find_by(name: options[:role])
          Severity: Minor
          Found in lib/mastodon/accounts_cli.rb - About 1 hr to fix

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

              onQuoteToggleHidden (status) {
                if (status.get('quote_hidden')) {
                  dispatch(revealQuote(status.get('id')));
                } else {
                  dispatch(hideQuote(status.get('id')));
            Severity: Major
            Found in app/javascript/mastodon/containers/status_container.js and 8 other locations - About 1 hr to fix
            app/javascript/mastodon/containers/status_container.js on lines 216..222
            app/javascript/mastodon/containers/status_container.js on lines 224..230
            app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js on lines 56..62
            app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js on lines 64..70
            app/javascript/mastodon/features/notifications/containers/notification_container.js on lines 64..70
            app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 152..158
            app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 160..166
            app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 168..174

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

            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 9 locations. Consider refactoring.
            Open

              onToggleHidden (status) {
                if (status.get('hidden')) {
                  dispatch(revealStatus(status.get('id')));
                } else {
                  dispatch(hideStatus(status.get('id')));
            Severity: Major
            Found in app/javascript/mastodon/containers/status_container.js and 8 other locations - About 1 hr to fix
            app/javascript/mastodon/containers/status_container.js on lines 216..222
            app/javascript/mastodon/containers/status_container.js on lines 258..264
            app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js on lines 56..62
            app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js on lines 64..70
            app/javascript/mastodon/features/notifications/containers/notification_container.js on lines 64..70
            app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 152..158
            app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 160..166
            app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 168..174

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

            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 9 locations. Consider refactoring.
            Open

              onMute (status) {
                if (status.get('muted')) {
                  dispatch(unmuteStatus(status.get('id')));
                } else {
                  dispatch(muteStatus(status.get('id')));
            app/javascript/mastodon/containers/status_container.js on lines 216..222
            app/javascript/mastodon/containers/status_container.js on lines 224..230
            app/javascript/mastodon/containers/status_container.js on lines 258..264
            app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js on lines 64..70
            app/javascript/mastodon/features/notifications/containers/notification_container.js on lines 64..70
            app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 152..158
            app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 160..166
            app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 168..174

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

            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 9 locations. Consider refactoring.
            Open

              onQuoteToggleHidden (status) {
                if (status.get('quote_hidden')) {
                  dispatch(revealQuote(status.get('id')));
                } else {
                  dispatch(hideQuote(status.get('id')));
            app/javascript/mastodon/containers/status_container.js on lines 216..222
            app/javascript/mastodon/containers/status_container.js on lines 224..230
            app/javascript/mastodon/containers/status_container.js on lines 258..264
            app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js on lines 56..62
            app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js on lines 64..70
            app/javascript/mastodon/features/notifications/containers/notification_container.js on lines 64..70
            app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 152..158
            app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 160..166

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

            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 9 locations. Consider refactoring.
            Open

              onToggleHidden (status) {
                if (status.get('hidden')) {
                  dispatch(revealStatus(status.get('id')));
                } else {
                  dispatch(hideStatus(status.get('id')));
            app/javascript/mastodon/containers/status_container.js on lines 216..222
            app/javascript/mastodon/containers/status_container.js on lines 224..230
            app/javascript/mastodon/containers/status_container.js on lines 258..264
            app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js on lines 56..62
            app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js on lines 64..70
            app/javascript/mastodon/features/notifications/containers/notification_container.js on lines 64..70
            app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 152..158
            app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 168..174

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

            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

                    menu.push({ text: intl.formatMessage(messages.admin_status), href: `/admin/accounts/${status.getIn(['account', 'id'])}/statuses?id=${status.get('id')}` });
            Severity: Major
            Found in app/javascript/mastodon/components/status_action_bar.js and 1 other location - About 1 hr to fix
            app/javascript/mastodon/features/status/components/action_bar.js on lines 264..264

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

            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 9 locations. Consider refactoring.
            Open

              onMuteConversation (status) {
                if (status.get('muted')) {
                  dispatch(unmuteStatus(status.get('id')));
                } else {
                  dispatch(muteStatus(status.get('id')));
            app/javascript/mastodon/containers/status_container.js on lines 216..222
            app/javascript/mastodon/containers/status_container.js on lines 224..230
            app/javascript/mastodon/containers/status_container.js on lines 258..264
            app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js on lines 56..62
            app/javascript/mastodon/features/direct_timeline/containers/conversation_container.js on lines 64..70
            app/javascript/mastodon/features/notifications/containers/notification_container.js on lines 64..70
            app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 160..166
            app/javascript/mastodon/features/status/containers/detailed_status_container.js on lines 168..174

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

            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