FezVrasta/popper.js

View on GitHub
website/lib/components/Layout.js

Summary

Maintainability
F
3 days
Test Coverage

File Layout.js has 874 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {DocSearch} from '@docsearch/react';
import {
    autoUpdate,
    FloatingFocusManager,
    FloatingPortal,
Severity: Major
Found in website/lib/components/Layout.js - About 2 days to fix

Function Layout has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export default function Layout({children, className}) {
    const {pathname, events, asPath} = useRouter();
    const index = nav.findIndex(({url}) => url === pathname) ?? 0;
    const [navOpen, setNavOpen] = useState(false);
    const [anchors, setAnchors] = useState([]);
Severity: Minor
Found in website/lib/components/Layout.js - 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 a has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    a(props) {
        const className =
            'transition-colors inline-flex items-center border-none underline ' +
            'underline-offset-4 text-rose-600 dark:text-rose-300 hover:text-gray-1000 dark:hover:text-gray-50 ' +
            'decoration-rose-500/80 dark:decoration-rose-300/70 ' +
Severity: Minor
Found in website/lib/components/Layout.js - About 1 hr to fix

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

function NavbarItem({
    url,
    title,
    icon: Icon,
    hide,
Severity: Minor
Found in website/lib/components/Layout.js - 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

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

                        <Link
                            ref={hash === url ? refs.setReference : null}
                            href={url}
                            className={cn('block w-full truncate rounded-lg py-1 px-4', {
                                'font-bold hover:bg-gray-100 dark:hover:bg-purple-300/10':
Severity: Major
Found in website/lib/components/Layout.js and 1 other location - About 2 hrs to fix
website/lib/components/Layout.js on lines 460..474

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

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

                                        <Link
                                            ref={hash === url ? refs.setReference : null}
                                            href={url}
                                            className={cn(
                                                'text-md ml-4 block truncate rounded-tr-md rounded-br-md border-l border-gray-700 py-1 px-4',
Severity: Major
Found in website/lib/components/Layout.js and 1 other location - About 2 hrs to fix
website/lib/components/Layout.js on lines 440..451

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

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

                <p className="mt-4 text-sm">
                    Icons made by{' '}
                    <a
                        className="text-blue-600 dark:text-blue-400 underline"
                        href="https://www.zwicon.com/cheatsheet.html"
Severity: Major
Found in website/lib/components/Layout.js and 1 other location - About 1 hr to fix
website/pages/index.js on lines 644..661

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

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 isTopLevelAnchor = anchors
        .filter(({depth}) => depth === 2)
        .find(({url}) => hash === url);
Severity: Minor
Found in website/lib/components/Layout.js and 1 other location - About 50 mins to fix
website/lib/components/Layout.js on lines 400..402

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

    const isSecondLevelAnchor = anchors
        .filter(({depth}) => depth === 3)
        .find(({url}) => hash === url);
Severity: Minor
Found in website/lib/components/Layout.js and 1 other location - About 50 mins to fix
website/lib/components/Layout.js on lines 397..399

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

There are no issues that match your filters.

Category
Status