src/components/layout/sidebar/Sidebar.js

Summary

Maintainability
D
1 day
Test Coverage

Function Sidebar has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

export const Sidebar = ({
  snippets,
  filterText,
  filterTags,
  filterLanguage,
Severity: Minor
Found in src/components/layout/sidebar/Sidebar.js - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function searchType has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const searchType = () => {
    if (!isEmpty(trim(filterText))) {
      return isTag(filterText) ? 'free text tag' : 'free text';
    }

Severity: Minor
Found in src/components/layout/sidebar/Sidebar.js - About 1 hr to fix

    Avoid too many return statements within this function.
    Open

        return '';
    Severity: Major
    Found in src/components/layout/sidebar/Sidebar.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return 'untagged';
      Severity: Major
      Found in src/components/layout/sidebar/Sidebar.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return 'large files';
        Severity: Major
        Found in src/components/layout/sidebar/Sidebar.js - About 30 mins to fix

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

          const mapStateToProps = (state) => ({
            snippets: state.snippets.snippets,
            filterText: state.snippets.filter.text,
            filterTags: state.snippets.filter.tags,
            filterLanguage: state.snippets.filter.language,
          Severity: Major
          Found in src/components/layout/sidebar/Sidebar.js and 1 other location - About 4 hrs to fix
          src/components/Search.js on lines 134..142

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

          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

          Sidebar.propTypes = {
            snippets: PropTypes.object,
            theme: PropTypes.object,
            filterText: PropTypes.string,
            filterTags: PropTypes.array,
          Severity: Major
          Found in src/components/layout/sidebar/Sidebar.js and 2 other locations - About 3 hrs to fix
          src/components/common/controls/Button.js on lines 72..83
          src/components/layout/content/DashBoard.js on lines 420..431

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

          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

          const SearchFilters = styled.div`
            color: ${(props) => props.theme.baseAppColor};
            padding: 10px 20px;
            background: ${(props) => props.theme.lightText};
            z-index: 1;
          Severity: Major
          Found in src/components/layout/sidebar/Sidebar.js and 1 other location - About 2 hrs to fix
          src/components/LogIn.js on lines 25..75

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

          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 Tag = styled.span`
            border: 1px solid ${(props) => props.theme.baseAppColor};
            color: ${(props) => props.theme.baseAppColor};
            padding: 1px 3px;
            border-radius: 3px;
          Severity: Major
          Found in src/components/layout/sidebar/Sidebar.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/headers/SnippetHeader.js on lines 74..83

          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