maa123/mastodon

View on GitHub

Showing 793 of 1,813 total issues

File status.jsx has 494 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import PropTypes from 'prop-types';

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

import classNames from 'classnames';
Severity: Minor
Found in app/javascript/mastodon/components/status.jsx - About 7 hrs to fix

    Class User has 55 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class User < ApplicationRecord
      self.ignored_columns += %w(
        remember_created_at
        remember_token
        current_sign_in_ip
    Severity: Major
    Found in app/models/user.rb - About 7 hrs to fix

      File compose.js has 490 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable';
      
      import {
        COMPOSE_MOUNT,
        COMPOSE_UNMOUNT,
      Severity: Minor
      Found in app/javascript/mastodon/reducers/compose.js - About 7 hrs to fix

        File index.jsx has 485 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/index.jsx - About 7 hrs to fix

          File index.jsx has 479 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

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

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

              def call(username, domain, json, options = {})
                return if json['inbox'].blank? || unsupported_uri_scheme?(json['id']) || domain_not_allowed?(domain)
            
                @options     = options
                @json        = json
            Severity: Minor
            Found in app/services/activitypub/process_account_service.rb - About 7 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 173 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              render () {
                const status = this._properStatus();
                const outerStyle = { boxSizing: 'border-box' };
                const { intl, compact, pictureInPicture } = this.props;
            
            

              Status has 49 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class Status extends ImmutablePureComponent {
              
                static contextTypes = {
                  router: PropTypes.object,
                  identity: PropTypes.object,
              Severity: Minor
              Found in app/javascript/mastodon/features/status/index.jsx - About 6 hrs to fix

                Method remotable_attachment has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
                Open

                    def remotable_attachment(attachment_name, limit, suppress_errors: true, download_on_assign: true, attribute_name: nil)
                      attribute_name ||= "#{attachment_name}_remote_url".to_sym
                
                      define_method("download_#{attachment_name}!") do |url = nil|
                        url ||= self[attribute_name]
                Severity: Minor
                Found in app/models/concerns/remotable.rb - About 6 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 43 (exceeds 5 allowed). Consider refactoring.
                Open

                  def call(uri, id: true, prefetched_body: nil, suppress_errors: true)
                    raise Error, 'No key URI given' if uri.blank?
                
                    if prefetched_body.nil?
                      if id
                Severity: Minor
                Found in app/services/activitypub/fetch_remote_key_service.rb - About 6 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 interactions.js has 439 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import api, { getLinks } from '../api';
                
                import { fetchRelationships } from './accounts';
                import { importFetchedAccounts, importFetchedStatus } from './importer';
                
                
                Severity: Minor
                Found in app/javascript/mastodon/actions/interactions.js - About 6 hrs to fix

                  Audio has 46 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class Audio extends PureComponent {
                  
                    static propTypes = {
                      src: PropTypes.string.isRequired,
                      alt: PropTypes.string,
                  Severity: Minor
                  Found in app/javascript/mastodon/features/audio/index.jsx - About 6 hrs to fix

                    Method remove has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def remove
                          if options[:prune_profiles] && options[:remove_headers]
                            say('--prune-profiles and --remove-headers should not be specified simultaneously', :red, true)
                            exit(1)
                          end
                    Severity: Minor
                    Found in lib/mastodon/cli/media.rb - About 6 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 149 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      render () {
                        const { intl, multiColumn } = this.props;
                    
                        return (
                          <Column>
                    Severity: Major
                    Found in app/javascript/mastodon/features/keyboard_shortcuts/index.jsx - About 5 hrs to fix

                      Function emojifyTextNode has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const emojifyTextNode = (node, customEmojis) => {
                        const VS15 = 0xFE0E;
                        const VS16 = 0xFE0F;
                      
                        let str = node.textContent;
                      Severity: Minor
                      Found in app/javascript/mastodon/features/emoji/emoji.js - 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 purge has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def purge(*domains)
                            domains            = domains.map { |domain| TagManager.instance.normalize_domain(domain) }
                            account_scope      = Account.none
                            domain_block_scope = DomainBlock.none
                            emoji_scope        = CustomEmoji.none
                      Severity: Minor
                      Found in lib/mastodon/cli/domains.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

                      File header.jsx has 411 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import PropTypes from 'prop-types';
                      
                      import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
                      
                      import classNames from 'classnames';
                      Severity: Minor
                      Found in app/javascript/mastodon/features/account/components/header.jsx - About 5 hrs to fix

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

                          render () {
                            const { settings, pushSettings, onChange, onClear, alertsEnabled, browserSupport, browserPermission, onRequestNotificationPermission } = this.props;
                        
                            const unreadMarkersShowStr = <FormattedMessage id='notifications.column_settings.unread_notifications.highlight' defaultMessage='Highlight unread notifications' />;
                            const filterBarShowStr = <FormattedMessage id='notifications.column_settings.filter_bar.show_bar' defaultMessage='Show filter bar' />;

                          Function streamFrom has 133 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            const streamFrom = (ids, req, output, attachCloseHandler, destinationType, needsFiltering = false) => {
                              const accountId = req.accountId || req.remoteAddress;
                          
                              log.verbose(req.requestId, `Starting stream from ${ids.join(', ')} for ${accountId}`);
                          
                          
                          Severity: Major
                          Found in streaming/index.js - About 5 hrs to fix

                            Function mapDispatchToProps has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
                            Open

                            const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
                            
                              onReply (status, router) {
                                dispatch((_, getState) => {
                                  let state = getState();
                            Severity: Minor
                            Found in app/javascript/mastodon/containers/status_container.jsx - 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

                            Severity
                            Category
                            Status
                            Source
                            Language