mashirozx/mastodon

View on GitHub

Showing 1,785 of 1,785 total issues

Function render has a Cognitive Complexity of 22 (exceeds 5 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: Minor
Found in app/javascript/mastodon/features/video/index.js - About 3 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 import has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def import(path)
      imported = 0
      skipped  = 0
      failed   = 0
      category = options[:category] ? CustomEmojiCategory.find_or_create_by(name: options[:category]) : nil
Severity: Minor
Found in lib/mastodon/emoji_cli.rb - About 3 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 refresh has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def refresh
      dry_run = options[:dry_run] ? ' (DRY RUN)' : ''

      if options[:status]
        scope = MediaAttachment.where(status_id: options[:status])
Severity: Minor
Found in lib/mastodon/media_cli.rb - About 3 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 scrollable_list.js has 295 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, { PureComponent } from 'react';
import ScrollContainer from 'mastodon/containers/scroll_container';
import PropTypes from 'prop-types';
import IntersectionObserverArticleContainer from '../containers/intersection_observer_article_container';
import LoadMore from './load_more';
Severity: Minor
Found in app/javascript/mastodon/components/scrollable_list.js - About 3 hrs to fix

    File lists.js has 294 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import api from '../api';
    import { importFetchedAccounts } from './importer';
    import { showAlertForError } from './alerts';
    
    export const LIST_FETCH_REQUEST = 'LIST_FETCH_REQUEST';
    Severity: Minor
    Found in app/javascript/mastodon/actions/lists.js - About 3 hrs to fix

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

        it('should give same result for emoji_index_light and emoji-mart', () => {
          const expected = [
            {
              id: 'pineapple',
              unified: '1f34d',
      app/javascript/mastodon/features/emoji/__tests__/emoji_index-test.js on lines 153..163
      app/javascript/mastodon/features/emoji/__tests__/emoji_index-test.js on lines 165..175

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 96.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

        it('can search for woman-facepalming', () => {
          const expected = [
            {
              id: 'woman-facepalming',
              unified: '1f926-200d-2640-fe0f',
      app/javascript/mastodon/features/emoji/__tests__/emoji_index-test.js on lines 8..18
      app/javascript/mastodon/features/emoji/__tests__/emoji_index-test.js on lines 153..163

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 96.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

        it('can search for thinking_face', () => {
          const expected = [
            {
              id: 'thinking_face',
              unified: '1f914',
      app/javascript/mastodon/features/emoji/__tests__/emoji_index-test.js on lines 8..18
      app/javascript/mastodon/features/emoji/__tests__/emoji_index-test.js on lines 165..175

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 96.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      export const deleteList = id => (dispatch, getState) => {
        dispatch(deleteListRequest(id));
      
        api(getState).delete(`/api/v1/lists/${id}`)
          .then(() => dispatch(deleteListSuccess(id)))
      Severity: Major
      Found in app/javascript/mastodon/actions/lists.js and 1 other location - About 3 hrs to fix
      app/javascript/mastodon/actions/conversations.js on lines 90..96

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 96.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      export const deleteConversation = conversationId => (dispatch, getState) => {
        dispatch(deleteConversationRequest(conversationId));
      
        api(getState).delete(`/api/v1/conversations/${conversationId}`)
          .then(() => dispatch(deleteConversationSuccess(conversationId)))
      Severity: Major
      Found in app/javascript/mastodon/actions/conversations.js and 1 other location - About 3 hrs to fix
      app/javascript/mastodon/actions/lists.js on lines 185..191

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 96.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

        render () {
          const { attachment, displayWidth } = this.props;
          const { visible, loaded } = this.state;
      
          const width  = `${Math.floor((displayWidth - 4) / 3) - 4}px`;

        Class MediaAttachment has 26 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class MediaAttachment < ApplicationRecord
          self.inheritance_column = nil
        
          include Attachmentable
        
        
        Severity: Minor
        Found in app/models/media_attachment.rb - About 3 hrs to fix

          Class PostStatusService has 26 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class PostStatusService < BaseService
            include Redisable
            include LanguagesHelper
          
            MIN_SCHEDULE_OFFSET = 5.minutes.freeze
          Severity: Minor
          Found in app/services/post_status_service.rb - About 3 hrs to fix

            Class FeedManager has 26 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class FeedManager
              include Singleton
              include Redisable
            
              # Maximum number of items stored in a single feed
            Severity: Minor
            Found in app/lib/feed_manager.rb - About 3 hrs to fix

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

                render () {
                  const { intl, onPaste, showSearch } = this.props;
                  const disabled = this.props.isSubmitting;
              
                  let publishText = '';
              Severity: Major
              Found in app/javascript/mastodon/features/compose/components/compose_form.js - About 2 hrs to fix

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

                  render() {
                    const { account, intl } = this.props;
                
                    let actionBtn;
                
                
                Severity: Major
                Found in app/javascript/mastodon/features/directory/components/account_card.js - About 2 hrs to fix

                  Identical blocks of code found in 2 locations. Consider refactoring.
                  Open

                          <div className={classNames('media-gallery__item', { standalone })} key={attachment.get('id')} style={{ left: left, top: top, right: right, bottom: bottom, width: `${width}%`, height: `${height}%` }}>
                            <a className='media-gallery__item-thumbnail' href={attachment.get('remote_url') || attachment.get('url')} style={{ cursor: 'pointer' }} title={attachment.get('description')} target='_blank' rel='noopener noreferrer'>
                              <Blurhash
                                hash={attachment.get('blurhash')}
                                className='media-gallery__preview'
                  Severity: Major
                  Found in app/javascript/mastodon/components/media_gallery.js and 1 other location - About 2 hrs to fix
                  app/javascript/mastodon/components/media_gallery.js on lines 353..362

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 94.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 4 locations. Consider refactoring.
                  Open

                    handleBlockClick = () => {
                      const { status, relationship, onBlock, onUnblock } = this.props;
                      const account = status.get('account');
                  
                      if (relationship && relationship.get('blocking')) {
                  app/javascript/mastodon/components/status_action_bar.js on lines 171..180
                  app/javascript/mastodon/components/status_action_bar.js on lines 182..191
                  app/javascript/mastodon/features/status/components/action_bar.js on lines 124..133

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 94.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Identical blocks of code found in 2 locations. Consider refactoring.
                  Open

                        <div className={classNames('media-gallery__item', { standalone })} key={attachment.get('id')} style={{ left: left, top: top, right: right, bottom: bottom, width: `${width}%`, height: `${height}%` }}>
                          <Blurhash
                            hash={attachment.get('blurhash')}
                            dummy={!useBlurhash}
                            className={classNames('media-gallery__preview', {
                  Severity: Major
                  Found in app/javascript/mastodon/components/media_gallery.js and 1 other location - About 2 hrs to fix
                  app/javascript/mastodon/components/media_gallery.js on lines 282..290

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 94.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 4 locations. Consider refactoring.
                  Open

                    handleMuteClick = () => {
                      const { status, relationship, onMute, onUnmute } = this.props;
                      const account = status.get('account');
                  
                      if (relationship && relationship.get('muting')) {
                  app/javascript/mastodon/components/status_action_bar.js on lines 171..180
                  app/javascript/mastodon/components/status_action_bar.js on lines 182..191
                  app/javascript/mastodon/features/status/components/action_bar.js on lines 135..144

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 94.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language