glitch-soc/mastodon

View on GitHub
app/javascript/flavours/glitch/actions/compose.js

Summary

Maintainability
F
1 wk
Test Coverage

File compose.js has 706 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/flavours/glitch/actions/compose.js - About 1 day to fix

    Function submitCompose has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function submitCompose(routerHistory, overridePrivacy = null) {
      return function (dispatch, getState) {
        let status     = getState().getIn(['compose', 'text'], '');
        const media    = getState().getIn(['compose', 'media_attachments']);
        const statusId = getState().getIn(['compose', 'id'], null);
    Severity: Major
    Found in app/javascript/flavours/glitch/actions/compose.js - About 3 hrs to fix

      Function uploadCompose has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function uploadCompose(files) {
        return function (dispatch, getState) {
          const uploadLimit = 4;
          const media = getState().getIn(['compose', 'media_attachments']);
          const pending = getState().getIn(['compose', 'pending_media_attachments']);
      Severity: Minor
      Found in app/javascript/flavours/glitch/actions/compose.js - About 1 hr to fix

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

        export function selectComposeSuggestion(position, token, suggestion, path) {
          return (dispatch, getState) => {
            let completion, startPosition;
        
            if (suggestion.type === 'emoji') {
        Severity: Minor
        Found in app/javascript/flavours/glitch/actions/compose.js - About 1 hr to fix

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

                  return api(getState).post('/api/v2/media', data, {
                    onUploadProgress: function({ loaded }){
                      progress[i] = loaded;
                      dispatch(uploadComposeProgress(progress.reduce((a, v) => a + v, 0), total));
                    },
          Severity: Major
          Found in app/javascript/flavours/glitch/actions/compose.js and 1 other location - About 1 day to fix
          app/javascript/mastodon/actions/compose.js on lines 309..339

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

          export function selectComposeSuggestion(position, token, suggestion, path) {
            return (dispatch, getState) => {
              let completion, startPosition;
          
              if (suggestion.type === 'emoji') {
          Severity: Major
          Found in app/javascript/flavours/glitch/actions/compose.js and 1 other location - About 1 day to fix
          app/javascript/mastodon/actions/compose.js on lines 620..657

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

          export function changeUploadCompose(id, params) {
            return (dispatch, getState) => {
              dispatch(changeUploadComposeRequest());
          
              let media = getState().getIn(['compose', 'media_attachments']).find((item) => item.get('id') === id);
          Severity: Major
          Found in app/javascript/flavours/glitch/actions/compose.js and 1 other location - About 1 day to fix
          app/javascript/mastodon/actions/compose.js on lines 420..446

          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

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

          const fetchComposeSuggestionsAccounts = throttle((dispatch, getState, token) => {
            if (fetchComposeSuggestionsAccountsController) {
              fetchComposeSuggestionsAccountsController.abort();
            }
          
          
          Severity: Major
          Found in app/javascript/flavours/glitch/actions/compose.js and 1 other location - About 1 day to fix
          app/javascript/mastodon/actions/compose.js on lines 520..545

          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

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

          export const uploadThumbnail = (id, file) => (dispatch, getState) => {
            dispatch(uploadThumbnailRequest());
          
            const total = file.size;
            const data = new FormData();
          Severity: Major
          Found in app/javascript/flavours/glitch/actions/compose.js and 1 other location - About 7 hrs to fix
          app/javascript/mastodon/actions/compose.js on lines 348..365

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

              if (statusId !== null) {
                media_attributes = media.map(item => {
                  let focus;
          
                  if (item.getIn(['meta', 'focus'])) {
          Severity: Major
          Found in app/javascript/flavours/glitch/actions/compose.js and 1 other location - About 5 hrs to fix
          app/javascript/mastodon/actions/compose.js on lines 183..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 150.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                const insertIfOnline = timelineId => {
                  const timeline = getState().getIn(['timelines', timelineId]);
          
                  if (timeline && timeline.get('items').size > 0 && timeline.getIn(['items', 0]) !== null && timeline.get('online')) {
                    dispatch(updateTimeline(timelineId, { ...response.data }));
          Severity: Major
          Found in app/javascript/flavours/glitch/actions/compose.js and 1 other location - About 4 hrs to fix
          app/javascript/mastodon/actions/compose.js on lines 226..232

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                  dispatch(showAlert({
                    message: statusId === null ? messages.published : messages.saved,
                    action: messages.open,
                    dismissAfter: 10000,
                    onClick: () => routerHistory.push(`/@${response.data.account.username}/${response.data.id}`),
          Severity: Major
          Found in app/javascript/flavours/glitch/actions/compose.js and 1 other location - About 3 hrs to fix
          app/javascript/mastodon/actions/compose.js on lines 250..255

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

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

          const messages = defineMessages({
            uploadErrorLimit: { id: 'upload_error.limit', defaultMessage: 'File upload limit exceeded.' },
            uploadErrorPoll:  { id: 'upload_error.poll', defaultMessage: 'File upload not allowed with polls.' },
            open: { id: 'compose.published.open', defaultMessage: 'Open' },
            published: { id: 'compose.published.body', defaultMessage: 'Post published.' },
          Severity: Major
          Found in app/javascript/flavours/glitch/actions/compose.js and 13 other locations - About 2 hrs to fix
          app/javascript/flavours/glitch/components/column_header.jsx on lines 21..27
          app/javascript/flavours/glitch/features/compose/components/compose_form.jsx on lines 40..46
          app/javascript/flavours/glitch/features/compose/components/federation_button.jsx on lines 14..20
          app/javascript/flavours/glitch/features/directory/index.jsx on lines 24..30
          app/javascript/flavours/glitch/features/list_timeline/index.jsx on lines 31..37
          app/javascript/flavours/glitch/features/ui/components/mute_modal.jsx on lines 23..29
          app/javascript/mastodon/actions/compose.js on lines 83..89
          app/javascript/mastodon/components/column_header.jsx on lines 21..27
          app/javascript/mastodon/components/status.jsx on lines 72..78
          app/javascript/mastodon/features/compose/components/compose_form.jsx on lines 36..42
          app/javascript/mastodon/features/directory/index.jsx on lines 24..30
          app/javascript/mastodon/features/list_timeline/index.jsx on lines 31..37
          app/javascript/mastodon/features/ui/components/mute_modal.jsx on lines 23..29

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

          export function hydrateCompose() {
            return (dispatch, getState) => {
              const me = getState().getIn(['meta', 'me']);
              const history = tagHistory.get(me);
          
          
          Severity: Major
          Found in app/javascript/flavours/glitch/actions/compose.js and 1 other location - About 2 hrs to fix
          app/javascript/mastodon/actions/compose.js on lines 673..682

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 79.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

          export function fetchComposeSuggestions(token) {
            return (dispatch, getState) => {
              switch (token[0]) {
              case ':':
                fetchComposeSuggestionsEmojis(dispatch, getState, token);
          Severity: Major
          Found in app/javascript/flavours/glitch/actions/compose.js and 1 other location - About 1 hr to fix
          app/javascript/mastodon/actions/compose.js on lines 582..596

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

          export function initMediaEditModal(id) {
            return dispatch => {
              dispatch({
                type: INIT_MEDIA_EDIT_MODAL,
                id,
          Severity: Major
          Found in app/javascript/flavours/glitch/actions/compose.js and 1 other location - About 1 hr to fix
          app/javascript/mastodon/actions/compose.js on lines 391..403

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

              const intersectedOldHistory = oldHistory.filter(name => names.findIndex(newName => newName.toLowerCase() === name.toLowerCase()) === -1);
          Severity: Major
          Found in app/javascript/flavours/glitch/actions/compose.js and 1 other location - About 1 hr to fix
          app/javascript/mastodon/actions/compose.js on lines 703..703

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

          const fetchComposeSuggestionsEmojis = (dispatch, getState, token) => {
            const results = emojiSearch(token.replace(':', ''), { maxResults: 5 });
            dispatch(readyComposeSuggestionsEmojis(token, results));
          };
          Severity: Minor
          Found in app/javascript/flavours/glitch/actions/compose.js and 1 other location - About 55 mins to fix
          app/javascript/mastodon/actions/compose.js on lines 547..550

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

          export const ensureComposeIsVisible = (getState, routerHistory) => {
            if (!getState().getIn(['compose', 'mounted'])) {
              routerHistory.push('/publish');
            }
          };
          Severity: Minor
          Found in app/javascript/flavours/glitch/actions/compose.js and 1 other location - About 50 mins to fix
          app/javascript/mastodon/actions/compose.js on lines 91..95

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 51.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

          export function directCompose(account, routerHistory) {
            return (dispatch, getState) => {
              dispatch({
                type: COMPOSE_DIRECT,
                account: account,
          Severity: Major
          Found in app/javascript/flavours/glitch/actions/compose.js and 4 other locations - About 40 mins to fix
          app/javascript/flavours/glitch/actions/compose.js on lines 154..163
          app/javascript/mastodon/actions/compose.js on lines 113..122
          app/javascript/mastodon/actions/compose.js on lines 145..154
          app/javascript/mastodon/actions/compose.js on lines 156..165

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

          export function mentionCompose(account, routerHistory) {
            return (dispatch, getState) => {
              dispatch({
                type: COMPOSE_MENTION,
                account: account,
          Severity: Major
          Found in app/javascript/flavours/glitch/actions/compose.js and 4 other locations - About 40 mins to fix
          app/javascript/flavours/glitch/actions/compose.js on lines 165..174
          app/javascript/mastodon/actions/compose.js on lines 113..122
          app/javascript/mastodon/actions/compose.js on lines 145..154
          app/javascript/mastodon/actions/compose.js on lines 156..165

          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

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

              if (files.length + media.size + pending > uploadLimit) {
                dispatch(showAlert({ message: messages.uploadErrorLimit }));
                return;
              }
          Severity: Minor
          Found in app/javascript/flavours/glitch/actions/compose.js and 1 other location - About 40 mins to fix
          app/javascript/mastodon/actions/compose.js on lines 291..294

          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

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

          export const focusCompose = (routerHistory, defaultText) => (dispatch, getState) => {
            dispatch({
              type: COMPOSE_FOCUS,
              defaultText,
            });
          Severity: Minor
          Found in app/javascript/flavours/glitch/actions/compose.js and 1 other location - About 40 mins to fix
          app/javascript/mastodon/actions/compose.js on lines 136..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 48.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                if (routerHistory
                    && (routerHistory.location.pathname === '/publish' || routerHistory.location.pathname === '/statuses/new')
                    && window.history.state
          Severity: Minor
          Found in app/javascript/flavours/glitch/actions/compose.js and 1 other location - About 30 mins to fix
          app/javascript/mastodon/actions/compose.js on lines 217..217

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

          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