mashirozx/mastodon

View on GitHub
app/javascript/mastodon/components/dropdown_menu.js

Summary

Maintainability
D
2 days
Test Coverage

File dropdown_menu.js has 303 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from 'react';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import IconButton from './icon_button';
import Overlay from 'react-overlays/lib/Overlay';
Severity: Minor
Found in app/javascript/mastodon/components/dropdown_menu.js - About 3 hrs to fix

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

      render () {
        const {
          icon,
          items,
          size,
    Severity: Major
    Found in app/javascript/mastodon/components/dropdown_menu.js - About 2 hrs to fix

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

        render () {
          const { items, style, placement, arrowOffsetLeft, arrowOffsetTop, scrollable, renderHeader, loading } = this.props;
          const { mounted } = this.state;
      
          let renderItem = this.props.renderItem || this.renderItem;
      Severity: Minor
      Found in app/javascript/mastodon/components/dropdown_menu.js - About 1 hr to fix

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

              <Motion defaultStyle={{ opacity: 0, scaleX: 0.85, scaleY: 0.75 }} style={{ opacity: spring(1, { damping: 35, stiffness: 400 }), scaleX: spring(1, { damping: 35, stiffness: 400 }), scaleY: spring(1, { damping: 35, stiffness: 400 }) }}>
                {({ opacity, scaleX, scaleY }) => (
                  // It should not be transformed when mounting because the resulting
                  // size will be used to determine the coordinate of the menu by
                  // react-overlays
        Severity: Major
        Found in app/javascript/mastodon/components/dropdown_menu.js and 6 other locations - About 3 hrs to fix
        app/javascript/mastodon/features/compose/components/content_type_dropdown.js on lines 119..139
        app/javascript/mastodon/features/compose/components/federation_dropdown.js on lines 122..142
        app/javascript/mastodon/features/compose/components/language_dropdown.js on lines 222..238
        app/javascript/mastodon/features/compose/components/privacy_dropdown.js on lines 125..145
        app/javascript/mastodon/features/compose/components/search.js on lines 25..40
        app/javascript/mastodon/features/compose/components/warning.js on lines 16..22

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

        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

            const {
              icon,
              items,
              size,
              title,
        Severity: Major
        Found in app/javascript/mastodon/components/dropdown_menu.js and 1 other location - About 2 hrs to fix
        app/javascript/mastodon/components/icon_button.js on lines 93..107

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

        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

                  <div className={`dropdown-menu ${placement}`} style={{ ...style, opacity: opacity, transform: mounted ? `scale(${scaleX}, ${scaleY})` : null }} ref={this.setRef}>
                    <div className={`dropdown-menu__arrow ${placement}`} style={{ left: arrowOffsetLeft, top: arrowOffsetTop }} />
        
                    <div className={classNames('dropdown-menu__container', { 'dropdown-menu__container--loading': loading })}>
                      {loading && (
        Severity: Major
        Found in app/javascript/mastodon/components/dropdown_menu.js and 1 other location - About 1 hr to fix
        app/javascript/mastodon/features/compose/components/language_dropdown.js on lines 227..236

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

        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

              if (e.shiftKey) {
                element = items[index-1] || items[items.length-1];
              } else {
                element = items[index+1] || items[0];
              }
        Severity: Major
        Found in app/javascript/mastodon/components/dropdown_menu.js and 1 other location - About 1 hr to fix
        app/javascript/mastodon/components/modal_root.js on lines 40..44

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

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

          handleDocumentClick = e => {
            if (this.node && !this.node.contains(e.target)) {
              this.props.onClose();
            }
          }
        Severity: Major
        Found in app/javascript/mastodon/components/dropdown_menu.js and 6 other locations - About 1 hr to fix
        app/javascript/mastodon/features/compose/components/content_type_dropdown.js on lines 35..39
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js on lines 74..78
        app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js on lines 176..180
        app/javascript/mastodon/features/compose/components/federation_dropdown.js on lines 36..40
        app/javascript/mastodon/features/compose/components/language_dropdown.js on lines 44..48
        app/javascript/mastodon/features/compose/components/privacy_dropdown.js on lines 41..45

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

            const { items, style, placement, arrowOffsetLeft, arrowOffsetTop, scrollable, renderHeader, loading } = this.props;
        Severity: Major
        Found in app/javascript/mastodon/components/dropdown_menu.js and 5 other locations - About 50 mins to fix
        app/javascript/mastodon/components/media_gallery.js on lines 460..460
        app/javascript/mastodon/components/status.js on lines 371..371
        app/javascript/mastodon/features/audio/index.js on lines 462..462
        app/javascript/mastodon/features/notifications/components/column_settings.js on lines 32..32
        app/javascript/mastodon/features/ui/components/report_modal.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 52.

        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

          handleItemKeyPress = e => {
            if (e.key === 'Enter' || e.key === ' ') {
              this.handleClick(e);
            }
          }
        Severity: Minor
        Found in app/javascript/mastodon/components/dropdown_menu.js and 1 other location - About 40 mins to fix
        app/javascript/mastodon/features/compose/components/poll_form.js on lines 56..60

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

        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

            const button = children ? React.cloneElement(React.Children.only(children), {
              ref: this.setTargetRef,
              onClick: this.handleClick,
              onMouseDown: this.handleMouseDown,
              onKeyDown: this.handleButtonKeyDown,
        Severity: Minor
        Found in app/javascript/mastodon/components/dropdown_menu.js and 1 other location - About 35 mins to fix
        app/javascript/mastodon/features/direct_timeline/components/conversation.js on lines 138..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 47.

        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