maa123/mastodon

View on GitHub

Showing 793 of 1,813 total issues

File notification.jsx has 384 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import PropTypes from 'prop-types';

import { injectIntl, FormattedMessage, defineMessages } from 'react-intl';

import classNames from 'classnames';

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

      render () {
        const { media, intl, account, onClose, isUploadingThumbnail, description, lang, focusX, focusY, dirty, is_changing_upload } = this.props;
        const { dragging, detecting, progress, ocrStatus } = this.state;
        const x = (focusX /  2) + .5;
        const y = (focusY / -2) + .5;
    Severity: Major
    Found in app/javascript/mastodon/features/ui/components/focal_point_modal.jsx - About 5 hrs to fix

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

        def publish_media_attachments!
          attachment_names = MediaAttachment.attachment_definitions.keys
      
          @account.media_attachments.reorder(nil).find_each do |media_attachment|
            attachment_names.each do |attachment_name|
      Severity: Minor
      Found in app/services/unsuspend_account_service.rb - About 5 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 privatize_media_attachments! has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

        def privatize_media_attachments!
          attachment_names = MediaAttachment.attachment_definitions.keys
      
          @account.media_attachments.reorder(nil).find_each do |media_attachment|
            attachment_names.each do |attachment_name|
      Severity: Minor
      Found in app/services/suspend_account_service.rb - About 5 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 storage_schema has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

          def storage_schema
            progress = create_progress_bar(nil)
            records  = 0
      
            klasses = [
      Severity: Minor
      Found in lib/mastodon/cli/upgrade.rb - About 5 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

      Class ProcessAccountService has 38 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class ActivityPub::ProcessAccountService < BaseService
        include JsonLdHelper
        include DomainControlHelper
        include Redisable
        include Lockable
      Severity: Minor
      Found in app/services/activitypub/process_account_service.rb - About 5 hrs to fix

        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

          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

                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';
                
                

                  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

                        File focal_point_modal.jsx has 356 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

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

                          File status.rb has 354 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          class Status < ApplicationRecord
                            include Discard::Model
                            include Paginable
                            include Cacheable
                            include StatusThreadingConcern
                          Severity: Minor
                          Found in app/models/status.rb - About 4 hrs to fix

                            Function render has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                            Open

                              render () {
                                const { intl, hidden, featured, unread, showThread, scrollKey, pictureInPicture, previousId, nextInReplyToId, rootId } = this.props;
                            
                                let { status, account, ...other } = this.props;
                            
                            
                            Severity: Minor
                            Found in app/javascript/mastodon/components/status.jsx - 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

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

                              render () {
                                const { preview, src, aspectRatio, onOpenVideo, onCloseVideo, intl, alt, lang, detailed, sensitive, editable, blurhash, autoFocus } = this.props;
                                const { currentTime, duration, volume, buffer, dragging, paused, fullscreen, hovered, revealed } = this.state;
                                const progress = Math.min((currentTime / duration) * 100, 100);
                                const muted = this.state.muted || volume === 0;
                            Severity: Major
                            Found in app/javascript/mastodon/features/video/index.jsx - About 4 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language