glitch-soc/mastodon

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

Summary

Maintainability
F
1 wk
Test Coverage

File interactions.js has 439 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import api, { getLinks } from '../api';

import { fetchRelationships } from './accounts';
import { importFetchedAccounts, importFetchedStatus } from './importer';

Severity: Minor
Found in app/javascript/flavours/glitch/actions/interactions.js - About 6 hrs to fix

    Similar blocks of code found in 4 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/flavours/glitch/actions/interactions.js and 3 other locations - About 1 day to fix
    app/javascript/flavours/glitch/actions/interactions.js on lines 319..336
    app/javascript/mastodon/actions/interactions.js on lines 319..336
    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 4 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/flavours/glitch/actions/interactions.js and 3 other locations - About 1 day to fix
    app/javascript/flavours/glitch/actions/interactions.js on lines 401..418
    app/javascript/mastodon/actions/interactions.js on lines 319..336
    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 8 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/flavours/glitch/actions/interactions.js and 7 other locations - About 1 day to fix
    app/javascript/flavours/glitch/actions/accounts.js on lines 289..303
    app/javascript/flavours/glitch/actions/accounts.js on lines 376..390
    app/javascript/flavours/glitch/actions/interactions.js on lines 280..293
    app/javascript/mastodon/actions/accounts.js on lines 276..290
    app/javascript/mastodon/actions/accounts.js on lines 363..377
    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 8 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/flavours/glitch/actions/interactions.js and 7 other locations - About 1 day to fix
    app/javascript/flavours/glitch/actions/accounts.js on lines 289..303
    app/javascript/flavours/glitch/actions/accounts.js on lines 376..390
    app/javascript/flavours/glitch/actions/interactions.js on lines 362..375
    app/javascript/mastodon/actions/accounts.js on lines 276..290
    app/javascript/mastodon/actions/accounts.js on lines 363..377
    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

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

    export function reblog(status, visibility) {
      return function (dispatch, getState) {
        dispatch(reblogRequest(status));
    
        api(getState).post(`/api/v1/statuses/${status.get('id')}/reblog`, { visibility }).then(function (response) {
    Severity: Major
    Found in app/javascript/flavours/glitch/actions/interactions.js and 1 other location - About 5 hrs to fix
    app/javascript/mastodon/actions/interactions.js on lines 54..67

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

    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 bookmark(status) {
      return function (dispatch, getState) {
        dispatch(bookmarkRequest(status));
    
        api(getState).post(`/api/v1/statuses/${status.get('id')}/bookmark`).then(function (response) {
    Severity: Major
    Found in app/javascript/flavours/glitch/actions/interactions.js and 1 other location - About 5 hrs to fix
    app/javascript/mastodon/actions/interactions.js on lines 208..219

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

    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 unbookmark(status) {
      return (dispatch, getState) => {
        dispatch(unbookmarkRequest(status));
    
        api(getState).post(`/api/v1/statuses/${status.get('id')}/unbookmark`).then(response => {
    Severity: Major
    Found in app/javascript/flavours/glitch/actions/interactions.js and 1 other location - About 5 hrs to fix
    app/javascript/mastodon/actions/interactions.js on lines 221..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 136.

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

    export function unpin (status) {
      return (dispatch, getState) => {
        dispatch(unpinRequest(status));
    
        api(getState).post(`/api/v1/statuses/${status.get('id')}/unpin`).then(response => {
    Severity: Major
    Found in app/javascript/flavours/glitch/actions/interactions.js and 7 other locations - About 4 hrs to fix
    app/javascript/flavours/glitch/actions/interactions.js on lines 69..80
    app/javascript/flavours/glitch/actions/interactions.js on lines 145..156
    app/javascript/flavours/glitch/actions/interactions.js on lines 444..455
    app/javascript/mastodon/actions/interactions.js on lines 69..80
    app/javascript/mastodon/actions/interactions.js on lines 145..156
    app/javascript/mastodon/actions/interactions.js on lines 444..455
    app/javascript/mastodon/actions/interactions.js on lines 482..493

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

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

    export function unreblog(status) {
      return (dispatch, getState) => {
        dispatch(unreblogRequest(status));
    
        api(getState).post(`/api/v1/statuses/${status.get('id')}/unreblog`).then(response => {
    Severity: Major
    Found in app/javascript/flavours/glitch/actions/interactions.js and 7 other locations - About 4 hrs to fix
    app/javascript/flavours/glitch/actions/interactions.js on lines 145..156
    app/javascript/flavours/glitch/actions/interactions.js on lines 444..455
    app/javascript/flavours/glitch/actions/interactions.js on lines 482..493
    app/javascript/mastodon/actions/interactions.js on lines 69..80
    app/javascript/mastodon/actions/interactions.js on lines 145..156
    app/javascript/mastodon/actions/interactions.js on lines 444..455
    app/javascript/mastodon/actions/interactions.js on lines 482..493

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

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

    export function pin(status) {
      return (dispatch, getState) => {
        dispatch(pinRequest(status));
    
        api(getState).post(`/api/v1/statuses/${status.get('id')}/pin`).then(response => {
    Severity: Major
    Found in app/javascript/flavours/glitch/actions/interactions.js and 7 other locations - About 4 hrs to fix
    app/javascript/flavours/glitch/actions/interactions.js on lines 69..80
    app/javascript/flavours/glitch/actions/interactions.js on lines 145..156
    app/javascript/flavours/glitch/actions/interactions.js on lines 482..493
    app/javascript/mastodon/actions/interactions.js on lines 69..80
    app/javascript/mastodon/actions/interactions.js on lines 145..156
    app/javascript/mastodon/actions/interactions.js on lines 444..455
    app/javascript/mastodon/actions/interactions.js on lines 482..493

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

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

    export function unfavourite(status) {
      return (dispatch, getState) => {
        dispatch(unfavouriteRequest(status));
    
        api(getState).post(`/api/v1/statuses/${status.get('id')}/unfavourite`).then(response => {
    Severity: Major
    Found in app/javascript/flavours/glitch/actions/interactions.js and 7 other locations - About 4 hrs to fix
    app/javascript/flavours/glitch/actions/interactions.js on lines 69..80
    app/javascript/flavours/glitch/actions/interactions.js on lines 444..455
    app/javascript/flavours/glitch/actions/interactions.js on lines 482..493
    app/javascript/mastodon/actions/interactions.js on lines 69..80
    app/javascript/mastodon/actions/interactions.js on lines 145..156
    app/javascript/mastodon/actions/interactions.js on lines 444..455
    app/javascript/mastodon/actions/interactions.js on lines 482..493

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

    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 favourite(status) {
      return function (dispatch, getState) {
        dispatch(favouriteRequest(status));
    
        api(getState).post(`/api/v1/statuses/${status.get('id')}/favourite`).then(function (response) {
    Severity: Major
    Found in app/javascript/flavours/glitch/actions/interactions.js and 1 other location - About 4 hrs to fix
    app/javascript/mastodon/actions/interactions.js on lines 132..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 131.

    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