best-doctor/ke

View on GitHub
src/ListView/components/Table/filters.tsx

Summary

Maintainability
F
4 days
Test Coverage
F
59%

File filters.tsx has 383 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Это легаси
/* eslint-disable react/jsx-props-no-spreading */
import React, { useState } from 'react'
import InputMask, { Props as InputMaskProps } from 'react-input-mask'
import { Box } from '@chakra-ui/react'
Severity: Minor
Found in src/ListView/components/Table/filters.tsx - About 5 hrs to fix

    Function ForeignKeySelectFilter has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const ForeignKeySelectFilter = (params: ForeignKeySelectFilterProps): JSX.Element => {
      const {
        name,
        label,
        resourceName,
    Severity: Major
    Found in src/ListView/components/Table/filters.tsx - About 2 hrs to fix

      Function MultiSelectFilter has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const MultiSelectFilter = (params: ResourceFilterProps): JSX.Element => {
        const [options, setOptions] = React.useState<any>([])
        const [storedOptions, setStoredOptions] = React.useState<Model[]>([])
        const { name, label, filterResource, resourceName, gotoPage, provider, cacheTime, className } = params
        const history = useHistory()
      Severity: Minor
      Found in src/ListView/components/Table/filters.tsx - About 1 hr to fix

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

        const BooleanFilter = (params: BooleanFilterProps): JSX.Element => {
          const {
            name,
            label,
            resourceName,
        Severity: Minor
        Found in src/ListView/components/Table/filters.tsx - About 1 hr to fix

          Function SelectFilter has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const SelectFilter = (params: ResourceFilterProps): JSX.Element => {
            const { name, label, resourceName, filterResource, gotoPage, provider, cacheTime } = params
            const history = useHistory()
            const location = useLocation()
            const [options, setOptions] = React.useState<any>([])
          Severity: Minor
          Found in src/ListView/components/Table/filters.tsx - About 1 hr to fix

            Function DateTimeFilter has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const DateTimeFilter = (params: DateTimeFilterProps): JSX.Element => {
              const [currentDate, setCurrentDate] = React.useState<Date | null | undefined>()
              const { name, label, resourceName, gotoPage, filterDate, filterTime } = params
              const history = useHistory()
              const location = useLocation()
            Severity: Minor
            Found in src/ListView/components/Table/filters.tsx - About 1 hr to fix

              Function DateFilter has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const DateFilter = (params: DateTimeFilterProps): JSX.Element => {
                const [currentDate, setCurrentDate] = React.useState<Date | null | undefined>()
                const { name, label, resourceName, gotoPage, filterDate, filterTime } = params
                const history = useHistory()
                const location = useLocation()
              Severity: Minor
              Found in src/ListView/components/Table/filters.tsx - About 1 hr to fix

                Function MaskFilter has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const MaskFilter = (params: FilterProps & InputMaskProps): JSX.Element => {
                  const { name, label, resourceName, gotoPage, ...maskProps } = params
                  const history = useHistory()
                  const location = useLocation()
                  const [value, setValue] = useState('')
                Severity: Minor
                Found in src/ListView/components/Table/filters.tsx - About 1 hr to fix

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

                    return (
                      <StyledFilter>
                        <Select
                          className="styled-filter"
                          onChange={(value: any) => handleChange(value)}
                  Severity: Major
                  Found in src/ListView/components/Table/filters.tsx and 1 other location - About 3 hrs to fix
                  src/ListView/components/Table/filters.tsx on lines 238..250

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

                  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 (
                      <StyledFilter>
                        <Select
                          className="styled-filter"
                          onChange={(value: any) => handleChange(value)}
                  Severity: Major
                  Found in src/ListView/components/Table/filters.tsx and 1 other location - About 3 hrs to fix
                  src/ListView/components/Table/filters.tsx on lines 283..295

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

                  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 handleChange = (value: DatePickerValue): void => {
                      const singleValue = getDateFromDatePicker(value)
                      const filterValue = singleValue ? format(singleValue, "yyyy-MM-dd'T'HH:mm:ss") : ''
                  
                      pushAnalytics({
                  Severity: Major
                  Found in src/ListView/components/Table/filters.tsx and 1 other location - About 3 hrs to fix
                  src/ListView/components/Table/filters.tsx on lines 371..383

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

                  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 handleChange = (value: DatePickerValue): void => {
                      const singleValue = getDateFromDatePicker(value)
                      const filterValue = singleValue ? format(singleValue, 'yyyy-MM-dd') : ''
                  
                      pushAnalytics({
                  Severity: Major
                  Found in src/ListView/components/Table/filters.tsx and 1 other location - About 3 hrs to fix
                  src/ListView/components/Table/filters.tsx on lines 406..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 99.

                  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 handleChange = (value: ValueType): void => {
                      const filterValue = value ? value.value : ''
                  
                      pushAnalytics({
                        eventName: EventNameEnum.SELECT_OPTION_CHANGE,
                  Severity: Major
                  Found in src/ListView/components/Table/filters.tsx and 1 other location - About 2 hrs to fix
                  src/ListView/components/Table/filters.tsx on lines 271..281

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

                  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 handleChange = (value: ValueType): void => {
                      const filterValue = value ? value.value : ''
                  
                      pushAnalytics({
                        eventName: EventNameEnum.SELECT_OPTION_CHANGE,
                  Severity: Major
                  Found in src/ListView/components/Table/filters.tsx and 1 other location - About 2 hrs to fix
                  src/ListView/components/Table/filters.tsx on lines 222..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 80.

                  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 handleChange = (newValue: string): void => {
                      setValue(newValue)
                      pushAnalytics({
                        eventName: EventNameEnum.INPUT_CHANGE,
                        ...getCommonFilterAnalyticsPayload(resourceName, newValue, name),
                  Severity: Major
                  Found in src/ListView/components/Table/filters.tsx and 1 other location - About 1 hr to fix
                  src/ListView/components/Table/filters.tsx on lines 102..111

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

                  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 handleChange = (newValue: string): void => {
                      setValue(newValue)
                      pushAnalytics({
                        eventName: EventNameEnum.INPUT_CHANGE,
                        ...getCommonFilterAnalyticsPayload(resourceName, newValue, name),
                  Severity: Major
                  Found in src/ListView/components/Table/filters.tsx and 1 other location - About 1 hr to fix
                  src/ListView/components/Table/filters.tsx on lines 129..138

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

                  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

                    React.useEffect(() => {
                      provider.getList(filterResource, null, null, cacheTime).then((result) => setOptions(result))
                    }, [cacheTime, filterResource, provider])
                  Severity: Minor
                  Found in src/ListView/components/Table/filters.tsx and 1 other location - About 50 mins to fix
                  src/ListView/components/Table/filters.tsx on lines 168..170

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

                  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

                    React.useEffect(() => {
                      provider.getList(filterResource, null, null, cacheTime).then((result) => setStoredOptions(result))
                    }, [cacheTime, filterResource, provider])
                  Severity: Minor
                  Found in src/ListView/components/Table/filters.tsx and 1 other location - About 50 mins to fix
                  src/ListView/components/Table/filters.tsx on lines 234..236

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

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

                    const { name, label, filterResource, resourceName, gotoPage, provider, cacheTime, className } = params
                  Severity: Major
                  Found in src/ListView/components/Table/filters.tsx and 4 other locations - About 40 mins to fix
                  src/DetailView/widgets/AsyncReadOnlyWidget.tsx on lines 21..21
                  src/DetailView/widgets/SwitchWidget.tsx on lines 21..22
                  src/common/hooks/useWidgetInitialization.tsx on lines 33..34
                  src/integration/analytics/utils.ts on lines 37..37

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

                  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