basantech89/awesome-ui

View on GitHub
src/utils/theme.ts

Summary

Maintainability
C
7 hrs
Test Coverage

Function expandCSS has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

export const expandCSS = ({ d, gap, gapX, gapY, ...rest }: ThemeBoxProps) => {
  let styles: CSSObject = {}
  if (d) {
    styles = { ...styles, display: d }
    if (d === 'flex' || d === 'inline-flex') {
Severity: Minor
Found in src/utils/theme.ts - About 5 hrs 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

Avoid deeply nested control flow statements.
Open

        if (gapX) {
          styles = { ...styles, columnGap: getSpacing(gapX) }
        }
Severity: Major
Found in src/utils/theme.ts - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

            if (gapY) {
              styles = { ...styles, rowGap: getSpacing(gapY) }
            }
    Severity: Major
    Found in src/utils/theme.ts - About 45 mins to fix

      Function getSpacing has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export const getSpacing = (
        spacer: string | number,
        sizing?: SpacingSizing,
        compute?: SpacingFn
      ): string => {
      Severity: Minor
      Found in src/utils/theme.ts - About 25 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 getSpacingComponents has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export const getSpacingComponents = (spacing: string): { spacer: number; unit: string } => {
        let amount = ''
        let unit = ''
      
        for (const char of spacing) {
      Severity: Minor
      Found in src/utils/theme.ts - About 25 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

      There are no issues that match your filters.

      Category
      Status