lukaskupczyk/react-hook-consent

View on GitHub

Showing 7 of 47 total issues

Function Home has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function Home() {
    return (
        <main className={styles.main}>
            <div className={styles.description}>
                <p>
Severity: Major
Found in examples/next-v13/src/app/page.tsx - About 3 hrs to fix

    Function useConsentState has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function useConsentState(options: ConsentOptions) {
        const [state, setState] = useState<ConsentState>({
            consent: [],
            isBannerVisible: false,
            isDetailsVisible: false,
    Severity: Minor
    Found in src/useConsentState.tsx - About 1 hr to fix

      Function HomepageDemo has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function HomepageDemo() {
          const { colorMode: theme } = useColorMode();
      
          return (
              <ConsentProvider
      Severity: Minor
      Found in docs/src/components/homepage/Demo.tsx - About 1 hr to fix

        Function ConsentBanner has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        export function ConsentBanner({ children, settings, approve, decline }: ConsentBannerProps) {
            const {
                isBannerVisible,
                isDetailsVisible,
                toggleDetails,
        Severity: Minor
        Found in src/banner/Banner.tsx - About 55 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

        Function removeCookies has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        export function removeCookies(cookies?: Cookie[]) {
            if (!cookies) {
                return;
            }
        
        
        Severity: Minor
        Found in src/core/cookies/remove.ts - About 55 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

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

        export function addScripts(serviceId: string, scripts: ConsentOptions['services'][number]['scripts']) {
            if (!scripts) {
                return;
            }
        
        
        Severity: Minor
        Found in src/core/scripts/add.ts - 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

        Function ConsentBannerSettings has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        export function ConsentBannerSettings({ onToggle = () => {}, modal }: ConsentBannerSettingsProps) {
            const {
                options: { services, theme },
            } = useConsent();
            const { onDecline, onApprove } = useConsentBannerActions();
        Severity: Minor
        Found in src/banner/settings/Settings.tsx - About 35 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

        Severity
        Category
        Status
        Source
        Language