maa123/mastodon

View on GitHub
app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx

Summary

Maintainability
F
4 days
Test Coverage

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 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      render () {
        const { loading, style, intl, custom_emojis, skinTone, frequentlyUsedEmojis } = this.props;
    
        if (loading) {
          return <div style={{ width: 299 }} />;

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

        render () {
          const { intl, onPickEmoji, onSkinTone, skinTone, frequentlyUsedEmojis, button } = this.props;
          const title = intl.formatMessage(messages.emoji);
          const { active, loading } = this.state;
      
      

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

        const messages = defineMessages({
          emoji: { id: 'emoji_button.label', defaultMessage: 'Insert emoji' },
          emoji_search: { id: 'emoji_button.search', defaultMessage: 'Search...' },
          custom: { id: 'emoji_button.custom', defaultMessage: 'Custom' },
          recent: { id: 'emoji_button.recent', defaultMessage: 'Frequently used' },
        app/javascript/mastodon/features/compose/components/action_bar.jsx on lines 10..24

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

        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 6 locations. Consider refactoring.
        Open

                <button type='button' onClick={this.handleClick} data-index={1}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={1} backgroundImageFn={backgroundImageFn} /></button>
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 106..106
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 107..107
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 108..108
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 109..109
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 110..110

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

        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 6 locations. Consider refactoring.
        Open

                <button type='button' onClick={this.handleClick} data-index={2}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={2} backgroundImageFn={backgroundImageFn} /></button>
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 105..105
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 107..107
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 108..108
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 109..109
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 110..110

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

        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 6 locations. Consider refactoring.
        Open

                <button type='button' onClick={this.handleClick} data-index={4}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={4} backgroundImageFn={backgroundImageFn} /></button>
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 105..105
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 106..106
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 107..107
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 109..109
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 110..110

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

        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 6 locations. Consider refactoring.
        Open

                <button type='button' onClick={this.handleClick} data-index={6}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={6} backgroundImageFn={backgroundImageFn} /></button>
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 105..105
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 106..106
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 107..107
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 108..108
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 109..109

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

        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 6 locations. Consider refactoring.
        Open

                <button type='button' onClick={this.handleClick} data-index={3}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={3} backgroundImageFn={backgroundImageFn} /></button>
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 105..105
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 106..106
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 108..108
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 109..109
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 110..110

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

        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 6 locations. Consider refactoring.
        Open

                <button type='button' onClick={this.handleClick} data-index={5}><Emoji emoji='fist' set='twitter' size={22} sheetSize={32} skin={5} backgroundImageFn={backgroundImageFn} /></button>
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 105..105
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 106..106
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 107..107
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 108..108
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 110..110

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

        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

          handleDocumentClick = e => {
            if (this.node && !this.node.contains(e.target)) {
              this.props.onClose();
            }
          };
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 178..182

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

        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

          handleDocumentClick = e => {
            if (this.node && !this.node.contains(e.target)) {
              this.props.onClose();
            }
          };
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 80..84

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

        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

          static propTypes = {
            active: PropTypes.bool,
            modifier: PropTypes.number,
            onChange: PropTypes.func,
            onClose: PropTypes.func,
        app/javascript/mastodon/features/ui/components/column.jsx on lines 13..19
        app/javascript/mastodon/features/ui/components/column_header.jsx on lines 10..16

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

        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 5 locations. Consider refactoring.
        Open

          removeListeners () {
            document.removeEventListener('click', this.handleDocumentClick, { capture: true });
            document.removeEventListener('touchend', this.handleDocumentClick, listenerOptions);
          }
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 86..89
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 199..202
        app/javascript/mastodon/features/compose/components/language_dropdown.jsx on lines 65..68
        app/javascript/mastodon/features/compose/components/privacy_dropdown.jsx on lines 105..108

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

        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 5 locations. Consider refactoring.
        Open

          componentWillUnmount () {
            document.removeEventListener('click', this.handleDocumentClick, { capture: true });
            document.removeEventListener('touchend', this.handleDocumentClick, listenerOptions);
          }
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 86..89
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 91..94
        app/javascript/mastodon/features/compose/components/language_dropdown.jsx on lines 65..68
        app/javascript/mastodon/features/compose/components/privacy_dropdown.jsx on lines 105..108

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

        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 5 locations. Consider refactoring.
        Open

          attachListeners () {
            document.addEventListener('click', this.handleDocumentClick, { capture: true });
            document.addEventListener('touchend', this.handleDocumentClick, listenerOptions);
          }
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 91..94
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 199..202
        app/javascript/mastodon/features/compose/components/language_dropdown.jsx on lines 65..68
        app/javascript/mastodon/features/compose/components/privacy_dropdown.jsx on lines 105..108

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

        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

        There are no issues that match your filters.

        Category
        Status