maa123/mastodon

View on GitHub

Showing 793 of 1,813 total issues

Function startServer has 812 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const startServer = async () => {
  const app = express();

  app.set('trust proxy', process.env.TRUSTED_PROXY_IP ? process.env.TRUSTED_PROXY_IP.split(/(?:\s*,\s*|\s+)/) : 'loopback,uniquelocal');

Severity: Major
Found in streaming/index.js - About 4 days to fix

    Function startServer has a Cognitive Complexity of 122 (exceeds 5 allowed). Consider refactoring.
    Open

    const startServer = async () => {
      const app = express();
    
      app.set('trust proxy', process.env.TRUSTED_PROXY_IP ? process.env.TRUSTED_PROXY_IP.split(/(?:\s*,\s*|\s+)/) : 'loopback,uniquelocal');
    
    
    Severity: Minor
    Found in streaming/index.js - About 2 days 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 index.js has 953 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // @ts-check
    
    const fs = require('fs');
    const http = require('http');
    const url = require('url');
    Severity: Major
    Found in streaming/index.js - About 2 days to fix

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

        render () {
          const { account, hidden, intl, domain } = this.props;
          const { signedIn, permissions } = this.context.identity;
      
          if (!account) {
      Severity: Minor
      Found in app/javascript/mastodon/features/account/components/header.jsx - About 1 day 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 compose.js has 663 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { defineMessages } from 'react-intl';
      
      import axios from 'axios';
      import { throttle } from 'lodash';
      
      
      Severity: Major
      Found in app/javascript/mastodon/actions/compose.js - About 1 day to fix

        File accounts.js has 657 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import api, { getLinks } from '../api';
        
        import { importFetchedAccount, importFetchedAccounts } from './importer';
        
        export const ACCOUNT_FETCH_REQUEST = 'ACCOUNT_FETCH_REQUEST';
        Severity: Major
        Found in app/javascript/mastodon/actions/accounts.js - About 1 day to fix

          Method remove_orphans has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
          Open

              def remove_orphans
                progress        = create_progress_bar(nil)
                reclaimed_bytes = 0
                removed         = 0
                prefix          = options[:prefix]
          Severity: Minor
          Found in lib/mastodon/cli/media.rb - About 1 day 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 index.jsx has 628 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: Major
          Found in app/javascript/mastodon/features/status/index.jsx - About 1 day to fix

            Function search has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
            Open

            function search(value, { emojisToShowFilter, maxResults, include, exclude, custom } = {}) {
              if (custom !== undefined) {
                if (customEmojisList !== custom)
                  addCustomToPool(custom, originalPool);
              } else {
            Severity: Minor
            Found in app/javascript/mastodon/features/emoji/emoji_mart_search_light.js - About 1 day 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 66 (exceeds 5 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: Minor
            Found in app/javascript/mastodon/components/status_action_bar.jsx - About 1 day 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 compose has 238 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function compose(state = initialState, action) {
              switch(action.type) {
              case STORE_HYDRATE:
                return hydrate(state, action.state.get('compose'));
              case COMPOSE_MOUNT:
            Severity: Major
            Found in app/javascript/mastodon/reducers/compose.js - About 1 day to fix

              Class Account has 64 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class Account < ApplicationRecord
                self.ignored_columns += %w(
                  subscription_expires_at
                  secret
                  remote_url
              Severity: Major
              Found in app/models/account.rb - About 1 day to fix

                File accounts.rb has 554 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                require 'set'
                require_relative 'base'
                
                module Mastodon::CLI
                  class Accounts < Base
                Severity: Major
                Found in lib/mastodon/cli/accounts.rb - About 1 day to fix

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

                    render () {
                      const { status, relationship, intl } = this.props;
                      const { signedIn, permissions } = this.context.identity;
                  
                      const publicStatus       = ['public', 'unlisted'].includes(status.get('visibility'));
                  Severity: Minor
                  Found in app/javascript/mastodon/features/status/components/action_bar.jsx - About 1 day 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 maintenance.rb has 538 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require_relative 'base'
                  
                  module Mastodon::CLI
                    class Maintenance < Base
                      MIN_SUPPORTED_VERSION = 2019_10_01_213028
                  Severity: Major
                  Found in lib/mastodon/cli/maintenance.rb - About 1 day to fix

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

                      render () {
                        const { account, hidden, intl, domain } = this.props;
                        const { signedIn, permissions } = this.context.identity;
                    
                        if (!account) {
                    Severity: Major
                    Found in app/javascript/mastodon/features/account/components/header.jsx - About 1 day to fix

                      Function render has 216 lines of code (exceeds 25 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: Major
                      Found in app/javascript/mastodon/components/status.jsx - About 1 day to fix

                        File migration_helpers.rb has 516 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        module Mastodon
                          module MigrationHelpers
                            class CorruptionError < StandardError
                              attr_reader :index_name
                        
                        
                        Severity: Major
                        Found in lib/mastodon/migration_helpers.rb - About 1 day to fix

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

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

                            Class Status has 56 methods (exceeds 20 allowed). Consider refactoring.
                            Open

                            class Status < ApplicationRecord
                              include Discard::Model
                              include Paginable
                              include Cacheable
                              include StatusThreadingConcern
                            Severity: Major
                            Found in app/models/status.rb - About 1 day to fix
                              Severity
                              Category
                              Status
                              Source
                              Language