exercism/website

View on GitHub
app/javascript/utils/regex-check.ts

Summary

Maintainability
C
1 day
Test Coverage

Function isLookbehindSupported has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

export function isLookbehindSupported(): boolean {
  const parser = new UAParser().getBrowser()

  switch (parser.name) {
    case 'IE':
Severity: Minor
Found in app/javascript/utils/regex-check.ts - About 3 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

Function isLookbehindSupported has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function isLookbehindSupported(): boolean {
  const parser = new UAParser().getBrowser()

  switch (parser.name) {
    case 'IE':
Severity: Minor
Found in app/javascript/utils/regex-check.ts - About 1 hr to fix

    Avoid too many return statements within this function.
    Open

          if (parser.version) return compareVersions(parser.version, '124') >= 0
    Severity: Major
    Found in app/javascript/utils/regex-check.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            if (parser.version) return compareVersions(parser.version, '8.2') >= 0
      Severity: Major
      Found in app/javascript/utils/regex-check.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              if (parser.version) return compareVersions(parser.version, '14.9') >= 0
        Severity: Major
        Found in app/javascript/utils/regex-check.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                if (parser.version) return compareVersions(parser.version, '13.52') >= 0
          Severity: Major
          Found in app/javascript/utils/regex-check.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  if (parser.version) return compareVersions(parser.version, '3.1') >= 0
            Severity: Major
            Found in app/javascript/utils/regex-check.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    if (parser.version) return compareVersions(parser.version, '16.4') >= 0
              Severity: Major
              Found in app/javascript/utils/regex-check.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      if (parser.version) return compareVersions(parser.version, '49') >= 0
                Severity: Major
                Found in app/javascript/utils/regex-check.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        if (parser.version) return compareVersions(parser.version, '15.5') >= 0
                  Severity: Major
                  Found in app/javascript/utils/regex-check.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                          if (parser.version) return compareVersions(parser.version, '80') >= 0
                    Severity: Major
                    Found in app/javascript/utils/regex-check.ts - About 30 mins to fix

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

                      function compareVersions(versionA: string, versionB: string): number {
                        const partsA = versionA.split('.').map(Number)
                        const partsB = versionB.split('.').map(Number)
                      
                        for (let i = 0; i < Math.max(partsA.length, partsB.length); i++) {
                      Severity: Minor
                      Found in app/javascript/utils/regex-check.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