bufferapp/ui

View on GitHub
src/components/Select/Select.tsx

Summary

Maintainability
F
3 days
Test Coverage
C
75%

File Select.tsx has 645 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable no-unused-expressions, react/no-unused-state */
import React from 'react'
import PropTypes from 'prop-types'
import helper from 'immutability-helper'
import SearchIcon from '../Icon/Icons/Search'
Severity: Major
Found in src/components/Select/Select.tsx - About 1 day to fix

    Select has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class Select extends React.Component {
      // @ts-expect-error TS(7006) FIXME: Parameter 'itemsA' implicitly has an 'any' type.
      static sameItems = (itemsA, itemsB) =>
        itemsA.length === itemsB.length &&
        itemsA.every(
    Severity: Minor
    Found in src/components/Select/Select.tsx - About 3 hrs to fix

      Avoid too many return statements within this function.
      Open

          return (
            // @ts-expect-error TS(2740) FIXME: Type '{ size: any; items: any; disabled: any; type... Remove this comment to see the full error message
            <Button
              size={size}
              items={items}
      Severity: Major
      Found in src/components/Select/Select.tsx - About 30 mins to fix

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

            const {
              // @ts-expect-error TS(2339) FIXME: Property 'xPosition' does not exist on type 'Reado... Remove this comment to see the full error message
              xPosition,
              // @ts-expect-error TS(2339) FIXME: Property 'yPosition' does not exist on type 'Reado... Remove this comment to see the full error message
              yPosition,
        Severity: Major
        Found in src/components/Select/Select.tsx and 1 other location - About 5 hrs to fix
        src/components/Input/Input.tsx on lines 10..47

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

        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

                if (
                  item[searchField].toLowerCase().startsWith(searchValue.toLowerCase())
                ) {
                  return {
                    ...filtered,
        Severity: Major
        Found in src/components/Select/Select.tsx and 1 other location - About 2 hrs to fix
        src/components/Select/Select.tsx on lines 449..464

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

        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

                if (
                  item[searchField].toLowerCase().includes(searchValue.toLowerCase())
                ) {
                  return {
                    ...filtered,
        Severity: Major
        Found in src/components/Select/Select.tsx and 1 other location - About 2 hrs to fix
        src/components/Select/Select.tsx on lines 433..448

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

        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

              if (items[i]) {
                this.setState({ hoveredItem: i % itemsLength })
                this.scrollToItem(
                  // @ts-expect-error TS(2339) FIXME: Property 'itemsNode' does not exist on type 'Selec... Remove this comment to see the full error message
                  this.itemsNode,
        Severity: Major
        Found in src/components/Select/Select.tsx and 1 other location - About 1 hr to fix
        src/components/Select/Select.tsx on lines 367..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 71.

        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

              if (items[i]) {
                this.setState({ hoveredItem: i % itemsLength })
                this.scrollToItem(
                  // @ts-expect-error TS(2339) FIXME: Property 'itemsNode' does not exist on type 'Selec... Remove this comment to see the full error message
                  this.itemsNode,
        Severity: Major
        Found in src/components/Select/Select.tsx and 1 other location - About 1 hr to fix
        src/components/Select/Select.tsx on lines 292..300

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

        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