maa123/mastodon

View on GitHub

Showing 1,813 of 1,813 total issues

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

import { defineMessages } from 'react-intl';

import axios from 'axios';
import { throttle } from 'lodash';

Severity: Major
Found in app/javascript/mastodon/actions/compose.js - About 1 day to fix

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

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

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

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

      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', normalizeForLookup(acct)]);
      
        if (!accountId) {
          return {
      Severity: Major
      Found in app/javascript/mastodon/features/following/index.jsx and 1 other location - About 1 day to fix
      app/javascript/mastodon/features/followers/index.jsx on lines 30..51

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

      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.jsx and 1 other location - About 1 day to fix
      app/javascript/mastodon/components/autosuggest_textarea.jsx on lines 177..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 258.

      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.jsx and 1 other location - About 1 day to fix
      app/javascript/mastodon/components/autosuggest_input.jsx on lines 170..190

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

      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

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

          def remove_orphans
            progress        = create_progress_bar(nil)
            reclaimed_bytes = 0
            removed         = 0
            prefix          = options[:prefix]
      Severity: Minor
      Found in lib/mastodon/cli/media.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

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

      import PropTypes from 'prop-types';
      
      import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
      
      import classNames from 'classnames';
      Severity: Major
      Found in app/javascript/mastodon/features/status/index.jsx - 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 render has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
        Open

          render () {
            const { status, relationship, intl, withDismiss, withCounters, scrollKey } = this.props;
            const { signedIn, permissions } = this.context.identity;
        
            const publicStatus       = ['public', 'unlisted'].includes(status.get('visibility'));
        Severity: Minor
        Found in app/javascript/mastodon/components/status_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

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

        export function expandFollowing(id) {
          return (dispatch, getState) => {
            const url = getState().getIn(['user_lists', 'following', id, 'next']);
        
            if (url === null) {
        Severity: Major
        Found in app/javascript/mastodon/actions/accounts.js and 1 other location - About 1 day to fix
        app/javascript/mastodon/actions/accounts.js on lines 405..425

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

        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 expandFollowers(id) {
          return (dispatch, getState) => {
            const url = getState().getIn(['user_lists', 'followers', id, 'next']);
        
            if (url === null) {
        Severity: Major
        Found in app/javascript/mastodon/actions/accounts.js and 1 other location - About 1 day to fix
        app/javascript/mastodon/actions/accounts.js on lines 492..512

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

        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 expandReblogs(id) {
          return (dispatch, getState) => {
            const url = getState().getIn(['user_lists', 'reblogged_by', id, 'next']);
            if (url === null) {
              return;
        Severity: Major
        Found in app/javascript/mastodon/actions/interactions.js and 1 other location - About 1 day to fix
        app/javascript/mastodon/actions/interactions.js on lines 401..418

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

        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 expandFavourites(id) {
          return (dispatch, getState) => {
            const url = getState().getIn(['user_lists', 'favourited_by', id, 'next']);
            if (url === null) {
              return;
        Severity: Major
        Found in app/javascript/mastodon/actions/interactions.js and 1 other location - About 1 day to fix
        app/javascript/mastodon/actions/interactions.js on lines 319..336

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

        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 compose has 238 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

          Class Account has 64 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class Account < ApplicationRecord
            self.ignored_columns += %w(
              subscription_expires_at
              secret
              remote_url
          Severity: Major
          Found in app/models/account.rb - About 1 day to fix

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

            export function expandMutes() {
              return (dispatch, getState) => {
                const url = getState().getIn(['user_lists', 'mutes', 'next']);
            
                if (url === null) {
            Severity: Major
            Found in app/javascript/mastodon/actions/mutes.js and 1 other location - About 1 day to fix
            app/javascript/mastodon/actions/blocks.js on lines 51..68

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

            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 expandBlocks() {
              return (dispatch, getState) => {
                const url = getState().getIn(['user_lists', 'blocks', 'next']);
            
                if (url === null) {
            Severity: Major
            Found in app/javascript/mastodon/actions/blocks.js and 1 other location - About 1 day to fix
            app/javascript/mastodon/actions/mutes.js on lines 53..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 221.

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

            require 'set'
            require_relative 'base'
            
            module Mastodon::CLI
              class Accounts < Base
            Severity: Major
            Found in lib/mastodon/cli/accounts.rb - About 1 day to fix

              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

              Severity
              Category
              Status
              Source
              Language