src/components/layout/headers/SnippetHeader.js

Summary

Maintainability
D
2 days
Test Coverage

File SnippetHeader.js has 516 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { drop, get, isEmpty, map, size, toString, isArray } from 'lodash/fp';
import styled from 'styled-components';
Severity: Major
Found in src/components/layout/headers/SnippetHeader.js - About 1 day to fix

    Function render has 146 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      render() {
        const snippetUrl = getSnippetUrl('/gist');
        const { snippets, match, editSnippet, comments } = this.props;
        const snippet = get(match.params.id, snippets);
        const snippetId = get('id', snippet);
    Severity: Major
    Found in src/components/layout/headers/SnippetHeader.js - About 5 hrs to fix

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

        {
          searchByLanguages: snippetActions.filterSnippetsByLanguage,
          searchByTags: snippetActions.filterSnippetsByTags,
          setStar: snippetActions.starSnippet,
          unsetStar: snippetActions.unStarSnippet,
      Severity: Major
      Found in src/components/layout/headers/SnippetHeader.js and 1 other location - About 3 hrs to fix
      src/components/common/UtilityIcon.js on lines 139..152

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

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

      const Languages = styled.span`
        color: ${(props) => props.theme.baseAppColor};
        border: 1px solid ${(props) => props.theme.baseAppColor};
        font-size: 11px;
        padding: 1px 3px;
      Severity: Major
      Found in src/components/layout/headers/SnippetHeader.js and 10 other locations - About 35 mins to fix
      src/components/common/controls/Checkbox.js on lines 5..38
      src/components/common/editor/Csv.js on lines 11..24
      src/components/layout/content/About.js on lines 27..32
      src/components/layout/content/DashBoard.js on lines 52..57
      src/components/layout/content/settings/Base.js on lines 34..38
      src/components/layout/content/settings/Editor.js on lines 46..50
      src/components/layout/content/settings/Snippets.js on lines 47..51
      src/components/layout/headers/MainHeader.js on lines 29..40
      src/components/layout/headers/MainHeader.js on lines 69..83
      src/components/layout/sidebar/Sidebar.js on lines 39..45

      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

      There are no issues that match your filters.

      Category
      Status