maa123/mastodon

View on GitHub

Showing 793 of 1,813 total issues

Function mapDispatchToProps has a Cognitive Complexity of 29 (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

Method update_column_in_batches has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    def update_column_in_batches(table_name, column, value)
      if transaction_open?
        raise 'update_column_in_batches can not be run inside a transaction, ' \
          'you can disable transactions by calling disable_ddl_transaction! ' \
          'in the body of your migration class'
Severity: Minor
Found in lib/mastodon/migration_helpers.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

Method parallelize_with_progress has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    def parallelize_with_progress(scope)
      if options[:concurrency] < 1
        say('Cannot run with this concurrency setting, must be at least 1', :red)
        exit(1)
      end
Severity: Minor
Found in lib/mastodon/cli/progress_helper.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 emoji_picker_dropdown.jsx has 343 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';

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

      render () {
        const { src, intl, alt, lang, editable, autoPlay, sensitive, blurhash } = this.props;
        const { paused, volume, currentTime, duration, buffer, dragging, 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/audio/index.jsx - About 4 hrs to fix

      Function getData has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

      function getData(emoji, skin, set) {
        let emojiData = {};
      
        if (typeof emoji === 'string') {
          let matches = emoji.match(COLONS_REGEX);
      Severity: Minor
      Found in app/javascript/mastodon/features/emoji/emoji_utils.js - 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 102 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        render () {
          const { media, statusId, lang, intl, onClose } = this.props;
          const { navigationHidden } = this.state;
      
          const index = this.getIndex();
      Severity: Major
      Found in app/javascript/mastodon/features/ui/components/media_modal.jsx - About 4 hrs to fix

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

          render () {
            const { router } = this.context;
            const { title, icon, active, children, pinned, multiColumn, extraButton, showBackButton, intl: { formatMessage }, placeholder, appendContent, collapseIssues } = this.props;
            const { collapsed, animating } = this.state;
        
        
        Severity: Major
        Found in app/javascript/mastodon/components/column_header.jsx - About 4 hrs to fix

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

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

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

            class Status extends ImmutablePureComponent {
            
              static contextTypes = {
                router: PropTypes.object,
              };
            Severity: Minor
            Found in app/javascript/mastodon/components/status.jsx - About 4 hrs to fix

              Class Maintenance has 32 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class Maintenance < Base
                  MIN_SUPPORTED_VERSION = 2019_10_01_213028
                  MAX_SUPPORTED_VERSION = 2023_09_07_150100
              
                  # Stubs to enjoy ActiveRecord queries while not depending on a particular
              Severity: Minor
              Found in lib/mastodon/cli/maintenance.rb - About 4 hrs to fix

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

                  render () {
                    const { card } = this.props;
                    const { embedded, revealed } = this.state;
                
                    if (card === null) {
                Severity: Major
                Found in app/javascript/mastodon/features/status/components/card.jsx - About 3 hrs to fix

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

                    render () {
                      const { attachment, lang, index, size, standalone, displayWidth, visible } = this.props;
                  
                      let badges = [], thumbnail;
                  
                  
                  Severity: Major
                  Found in app/javascript/mastodon/components/media_gallery.jsx - About 3 hrs to fix

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

                    const mapDispatchToProps = (dispatch, { intl }) => ({
                    
                      onFollow (account) {
                        if (account.getIn(['relationship', 'following'])) {
                          if (unfollowModal) {

                    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 LinkDetailsExtractor has 31 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class LinkDetailsExtractor
                      include ActionView::Helpers::TagHelper
                      include LanguagesHelper
                    
                      # Some publications wrap their JSON-LD data in their <script> tags
                    Severity: Minor
                    Found in app/lib/link_details_extractor.rb - About 3 hrs to fix

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

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

                          render () {
                            let ancestors, descendants;
                            const { isLoading, status, ancestorsIds, descendantsIds, intl, domain, multiColumn, pictureInPicture } = this.props;
                            const { fullscreen } = this.state;
                        
                        
                        Severity: Major
                        Found in app/javascript/mastodon/features/status/index.jsx - About 3 hrs to fix

                          Function userLists has 95 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export default function userLists(state = initialState, action) {
                            switch(action.type) {
                            case FOLLOWERS_FETCH_SUCCESS:
                              return normalizeList(state, ['followers', action.id], action.accounts, action.next);
                            case FOLLOWERS_EXPAND_SUCCESS:
                          Severity: Major
                          Found in app/javascript/mastodon/reducers/user_lists.js - About 3 hrs to fix

                            File user.rb has 325 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 3 hrs to fix

                              Method remove_orphans has 95 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  def remove_orphans
                                    progress        = create_progress_bar(nil)
                                    reclaimed_bytes = 0
                                    removed         = 0
                                    prefix          = options[:prefix]
                              Severity: Major
                              Found in lib/mastodon/cli/media.rb - About 3 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language