RocketChat/Rocket.Chat

View on GitHub
apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx

Summary

Maintainability
F
3 days
Test Coverage

File EditDepartment.tsx has 462 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import type { ILivechatDepartment, ILivechatDepartmentAgents, Serialized } from '@rocket.chat/core-typings';
import {
    FieldGroup,
    Field,
    FieldLabel,
Severity: Minor
Found in apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx - About 7 hrs to fix

    Function handleSave has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        const handleSave = useMutableCallback(async (data: FormValues) => {
            const {
                agentList,
                enabled,
                name,
    Severity: Major
    Found in apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx - About 2 hrs to fix

      Function EditDepartment has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function EditDepartment({ data, id, title, allowedToForwardData }: EditDepartmentProps) {
          const t = useTranslation();
          const router = useRouter();
          const queryClient = useQueryClient();
      
      
      Severity: Minor
      Found in apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx - About 1 hr 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

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

              const {
                  agentList,
                  enabled,
                  name,
                  description,
      apps/meteor/client/views/room/contextualBar/Info/EditRoomInfo/EditRoomInfo.tsx on lines 106..123

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

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

                                      <Field>
                                          <Controller
                                              control={control}
                                              name='abandonedRoomsCloseCustomMessage'
                                              render={({ field }) => (
      apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx on lines 345..357
      apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx on lines 358..370
      apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx on lines 384..392

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

                                      <Field>
                                          <Controller
                                              control={control}
                                              name='visitorInactivityTimeoutInSeconds'
                                              render={({ field }) => (
      apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx on lines 345..357
      apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx on lines 371..383
      apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx on lines 384..392

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

                                      <Field>
                                          <Controller
                                              control={control}
                                              name='waitingQueueMessage'
                                              render={({ field }) => (
      apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx on lines 345..357
      apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx on lines 358..370
      apps/meteor/client/views/omnichannel/departments/EditDepartment.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 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 4 locations. Consider refactoring.
      Open

                                      <Field>
                                          <Controller
                                              control={control}
                                              name='maxNumberSimultaneousChat'
                                              render={({ field }) => (
      apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx on lines 358..370
      apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx on lines 371..383
      apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx on lines 384..392

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

                              <Field>
                                  <FieldRow>
                                      <FieldLabel htmlFor={showOnOfflineFormField}>{t('Show_on_offline_page')}</FieldLabel>
                                      <ToggleSwitch id={showOnOfflineFormField} {...register('showOnOfflineForm')} />
                                  </FieldRow>
      apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx on lines 244..249
      apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx on lines 431..436
      apps/meteor/client/views/room/contextualBar/MessageSearchTab/components/MessageSearchForm.tsx on lines 70..75
      apps/meteor/client/views/room/contextualBar/PruneMessages/PruneMessages.tsx on lines 57..62
      apps/meteor/client/views/room/contextualBar/PruneMessages/PruneMessages.tsx on lines 63..68
      apps/meteor/client/views/room/contextualBar/PruneMessages/PruneMessages.tsx on lines 69..74
      apps/meteor/client/views/room/contextualBar/PruneMessages/PruneMessages.tsx on lines 75..80
      apps/meteor/client/views/room/contextualBar/PruneMessages/PruneMessages.tsx on lines 81..86

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

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

                              <Field>
                                  <FieldRow>
                                      <FieldLabel htmlFor={requestTagBeforeClosingChatField}>{t('Request_tag_before_closing_chat')}</FieldLabel>
                                      <ToggleSwitch id={requestTagBeforeClosingChatField} {...register('requestTagBeforeClosingChat')} />
                                  </FieldRow>
      apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx on lines 244..249
      apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx on lines 311..316
      apps/meteor/client/views/room/contextualBar/MessageSearchTab/components/MessageSearchForm.tsx on lines 70..75
      apps/meteor/client/views/room/contextualBar/PruneMessages/PruneMessages.tsx on lines 57..62
      apps/meteor/client/views/room/contextualBar/PruneMessages/PruneMessages.tsx on lines 63..68
      apps/meteor/client/views/room/contextualBar/PruneMessages/PruneMessages.tsx on lines 69..74
      apps/meteor/client/views/room/contextualBar/PruneMessages/PruneMessages.tsx on lines 75..80
      apps/meteor/client/views/room/contextualBar/PruneMessages/PruneMessages.tsx on lines 81..86

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

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

                              <Field>
                                  <FieldRow>
                                      <FieldLabel htmlFor={enabledField}>{t('Enabled')}</FieldLabel>
                                      <ToggleSwitch id={enabledField} {...register('enabled')} />
                                  </FieldRow>
      apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx on lines 311..316
      apps/meteor/client/views/omnichannel/departments/EditDepartment.tsx on lines 431..436
      apps/meteor/client/views/room/contextualBar/MessageSearchTab/components/MessageSearchForm.tsx on lines 70..75
      apps/meteor/client/views/room/contextualBar/PruneMessages/PruneMessages.tsx on lines 57..62
      apps/meteor/client/views/room/contextualBar/PruneMessages/PruneMessages.tsx on lines 63..68
      apps/meteor/client/views/room/contextualBar/PruneMessages/PruneMessages.tsx on lines 69..74
      apps/meteor/client/views/room/contextualBar/PruneMessages/PruneMessages.tsx on lines 75..80
      apps/meteor/client/views/room/contextualBar/PruneMessages/PruneMessages.tsx on lines 81..86

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

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

                                                      renderItem={({ label, ...props }) => (
                                                          <Option {...props} label={<span style={{ whiteSpace: 'normal' }}>{label}</span>} />
                                                      )}
      apps/meteor/client/components/AutoCompleteDepartmentMultiple.tsx on lines 68..68
      apps/meteor/client/components/Omnichannel/modals/ForwardChatModal.tsx on lines 122..122
      apps/meteor/client/views/omnichannel/agents/AgentEdit.tsx on lines 189..191
      apps/meteor/client/views/omnichannel/analytics/AnalyticsPage.tsx on lines 71..71
      apps/meteor/ee/client/omnichannel/additionalForms/DepartmentForwarding.tsx on lines 68..68
      apps/meteor/ee/client/omnichannel/cannedResponses/components/cannedResponseForm.tsx on lines 182..184
      apps/meteor/ee/client/omnichannel/units/UnitEdit.tsx on lines 245..247

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

      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