mashirozx/mastodon

View on GitHub

Showing 1,785 of 1,785 total issues

File index.js has 853 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// @ts-check

const os = require('os');
const throng = require('throng');
const dotenv = require('dotenv');
Severity: Major
Found in streaming/index.js - About 2 days to fix

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

            {(this.context.identity.permissions & PERMISSION_MANAGE_USERS === PERMISSION_MANAGE_USERS) && (
              <div role='group' aria-labelledby='notifications-admin-sign-up'>
                <span id='notifications-status' className='column-settings__section'><FormattedMessage id='notifications.column_settings.admin.sign_up' defaultMessage='New sign-ups:' /></span>
    
                <div className='column-settings__row'>
    app/javascript/mastodon/features/notifications/components/column_settings.js on lines 186..197

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

    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

            {(this.context.identity.permissions & PERMISSION_MANAGE_REPORTS === PERMISSION_MANAGE_REPORTS) && (
              <div role='group' aria-labelledby='notifications-admin-report'>
                <span id='notifications-status' className='column-settings__section'><FormattedMessage id='notifications.column_settings.admin.report' defaultMessage='New reports:' /></span>
    
                <div className='column-settings__row'>
    app/javascript/mastodon/features/notifications/components/column_settings.js on lines 173..184

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

    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

      render () {
        const { statusIds, hasMore, isLoading } = this.props;
    
        const sizes = [
          { columns: 1, gutter: 0 },
    app/javascript/mastodon/features/standalone/public_timeline/index.js on lines 70..97

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

    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

      render () {
        const { statusIds, hasMore, isLoading } = this.props;
    
        const sizes = [
          { columns: 1, gutter: 0 },
    app/javascript/mastodon/features/standalone/hashtag_timeline/index.js on lines 61..88

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

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

      render () {
        let media = null;
        let statusAvatar, prepend, rebloggedByText, unlistedQuoteText;
    
        const { intl, hidden, featured, unread, showThread, scrollKey, pictureInPicture, contextType } = this.props;
    Severity: Major
    Found in app/javascript/mastodon/components/status.js - About 1 day to fix

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

        renderFollow (notification, account, link) {
          const { intl, unread } = this.props;
      
          return (
            <HotKeys handlers={this.getHandlers()}>
      app/javascript/mastodon/features/notifications/components/notification.js on lines 350..370

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

      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

        renderAdminSignUp (notification, account, link) {
          const { intl, unread } = this.props;
      
          return (
            <HotKeys handlers={this.getHandlers()}>
      app/javascript/mastodon/features/notifications/components/notification.js on lines 122..142

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

      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

      File accounts.js has 655 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';
      export const ACCOUNT_FETCH_SUCCESS = 'ACCOUNT_FETCH_SUCCESS';
      Severity: Major
      Found in app/javascript/mastodon/actions/accounts.js - About 1 day to fix

        File compose.js has 646 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import api from '../api';
        import { CancelToken, isCancel } from 'axios';
        import { throttle } from 'lodash';
        import { search as emojiSearch } from '../features/emoji/emoji_mart_search_light';
        import { tagHistory } from '../settings';
        Severity: Major
        Found in app/javascript/mastodon/actions/compose.js - About 1 day to fix

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

              def remove_orphans
                progress        = create_progress_bar(nil)
                reclaimed_bytes = 0
                removed         = 0
                dry_run         = options[:dry_run] ? ' (DRY RUN)' : ''
          Severity: Minor
          Found in lib/mastodon/media_cli.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

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

          const mapStateToProps = (state, { params: { acct, id } }) => {
            const accountId = id || state.getIn(['accounts_map', acct]);
          
            if (!accountId) {
              return {
          Severity: Major
          Found in app/javascript/mastodon/features/following/index.js and 1 other location - About 1 day to fix
          app/javascript/mastodon/features/followers/index.js on lines 25..46

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

          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 mapStateToProps = (state, { params: { acct, id } }) => {
            const accountId = id || state.getIn(['accounts_map', acct]);
          
            if (!accountId) {
              return {
          Severity: Major
          Found in app/javascript/mastodon/features/followers/index.js and 1 other location - About 1 day to fix
          app/javascript/mastodon/features/following/index.js on lines 25..46

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

          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

            renderSuggestion = (suggestion, i) => {
              const { selectedSuggestion } = this.state;
              let inner, key;
          
              if (suggestion.type === 'emoji') {
          Severity: Major
          Found in app/javascript/mastodon/components/autosuggest_textarea.js and 1 other location - About 1 day to fix
          app/javascript/mastodon/components/autosuggest_input.js on lines 165..185

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

          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

            renderSuggestion = (suggestion, i) => {
              const { selectedSuggestion } = this.state;
              let inner, key;
          
              if (suggestion.type === 'emoji') {
          Severity: Major
          Found in app/javascript/mastodon/components/autosuggest_input.js and 1 other location - About 1 day to fix
          app/javascript/mastodon/components/autosuggest_textarea.js on lines 172..192

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

          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

          File status.js has 617 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import React from 'react';
          import ImmutablePropTypes from 'react-immutable-proptypes';
          import PropTypes from 'prop-types';
          import Avatar from './avatar';
          import AvatarOverlay from './avatar_overlay';
          Severity: Major
          Found in app/javascript/mastodon/components/status.js - 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 compose has 262 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

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

                render () {
                  const { account, hidden, intl, domain } = this.props;
              
                  if (!account) {
                    return null;
              Severity: Minor
              Found in app/javascript/mastodon/features/account/components/header.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

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

                        <div className={`privacy-dropdown__dropdown ${placement}`} style={{ ...style, opacity: opacity, transform: mounted ? `scale(${scaleX}, ${scaleY})` : null, zIndex: 2 }} role='listbox' ref={this.setRef}>
                          {items.map(item => (
                            <div role='option' tabIndex='0' key={item.value} data-index={item.value} onKeyDown={this.handleKeyDown} onClick={this.handleClick} className={classNames('privacy-dropdown__option', { active: item.value === value })} aria-selected={item.value === value} ref={item.value === value ? this.setFocusRef : null}>
                              <div className='privacy-dropdown__option__icon'>
                                <Icon id={item.icon} fixedWidth />
              app/javascript/mastodon/features/compose/components/privacy_dropdown.js on lines 130..143

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

              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