maa123/mastodon

View on GitHub

Showing 1,813 of 1,813 total issues

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

const messages = defineMessages({
  edit_profile: { id: 'account.edit_profile', defaultMessage: 'Edit profile' },
  pins: { id: 'navigation_bar.pins', defaultMessage: 'Pinned posts' },
  preferences: { id: 'navigation_bar.preferences', defaultMessage: 'Preferences' },
  follow_requests: { id: 'navigation_bar.follow_requests', defaultMessage: 'Follow requests' },
app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.jsx on lines 18..32

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

export function expandBookmarkedStatuses() {
  return (dispatch, getState) => {
    const url = getState().getIn(['status_lists', 'bookmarks', 'next'], null);

    if (url === null || getState().getIn(['status_lists', 'bookmarks', 'isLoading'])) {
Severity: Major
Found in app/javascript/mastodon/actions/bookmarks.js and 1 other location - About 1 day to fix
app/javascript/mastodon/actions/favourites.js on lines 55..73

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

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 function expandFavouritedStatuses() {
  return (dispatch, getState) => {
    const url = getState().getIn(['status_lists', 'favourites', 'next'], null);

    if (url === null || getState().getIn(['status_lists', 'favourites', 'isLoading'])) {
Severity: Major
Found in app/javascript/mastodon/actions/favourites.js and 1 other location - About 1 day to fix
app/javascript/mastodon/actions/bookmarks.js on lines 52..70

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

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 a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
Open

  render () {
    const { status, relationship, intl } = this.props;
    const { signedIn, permissions } = this.context.identity;

    const publicStatus       = ['public', 'unlisted'].includes(status.get('visibility'));
Severity: Minor
Found in app/javascript/mastodon/features/status/components/action_bar.jsx - 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

File maintenance.rb has 538 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative 'base'

module Mastodon::CLI
  class Maintenance < Base
    MIN_SUPPORTED_VERSION = 2019_10_01_213028
Severity: Major
Found in lib/mastodon/cli/maintenance.rb - About 1 day to fix

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

        if (results.get('accounts') && results.get('accounts').size > 0) {
          accounts = (
            <SearchSection title={<><Icon id='users' fixedWidth /><FormattedMessage id='search_results.accounts' defaultMessage='Profiles' /></>}>
              {withoutLastResult(results.get('accounts')).map(accountId => <AccountContainer key={accountId} id={accountId} />)}
              {(results.get('accounts').size > INITIAL_PAGE_LIMIT && results.get('accounts').size % INITIAL_PAGE_LIMIT === 1) && <LoadMore visible onClick={this.handleLoadMoreAccounts} />}
    app/javascript/mastodon/features/compose/components/search_results.jsx on lines 63..70

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

    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 (results.get('statuses') && results.get('statuses').size > 0) {
          statuses = (
            <SearchSection title={<><Icon id='quote-right' fixedWidth /><FormattedMessage id='search_results.statuses' defaultMessage='Posts' /></>}>
              {withoutLastResult(results.get('statuses')).map(statusId => <StatusContainer key={statusId} id={statusId} />)}
              {(results.get('statuses').size > INITIAL_PAGE_LIMIT && results.get('statuses').size % INITIAL_PAGE_LIMIT === 1) && <LoadMore visible onClick={this.handleLoadMoreStatuses} />}
    app/javascript/mastodon/features/compose/components/search_results.jsx on lines 45..52

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

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

      render () {
        const { account, hidden, intl, domain } = this.props;
        const { signedIn, permissions } = this.context.identity;
    
        if (!account) {
    Severity: Major
    Found in app/javascript/mastodon/features/account/components/header.jsx - About 1 day to fix

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

        render () {
          const { intl, hidden, featured, unread, showThread, scrollKey, pictureInPicture, previousId, nextInReplyToId, rootId } = this.props;
      
          let { status, account, ...other } = this.props;
      
      
      Severity: Major
      Found in app/javascript/mastodon/components/status.jsx - About 1 day to fix

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

        export function fetchFollowing(id) {
          return (dispatch, getState) => {
            dispatch(fetchFollowingRequest(id));
        
            api(getState).get(`/api/v1/accounts/${id}/following`).then(response => {
        Severity: Major
        Found in app/javascript/mastodon/actions/accounts.js and 3 other locations - About 1 day to fix
        app/javascript/mastodon/actions/accounts.js on lines 364..378
        app/javascript/mastodon/actions/interactions.js on lines 280..293
        app/javascript/mastodon/actions/interactions.js on lines 362..375

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

        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

        export function fetchFavourites(id) {
          return (dispatch, getState) => {
            dispatch(fetchFavouritesRequest(id));
        
            api(getState).get(`/api/v1/statuses/${id}/favourited_by`).then(response => {
        Severity: Major
        Found in app/javascript/mastodon/actions/interactions.js and 3 other locations - About 1 day to fix
        app/javascript/mastodon/actions/accounts.js on lines 364..378
        app/javascript/mastodon/actions/accounts.js on lines 451..465
        app/javascript/mastodon/actions/interactions.js on lines 280..293

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

        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

        export function fetchReblogs(id) {
          return (dispatch, getState) => {
            dispatch(fetchReblogsRequest(id));
        
            api(getState).get(`/api/v1/statuses/${id}/reblogged_by`).then(response => {
        Severity: Major
        Found in app/javascript/mastodon/actions/interactions.js and 3 other locations - About 1 day to fix
        app/javascript/mastodon/actions/accounts.js on lines 364..378
        app/javascript/mastodon/actions/accounts.js on lines 451..465
        app/javascript/mastodon/actions/interactions.js on lines 362..375

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

        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

        export function fetchFollowers(id) {
          return (dispatch, getState) => {
            dispatch(fetchFollowersRequest(id));
        
            api(getState).get(`/api/v1/accounts/${id}/followers`).then(response => {
        Severity: Major
        Found in app/javascript/mastodon/actions/accounts.js and 3 other locations - About 1 day to fix
        app/javascript/mastodon/actions/accounts.js on lines 451..465
        app/javascript/mastodon/actions/interactions.js on lines 280..293
        app/javascript/mastodon/actions/interactions.js on lines 362..375

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

        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 migration_helpers.rb has 516 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        module Mastodon
          module MigrationHelpers
            class CorruptionError < StandardError
              attr_reader :index_name
        
        
        Severity: Major
        Found in lib/mastodon/migration_helpers.rb - About 1 day to fix

          File index.jsx has 512 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';
          
          
          Severity: Major
          Found in app/javascript/mastodon/features/video/index.jsx - About 1 day to fix

            Class Status has 56 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class Status < ApplicationRecord
              include Discard::Model
              include Paginable
              include Cacheable
              include StatusThreadingConcern
            Severity: Major
            Found in app/models/status.rb - About 1 day to fix

              File status.jsx has 494 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import PropTypes from 'prop-types';
              
              import { injectIntl, defineMessages, FormattedMessage } from 'react-intl';
              
              import classNames from 'classnames';
              Severity: Minor
              Found in app/javascript/mastodon/components/status.jsx - About 7 hrs to fix

                Class User has 55 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class User < ApplicationRecord
                  self.ignored_columns += %w(
                    remember_created_at
                    remember_token
                    current_sign_in_ip
                Severity: Major
                Found in app/models/user.rb - About 7 hrs to fix

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

                  import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable';
                  
                  import {
                    COMPOSE_MOUNT,
                    COMPOSE_UNMOUNT,
                  Severity: Minor
                  Found in app/javascript/mastodon/reducers/compose.js - About 7 hrs to fix

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

                    import PropTypes from 'prop-types';
                    import { PureComponent } from 'react';
                    
                    import { defineMessages, injectIntl } from 'react-intl';
                    
                    
                    Severity: Minor
                    Found in app/javascript/mastodon/features/ui/index.jsx - About 7 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language