Microsoft/fast-dna

View on GitHub
packages/web-components/fast-router/src/routes.ts

Summary

Maintainability
C
1 day
Test Coverage

Function map has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    public map(...routes: MappableRouteDefinition<TSettings>[]) {
        for (const route of routes) {
            if ("children" in route) {
                const titleBuilder = this.owner.createTitleBuilder();
                const childRoutes = route.children.map(x => {
Severity: Minor
Found in packages/web-components/fast-router/src/routes.ts - About 4 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

File routes.ts has 290 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Constructable, FASTElement, ViewTemplate } from "@microsoft/fast-element";
import {
    ConfigurableRoute,
    Endpoint,
    RecognizedRoute,
Severity: Minor
Found in packages/web-components/fast-router/src/routes.ts - About 2 hrs to fix

    Function map has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public map(...routes: MappableRouteDefinition<TSettings>[]) {
            for (const route of routes) {
                if ("children" in route) {
                    const titleBuilder = this.owner.createTitleBuilder();
                    const childRoutes = route.children.map(x => {
    Severity: Minor
    Found in packages/web-components/fast-router/src/routes.ts - About 1 hr to fix

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

          public async recognize(path: string): Promise<RouteMatch<TSettings> | null> {
              const result = await this.recognizer.recognize(path, this.aggregateConverters());
      
              if (result !== null) {
                  return {
      Severity: Minor
      Found in packages/web-components/fast-router/src/routes.ts - About 1 hr to fix

        There are no issues that match your filters.

        Category
        Status