ui/src/modules/settings/integrations/components/mail/MailForm.tsx

Summary

Maintainability
F
4 days
Test Coverage

File MailForm.tsx has 800 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import dayjs from 'dayjs';
import Button from 'modules/common/components/Button';
import { SmallLoader } from 'modules/common/components/ButtonMutate';
import FormControl from 'modules/common/components/form/Control';
import { Label } from 'modules/common/components/form/styles';
Severity: Major
Found in ui/src/modules/settings/integrations/components/mail/MailForm.tsx - About 1 day to fix

    MailForm has 41 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class MailForm extends React.Component<Props, State> {
      constructor(props: Props) {
        super(props);
    
        const { isForward, replyAll, mailData = {} as IMail } = props;
    Severity: Minor
    Found in ui/src/modules/settings/integrations/components/mail/MailForm.tsx - About 5 hrs to fix

      Function renderButtons has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        renderButtons() {
          const { kind } = this.state;
          const {
            isReply,
            emailTemplates,
      Severity: Major
      Found in ui/src/modules/settings/integrations/components/mail/MailForm.tsx - About 2 hrs to fix

        Function constructor has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          constructor(props: Props) {
            super(props);
        
            const { isForward, replyAll, mailData = {} as IMail } = props;
        
        
        Severity: Minor
        Found in ui/src/modules/settings/integrations/components/mail/MailForm.tsx - About 1 hr to fix

          Function getReplies has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            getReplies(messageId?: string) {
              const { mails = [] } = this.props;
          
              if (!messageId) {
                return '';
          Severity: Minor
          Found in ui/src/modules/settings/integrations/components/mail/MailForm.tsx - About 1 hr to fix

            Function constructor has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              constructor(props: Props) {
                super(props);
            
                const { isForward, replyAll, mailData = {} as IMail } = props;
            
            
            Severity: Minor
            Found in ui/src/modules/settings/integrations/components/mail/MailForm.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

            Function getReplies has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              getReplies(messageId?: string) {
                const { mails = [] } = this.props;
            
                if (!messageId) {
                  return '';
            Severity: Minor
            Found in ui/src/modules/settings/integrations/components/mail/MailForm.tsx - About 45 mins 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

                  <ControlWrapper>
                    {this.renderMeta()}
                    {this.renderSubject()}
                    {this.renderBody()}
                    {this.renderAttachments()}
            ui/src/modules/settings/boards/components/PipelineRow.tsx on lines 154..160

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

            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

              findTemplate = id => {
                const template = this.props.emailTemplates.find(t => t._id === id);
            
                if (template) {
                  return template.content;
            ui/src/modules/engage/components/EmailForm.tsx on lines 93..101
            ui/src/modules/engage/components/WidgetForm.tsx on lines 116..124
            ui/src/modules/leads/components/step/SuccessStep.tsx on lines 96..104

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

            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

                  <Column>
                    {this.renderFrom()}
                    {this.renderTo()}
                    {this.renderCC()}
                    {this.renderBCC()}
            ui/src/modules/automations/components/forms/actions/placeHolder/PlaceHolderInput.tsx on lines 267..272

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

            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 {
                  isReply,
                  closeModal,
                  toggleReply,
                  integrationId,
            ui/src/modules/boards/components/editForm/Actions.tsx on lines 39..48
            ui/src/modules/customers/containers/CustomersList.tsx on lines 81..90
            ui/src/modules/engage/components/AutoAndManualForm.tsx on lines 256..265
            ui/src/modules/engage/components/MessageList.tsx on lines 211..220
            ui/src/modules/leads/components/Lead.tsx on lines 164..173
            ui/src/modules/leads/components/List.tsx on lines 71..80
            ui/src/modules/leads/components/step/preview/CalloutPreview.tsx on lines 17..26
            ui/src/modules/settings/boards/components/PipelineForm.tsx on lines 107..116
            ui/src/modules/settings/integrations/components/mail/MailForm.tsx on lines 307..316
            widgets/client/messenger/components/Message.tsx on lines 69..78

            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

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

                const {
                  content,
                  from,
                  attachments,
                  to,
            ui/src/modules/boards/components/editForm/Actions.tsx on lines 39..48
            ui/src/modules/customers/containers/CustomersList.tsx on lines 81..90
            ui/src/modules/engage/components/AutoAndManualForm.tsx on lines 256..265
            ui/src/modules/engage/components/MessageList.tsx on lines 211..220
            ui/src/modules/leads/components/Lead.tsx on lines 164..173
            ui/src/modules/leads/components/List.tsx on lines 71..80
            ui/src/modules/leads/components/step/preview/CalloutPreview.tsx on lines 17..26
            ui/src/modules/settings/boards/components/PipelineForm.tsx on lines 107..116
            ui/src/modules/settings/integrations/components/mail/MailForm.tsx on lines 295..304
            widgets/client/messenger/components/Message.tsx on lines 69..78

            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

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

                  <Meta>
                    <SpaceBetweenRow>
                      {this.renderLeftSide()}
                      {this.renderRightSide()}
                    </SpaceBetweenRow>
            ui/src/modules/inbox/components/conversationDetail/workarea/responseTemplate/PopoverContent.tsx on lines 161..166

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

            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