maa123/mastodon

View on GitHub

Showing 793 of 1,813 total issues

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

  def discover_endpoint!
    return if html.nil?

    @format = @options[:format]
    page    = Nokogiri::HTML(html)
Severity: Minor
Found in app/services/fetch_oembed_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 call has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  def call(body, actor, **options)
    @account = actor
    @json    = original_json = Oj.load(body, mode: :strict)
    @options = options

Severity: Minor
Found in app/services/activitypub/process_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 call has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  def call(row)
    @account = row.bulk_import.account
    @data    = row.data
    @type    = row.bulk_import.type.to_sym

Severity: Minor
Found in app/services/bulk_import_row_service.rb - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

  render () {
    const { intl, onPaste, autoFocus } = this.props;
    const { highlighted } = this.state;
    const disabled = this.props.isSubmitting;

Severity: Major
Found in app/javascript/mastodon/features/compose/components/compose_form.jsx - About 3 hrs to fix

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

      render () {
        const { attachment, displayWidth } = this.props;
        const { visible, loaded } = this.state;
    
        const width  = `${Math.floor((displayWidth - 4) / 3) - 4}px`;

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

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

        File feed_manager.rb has 305 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'singleton'
        
        class FeedManager
          include Singleton
          include Redisable
        Severity: Minor
        Found in app/lib/feed_manager.rb - About 3 hrs to fix

          Method to_s has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

            def to_s
              return html if custom_emojis.empty? || html.blank?
          
              tree = Nokogiri::HTML.fragment(html)
              tree.xpath('./text()|.//text()[not(ancestor[@class="invisible"])]').to_a.each do |node|
          Severity: Minor
          Found in app/lib/emoji_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 call has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

            def call(uri, options = {})
              return if uri.blank?
          
              process_options!(uri, options)
          
          
          Severity: Minor
          Found in app/services/resolve_account_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 self_destruct has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

              def self_destruct
                require 'tty-prompt'
          
                prompt = TTY::Prompt.new
          
          
          Severity: Minor
          Found in lib/mastodon/cli/main.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

          File media_attachment.rb has 299 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          class MediaAttachment < ApplicationRecord
            self.inheritance_column = nil
          
            include Attachmentable
          
          
          Severity: Minor
          Found in app/models/media_attachment.rb - About 3 hrs to fix

            ScrollableList has 27 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class ScrollableList extends PureComponent {
            
              static contextTypes = {
                router: PropTypes.object,
              };
            Severity: Minor
            Found in app/javascript/mastodon/components/scrollable_list.jsx - About 3 hrs to fix

              Class NotifyService has 27 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class NotifyService < BaseService
                include Redisable
              
                NON_EMAIL_TYPES = %i(
                  admin.report
              Severity: Minor
              Found in app/services/notify_service.rb - About 3 hrs to fix

                Class FeedManager has 27 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class FeedManager
                  include Singleton
                  include Redisable
                
                  # Maximum number of items stored in a single feed
                Severity: Minor
                Found in app/lib/feed_manager.rb - About 3 hrs to fix

                  File scrollable_list.jsx has 297 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import PropTypes from 'prop-types';
                  import { Children, cloneElement, PureComponent } from 'react';
                  
                  import classNames from 'classnames';
                  
                  
                  Severity: Minor
                  Found in app/javascript/mastodon/components/scrollable_list.jsx - About 3 hrs to fix

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

                      render () {
                        const { selectedFilter, advancedMode, intl } = this.props;
                        const renderedElement = !advancedMode ? (
                          <div className='notification__filter-bar'>
                            <button

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

                        def call(uri, id: true, prefetched_body: nil, on_behalf_of: nil, expected_actor_uri: nil, request_id: nil)
                          return if domain_not_allowed?(uri)
                      
                          @request_id = request_id || "#{Time.now.utc.to_i}-status-#{uri}"
                          @json = if prefetched_body.nil?
                      Severity: Minor
                      Found in app/services/activitypub/fetch_remote_status_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 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

                      File media.rb has 295 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      require_relative 'base'
                      
                      module Mastodon::CLI
                        class Media < Base
                          include ActionView::Helpers::NumberHelper
                      Severity: Minor
                      Found in lib/mastodon/cli/media.rb - About 3 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language