TryGhost/Ghost

View on GitHub
apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx

Summary

Maintainability
F
5 days
Test Coverage

File NewsletterDetailModal.tsx has 556 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import NewsletterPreview from './NewsletterPreview';
import NiceModal from '@ebay/nice-modal-react';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import useFeatureFlag from '../../../../hooks/useFeatureFlag';
import useSettingGroup from '../../../../hooks/useSettingGroup';

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

    }> = ({newsletter, onlyOne, updateNewsletter, validate, errors, clearError}) => {
        const {updateRoute} = useRouting();
        const {mutateAsync: editNewsletter} = useEditNewsletter();
        const limiter = useLimiter();
        const {settings, siteData, config} = useGlobalData();

    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 confirmStatusChange has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        const confirmStatusChange = async () => {
            if (newsletter.status === 'active') {
                NiceModal.show(ConfirmationModal, {
                    title: 'Archive newsletter',
                    prompt: <>

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

      const NewsletterDetailModalContent: React.FC<{newsletter: Newsletter; onlyOne: boolean;}> = ({newsletter, onlyOne}) => {
          const {config} = useGlobalData();
          const {mutateAsync: editNewsletter} = useEditNewsletter();
          const {updateRoute} = useRouting();
          const handleError = useHandleError();

      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 renderSenderEmailField has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          const renderSenderEmailField = () => {
              // Self-hosters, or legacy Pro users
              if (!isManagedEmail(config)) {
                  return (
                      <TextField

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

                                    {
                                        icon: 'align-left',
                                        label: 'Align left',
                                        hideLabel: true,
                                        link: false,
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 386..396

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

        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

                                    {
                                        icon: 'align-center',
                                        label: 'Align center',
                                        hideLabel: true,
                                        link: false,
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 375..385

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

        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

                            <Toggle
                                checked={newsletter.subscribe_on_signup}
                                direction='rtl'
                                label='Subscribe new members on signup'
                                labelStyle='value'
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 358..364

        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

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

                            <Toggle
                                checked={newsletter.show_post_title_section}
                                direction="rtl"
                                label='Post title'
                                labelStyle='heading'
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 246..252

        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

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

                                {icon && <Toggle
                                    checked={newsletter.show_header_icon}
                                    direction="rtl"
                                    label='Publication icon'
                                    onChange={e => updateNewsletter({show_header_icon: e.target.checked})}
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 299..304
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 305..310
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 426..431
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 436..441
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 442..447
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 448..453
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 454..459

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

        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

                                <Toggle
                                    checked={newsletter.show_latest_posts}
                                    direction="rtl"
                                    label='Share your latest posts'
                                    onChange={e => updateNewsletter({show_latest_posts: e.target.checked})}
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 293..298
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 299..304
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 305..310
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 426..431
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 436..441
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 442..447
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 454..459

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

        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

                                <Toggle
                                    checked={newsletter.show_header_title}
                                    direction="rtl"
                                    label='Publication title'
                                    onChange={e => updateNewsletter({show_header_title: e.target.checked})}
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 293..298
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 305..310
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 426..431
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 436..441
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 442..447
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 448..453
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 454..459

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

        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

                                <Toggle
                                    checked={newsletter.feedback_enabled}
                                    direction="rtl"
                                    label='Ask your readers for feedback'
                                    onChange={e => updateNewsletter({feedback_enabled: e.target.checked})}
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 293..298
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 299..304
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 305..310
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 426..431
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 442..447
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 448..453
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 454..459

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

        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

                                <Toggle
                                    checked={newsletter.show_subscription_details}
                                    direction="rtl"
                                    label='Show subscription details'
                                    onChange={e => updateNewsletter({show_subscription_details: e.target.checked})}
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 293..298
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 299..304
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 305..310
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 426..431
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 436..441
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 442..447
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 448..453

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

        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

                                <Toggle
                                    checked={newsletter.show_header_name}
                                    direction="rtl"
                                    label='Newsletter name'
                                    onChange={e => updateNewsletter({show_header_name: e.target.checked})}
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 293..298
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 299..304
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 426..431
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 436..441
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 442..447
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 448..453
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 454..459

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

        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

                            <Toggle
                                checked={newsletter.show_feature_image}
                                direction="rtl"
                                label='Feature image'
                                onChange={e => updateNewsletter({show_feature_image: e.target.checked})}
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 293..298
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 299..304
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 305..310
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 436..441
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 442..447
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 448..453
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 454..459

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

        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

                                <Toggle
                                    checked={newsletter.show_comment_cta}
                                    direction="rtl"
                                    label='Add a link to your comments'
                                    onChange={e => updateNewsletter({show_comment_cta: e.target.checked})}
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 293..298
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 299..304
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 305..310
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 426..431
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 436..441
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 448..453
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 454..459

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

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

                                        <div className='flex flex-col gap-0.5'>
                                            <span className='text-sm md:text-base'>Promote independent publishing</span>
                                            <span className='text-[11px] leading-tight text-grey-700 md:text-xs md:leading-tight'>Show you’re a part of the indie publishing movement with a small badge in the footer</span>
                                        </div>
        apps/admin-x-demo/src/DetailPage.tsx on lines 80..83
        apps/admin-x-demo/src/DetailPage.tsx on lines 117..120
        apps/admin-x-demo/src/DetailPage.tsx on lines 128..131
        apps/admin-x-demo/src/DetailPage.tsx on lines 132..135
        apps/admin-x-demo/src/DetailPage.tsx on lines 136..139

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

        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 sidebar = <Sidebar clearError={clearError} errors={errors} newsletter={formState} onlyOne={onlyOne} updateNewsletter={updateNewsletter} validate={validate} />;
        apps/admin-x-settings/src/components/settings/membership/portal/PortalModal.tsx on lines 31..38

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

        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

                            try {
                                await editNewsletter({...newsletter, status: 'archived'});
                                modal?.remove();
                                showToast({
                                    type: 'success',
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 171..178

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

        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

                        onOk: async (modal) => {
                            await editNewsletter({...newsletter, status: 'active'});
                            modal?.remove();
                            showToast({
                                type: 'success',
        apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx on lines 138..145

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

        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 {formState, saveState, updateForm, setFormState, handleSave, validate, errors, clearError, okProps} = useForm({
                initialState: newsletter,
                savingDelay: 500,
                onSave: async () => {
                    const {meta: {sent_email_verification: [emailToVerify] = []} = {}} = await editNewsletter(formState); ``;
        apps/admin-x-settings/src/components/settings/general/LockSite.tsx on lines 10..30
        apps/admin-x-settings/src/components/settings/general/Metadata.tsx on lines 59..69
        apps/admin-x-settings/src/components/settings/general/UserDetailModal.tsx on lines 100..121
        apps/admin-x-settings/src/components/settings/growth/offers/EditOfferModal.tsx on lines 189..213

        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