glitch-soc/mastodon

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

Summary

Maintainability
F
4 days
Test Coverage

File statuses.js has 288 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import api from '../api';

import { ensureComposeIsVisible, setComposeToStatus } from './compose';
import { importFetchedStatus, importFetchedStatuses, importFetchedAccount } from './importer';
import { deleteFromTimelines } from './timelines';
Severity: Minor
Found in app/javascript/flavours/glitch/actions/statuses.js - About 2 hrs to fix

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

    export function fetchContext(id) {
      return (dispatch, getState) => {
        dispatch(fetchContextRequest(id));
    
        api(getState).get(`/api/v1/statuses/${id}/context`).then(response => {
    Severity: Major
    Found in app/javascript/flavours/glitch/actions/statuses.js and 1 other location - About 1 day to fix
    app/javascript/mastodon/actions/statuses.js on lines 177..193

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

    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 fetchStatus(id, forceFetch = false) {
      return (dispatch, getState) => {
        const skipLoading = !forceFetch && getState().getIn(['statuses', id], null) !== null;
    
        dispatch(fetchContext(id));
    Severity: Major
    Found in app/javascript/flavours/glitch/actions/statuses.js and 1 other location - About 7 hrs to fix
    app/javascript/mastodon/actions/statuses.js on lines 50..69

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

    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 translateStatus = id => (dispatch, getState) => {
      dispatch(translateStatusRequest(id));
    
      api(getState).post(`/api/v1/statuses/${id}/translate`).then(response => {
        dispatch(translateStatusSuccess(id, response.data));
    Severity: Major
    Found in app/javascript/flavours/glitch/actions/statuses.js and 1 other location - About 3 hrs to fix
    app/javascript/mastodon/actions/statuses.js on lines 319..327

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

    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 muteStatus(id) {
      return (dispatch, getState) => {
        dispatch(muteStatusRequest(id));
    
        api(getState).post(`/api/v1/statuses/${id}/mute`).then(() => {
    Severity: Major
    Found in app/javascript/flavours/glitch/actions/statuses.js and 3 other locations - About 3 hrs to fix
    app/javascript/flavours/glitch/actions/statuses.js on lines 256..266
    app/javascript/mastodon/actions/statuses.js on lines 221..231
    app/javascript/mastodon/actions/statuses.js on lines 255..265

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

    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 unmuteStatus(id) {
      return (dispatch, getState) => {
        dispatch(unmuteStatusRequest(id));
    
        api(getState).post(`/api/v1/statuses/${id}/unmute`).then(() => {
    Severity: Major
    Found in app/javascript/flavours/glitch/actions/statuses.js and 3 other locations - About 3 hrs to fix
    app/javascript/flavours/glitch/actions/statuses.js on lines 222..232
    app/javascript/mastodon/actions/statuses.js on lines 221..231
    app/javascript/mastodon/actions/statuses.js on lines 255..265

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

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

      if (status.get('poll')) {
        status = status.set('poll', getState().getIn(['polls', status.get('poll')]));
      }
    Severity: Major
    Found in app/javascript/flavours/glitch/actions/statuses.js and 3 other locations - About 55 mins to fix
    app/javascript/flavours/glitch/actions/statuses.js on lines 132..134
    app/javascript/mastodon/actions/statuses.js on lines 99..101
    app/javascript/mastodon/actions/statuses.js on lines 131..133

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

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

        if (status.get('poll')) {
          status = status.set('poll', getState().getIn(['polls', status.get('poll')]));
        }
    Severity: Major
    Found in app/javascript/flavours/glitch/actions/statuses.js and 3 other locations - About 55 mins to fix
    app/javascript/flavours/glitch/actions/statuses.js on lines 100..102
    app/javascript/mastodon/actions/statuses.js on lines 99..101
    app/javascript/mastodon/actions/statuses.js on lines 131..133

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

    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 revealStatus(ids) {
      if (!Array.isArray(ids)) {
        ids = [ids];
      }
    
    
    Severity: Major
    Found in app/javascript/flavours/glitch/actions/statuses.js and 3 other locations - About 50 mins to fix
    app/javascript/flavours/glitch/actions/statuses.js on lines 290..299
    app/javascript/mastodon/actions/statuses.js on lines 289..298
    app/javascript/mastodon/actions/statuses.js on lines 300..309

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 52.

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

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

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

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

    Refactorings

    Further Reading

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

    export function hideStatus(ids) {
      if (!Array.isArray(ids)) {
        ids = [ids];
      }
    
    
    Severity: Major
    Found in app/javascript/flavours/glitch/actions/statuses.js and 3 other locations - About 50 mins to fix
    app/javascript/flavours/glitch/actions/statuses.js on lines 301..310
    app/javascript/mastodon/actions/statuses.js on lines 289..298
    app/javascript/mastodon/actions/statuses.js on lines 300..309

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 52.

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

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

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

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

    Refactorings

    Further Reading

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

    export function fetchContextSuccess(id, ancestors, descendants) {
      return {
        type: CONTEXT_FETCH_SUCCESS,
        id,
        ancestors,
    Severity: Minor
    Found in app/javascript/flavours/glitch/actions/statuses.js and 1 other location - About 50 mins to fix
    app/javascript/mastodon/actions/statuses.js on lines 202..210

    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

    There are no issues that match your filters.

    Category
    Status