mashirozx/mastodon

View on GitHub

Showing 720 of 1,785 total issues

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

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

  render () {
    const { status, relationship, intl } = this.props;

    const publicStatus       = ['public', 'unlisted'].includes(status.get('visibility'));
    const pinnableStatus     = ['public', 'unlisted', 'private'].includes(status.get('visibility'));
Severity: Minor
Found in app/javascript/mastodon/features/status/components/action_bar.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

Video has 39 functions (exceeds 20 allowed). Consider refactoring.
Open

export default @injectIntl
class Video extends React.PureComponent {

  static propTypes = {
    preview: PropTypes.string,
Severity: Minor
Found in app/javascript/mastodon/features/video/index.js - About 5 hrs to fix

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

      const streamFrom = (ids, req, output, attachCloseHandler, 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

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

      export default @injectIntl
      class Status extends ImmutablePureComponent {
      
        static contextTypes = {
          router: PropTypes.object,
      Severity: Minor
      Found in app/javascript/mastodon/components/status.js - About 5 hrs to fix

        File notification.js has 370 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import React from 'react';
        import ImmutablePropTypes from 'react-immutable-proptypes';
        import { injectIntl, FormattedMessage, defineMessages } from 'react-intl';
        import { HotKeys } from 'react-hotkeys';
        import PropTypes from 'prop-types';

          Class UserSettingsDecorator has 37 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class UserSettingsDecorator
            attr_reader :user, :settings
          
            def initialize(user)
              @user = user
          Severity: Minor
          Found in app/lib/user_settings_decorator.rb - About 4 hrs to fix

            Class ProcessAccountService has 37 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 4 hrs to fix

              File announcements.js has 366 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import React from 'react';
              import ImmutablePureComponent from 'react-immutable-pure-component';
              import ReactSwipeableViews from 'react-swipeable-views';
              import ImmutablePropTypes from 'react-immutable-proptypes';
              import PropTypes from 'prop-types';

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

                const mapDispatchToProps = (dispatch, { intl }) => ({
                
                  onReply (status, router) {
                    dispatch((_, getState) => {
                      let state = getState();

                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

                UI has 36 functions (exceeds 20 allowed). Consider refactoring.
                Open

                export default @connect(mapStateToProps)
                @injectIntl
                @withRouter
                class UI extends React.PureComponent {
                
                
                Severity: Minor
                Found in app/javascript/mastodon/features/ui/index.js - About 4 hrs to fix

                  File zoomable_image.js has 361 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import React from 'react';
                  import PropTypes from 'prop-types';
                  import IconButton from 'mastodon/components/icon_button';
                  import { defineMessages, injectIntl } from 'react-intl';
                  
                  
                  Severity: Minor
                  Found in app/javascript/mastodon/features/ui/components/zoomable_image.js - About 4 hrs to fix

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

                      render () {
                        const { media, intl, account, onClose, isUploadingThumbnail, description, 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.js - About 4 hrs to fix

                      Function listener has 115 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          const listener = message => {
                            const json = parseJSON(message, req);
                      
                            if (!json) return;
                      
                      
                      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/domains_cli.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

                        Function translationEndpointCallback has 114 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const translationEndpointCallback = async (request, response) => {
                          const body = request.body;
                        
                          const { content, to, status, edit } = body;
                        
                        
                        Severity: Major
                        Found in translation/index.js - About 4 hrs to fix

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

                            render () {
                              const { preview, src, inline, onOpenVideo, onCloseVideo, intl, alt, detailed, sensitive, editable, blurhash } = this.props;
                              const { quote } = this.props;
                              // const { preview, src, inline, onOpenVideo, onCloseVideo, intl, alt, detailed, sensitive, link, editable, blurhash, quote } = this.props;
                              const { containerWidth, currentTime, duration, volume, buffer, dragging, paused, fullscreen, hovered, muted, revealed } = this.state;
                          Severity: Major
                          Found in app/javascript/mastodon/features/video/index.js - About 4 hrs to fix

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

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

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

                                render () {
                                  const { status, relationship, intl, withDismiss, withCounters, scrollKey } = this.props;
                              
                                  const anonymousAccess    = !me;
                                  const publicStatus       = ['public', 'unlisted'].includes(status.get('visibility'));
                              Severity: Major
                              Found in app/javascript/mastodon/components/status_action_bar.js - About 4 hrs to fix

                                File interactions.js has 352 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                import api from '../api';
                                import { importFetchedAccounts, importFetchedStatus } from './importer';
                                
                                export const REBLOG_REQUEST = 'REBLOG_REQUEST';
                                export const REBLOG_SUCCESS = 'REBLOG_SUCCESS';
                                Severity: Minor
                                Found in app/javascript/mastodon/actions/interactions.js - About 4 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language