src/middlewares/gitHubAPI.js

Summary

Maintainability
F
3 days
Test Coverage

File gitHubAPI.js has 296 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint consistent-return: 0 */

import * as superagent from 'superagent';
import * as AT from 'constants/actionTypes';
import { responseHandler } from 'middlewares/responseHandler';
Severity: Minor
Found in src/middlewares/gitHubAPI.js - About 3 hrs to fix

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

        if (action.type === AT.GET_EMOJI) {
          dispatch({ type: AT.GET_EMOJI.PENDING, action });
          API.get(`${getApiUrl('/api/v3')}/emojis`)
            .set(_headers())
            .end((error, result) => {
    Severity: Major
    Found in src/middlewares/gitHubAPI.js and 2 other locations - About 5 hrs to fix
    src/middlewares/gitHubAPI.js on lines 31..42
    src/middlewares/gitHubAPI.js on lines 110..121

    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

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

        if (action.type === AT.GET_USER) {
          dispatch({ type: AT.GET_USER.PENDING, action });
          API.get(`${getApiUrl('/api/v3')}/user`)
            .set(_headers())
            .end((error, result) => {
    Severity: Major
    Found in src/middlewares/gitHubAPI.js and 2 other locations - About 5 hrs to fix
    src/middlewares/gitHubAPI.js on lines 31..42
    src/middlewares/gitHubAPI.js on lines 123..134

    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

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

        if (action.type === AT.GET_RATE_LIMIT) {
          dispatch({ type: AT.GET_RATE_LIMIT.PENDING, action });
          API.get(`${getApiUrl('/api/v3')}/rate_limit`)
            .set(_headers())
            .end((error, result) => {
    Severity: Major
    Found in src/middlewares/gitHubAPI.js and 2 other locations - About 5 hrs to fix
    src/middlewares/gitHubAPI.js on lines 110..121
    src/middlewares/gitHubAPI.js on lines 123..134

    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

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

          return API.put(`${getApiUrl('/api/v3')}/gists/${action.payload.id}/star`)
            .set(_headers({ 'Content-Length': 0 }))
            .end((error, result) => {
              errorHandler(error, result);
    
    
    Severity: Major
    Found in src/middlewares/gitHubAPI.js and 1 other location - About 3 hrs to fix
    src/middlewares/gitHubAPI.js on lines 224..242

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

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

          return API.get(`${getApiUrl('/api/v3')}/gists/${action.payload.id}`)
            .set(_headers())
            .end((error, result) => {
              errorHandler(error, result);
              const lastModified = result.headers['last-modified'] || '';
    Severity: Major
    Found in src/middlewares/gitHubAPI.js and 5 other locations - About 30 mins to fix
    src/middlewares/gitHubAPI.js on lines 224..242
    src/middlewares/gitHubAPI.js on lines 267..280
    src/middlewares/gitHubAPI.js on lines 286..288
    src/middlewares/gitHubAPI.js on lines 302..314
    src/middlewares/gitHubAPI.js on lines 319..321

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

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

          return API.delete(`${getApiUrl('/api/v3')}/gists/${action.payload.id}/star`)
            .set(_headers())
            .end((error, result) => {
              errorHandler(error, result);
    
    
    Severity: Major
    Found in src/middlewares/gitHubAPI.js and 5 other locations - About 30 mins to fix
    src/middlewares/gitHubAPI.js on lines 182..194
    src/middlewares/gitHubAPI.js on lines 267..280
    src/middlewares/gitHubAPI.js on lines 286..288
    src/middlewares/gitHubAPI.js on lines 302..314
    src/middlewares/gitHubAPI.js on lines 319..321

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

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

          API.patch(`${getApiUrl('/api/v3')}/gists/${action.payload.id}`)
            .set(_headers())
            .send(action.payload.snippet)
    Severity: Major
    Found in src/middlewares/gitHubAPI.js and 5 other locations - About 30 mins to fix
    src/middlewares/gitHubAPI.js on lines 182..194
    src/middlewares/gitHubAPI.js on lines 224..242
    src/middlewares/gitHubAPI.js on lines 267..280
    src/middlewares/gitHubAPI.js on lines 302..314
    src/middlewares/gitHubAPI.js on lines 319..321

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

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

          API.get(`${getApiUrl('/api/v3')}/gists/${action.payload.id}/comments`)
            .set(_headers())
            .end((error, result) => {
              errorHandler(error, result);
    
    
    Severity: Major
    Found in src/middlewares/gitHubAPI.js and 5 other locations - About 30 mins to fix
    src/middlewares/gitHubAPI.js on lines 182..194
    src/middlewares/gitHubAPI.js on lines 224..242
    src/middlewares/gitHubAPI.js on lines 267..280
    src/middlewares/gitHubAPI.js on lines 286..288
    src/middlewares/gitHubAPI.js on lines 319..321

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

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

          API.delete(`${getApiUrl('/api/v3')}/gists/${action.payload.id}`)
            .set(_headers())
            .end((error, result) => {
              errorHandler(error, result);
    
    
    Severity: Major
    Found in src/middlewares/gitHubAPI.js and 5 other locations - About 30 mins to fix
    src/middlewares/gitHubAPI.js on lines 182..194
    src/middlewares/gitHubAPI.js on lines 224..242
    src/middlewares/gitHubAPI.js on lines 286..288
    src/middlewares/gitHubAPI.js on lines 302..314
    src/middlewares/gitHubAPI.js on lines 319..321

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

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

          API.post(`${getApiUrl('/api/v3')}/gists/${action.payload.id}/comments`)
            .set(_headers())
            .send({ body: action.payload.body })
    Severity: Major
    Found in src/middlewares/gitHubAPI.js and 5 other locations - About 30 mins to fix
    src/middlewares/gitHubAPI.js on lines 182..194
    src/middlewares/gitHubAPI.js on lines 224..242
    src/middlewares/gitHubAPI.js on lines 267..280
    src/middlewares/gitHubAPI.js on lines 286..288
    src/middlewares/gitHubAPI.js on lines 302..314

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

    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