aurelia/aurelia

View on GitHub
packages/router/src/instructions/routing-instruction.ts

Summary

Maintainability
F
3 days
Test Coverage

File routing-instruction.ts has 361 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { InstructionParser } from './instruction-parser';
import { InstructionParameters, Parameters } from './instruction-parameters';
import { InstructionComponent } from './instruction-component';
import { ComponentAppellation, ComponentParameters, LoadInstruction } from '../interfaces';
import { RoutingScope } from '../routing-scope';
Severity: Minor
Found in packages/router/src/instructions/routing-instruction.ts - About 4 hrs to fix

    RoutingInstruction has 34 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class RoutingInstruction {
      /**
       * The component part of the routing instruction.
       */
      public component: InstructionComponent;
    Severity: Minor
    Found in packages/router/src/instructions/routing-instruction.ts - About 4 hrs to fix

      Function stringify has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

        public stringify(context: IRouterConfiguration | IRouter | IContainer, excludeEndpoint: boolean = false, endpointContext: boolean = false, shallow = false): string {
          const seps = Separators.for(context);
          let excludeCurrentEndpoint = excludeEndpoint;
          let excludeCurrentComponent = false;
      
      
      Severity: Minor
      Found in packages/router/src/instructions/routing-instruction.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 from has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        public static from(context: IRouterConfiguration | IRouter | IContainer, loadInstructions: LoadInstruction | LoadInstruction[]): RoutingInstruction[] {
          if (!Array.isArray(loadInstructions)) {
            loadInstructions = [loadInstructions];
          }
          const instructions: RoutingInstruction[] = [];
      Severity: Minor
      Found in packages/router/src/instructions/routing-instruction.ts - About 2 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 isIn has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

        public isIn(context: IRouterConfiguration | IRouter | IContainer, searchIn: RoutingInstruction[], deep: boolean): boolean {
          // Get all instructions with matching component.
          const matching = searchIn.filter(instruction => {
            // Match either routes...
            if (this.route != null || instruction.route != null) {
      Severity: Minor
      Found in packages/router/src/instructions/routing-instruction.ts - About 2 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 stringify has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public stringify(context: IRouterConfiguration | IRouter | IContainer, excludeEndpoint: boolean = false, endpointContext: boolean = false, shallow = false): string {
          const seps = Separators.for(context);
          let excludeCurrentEndpoint = excludeEndpoint;
          let excludeCurrentComponent = false;
      
      
      Severity: Minor
      Found in packages/router/src/instructions/routing-instruction.ts - About 1 hr to fix

        Function stringifyShallow has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          private stringifyShallow(context: IRouterConfiguration | IRouter | IContainer, excludeEndpoint: boolean = false, excludeComponent: boolean = false): string {
            if (this.route != null) {
              const path = this.route instanceof FoundRoute ? this.route.matching : this.route;
              return path
                .split('/')
        Severity: Minor
        Found in packages/router/src/instructions/routing-instruction.ts - 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 isIn has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public isIn(context: IRouterConfiguration | IRouter | IContainer, searchIn: RoutingInstruction[], deep: boolean): boolean {
            // Get all instructions with matching component.
            const matching = searchIn.filter(instruction => {
              // Match either routes...
              if (this.route != null || instruction.route != null) {
        Severity: Minor
        Found in packages/router/src/instructions/routing-instruction.ts - About 1 hr to fix

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

            public getTitle(navigation: Navigation): string {
              // If it's a configured route...
              if (this.route instanceof FoundRoute) {
                // ...get the configured route title.
                const routeTitle = this.route.match?.title;
          Severity: Minor
          Found in packages/router/src/instructions/routing-instruction.ts - 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 from has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public static from(context: IRouterConfiguration | IRouter | IContainer, loadInstructions: LoadInstruction | LoadInstruction[]): RoutingInstruction[] {
              if (!Array.isArray(loadInstructions)) {
                loadInstructions = [loadInstructions];
              }
              const instructions: RoutingInstruction[] = [];
          Severity: Minor
          Found in packages/router/src/instructions/routing-instruction.ts - About 1 hr to fix

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

              public clone(keepInstances: boolean = false, scopeModifier: boolean = false, shallow: boolean = false): RoutingInstruction {
                // Create a clone without instances...
                const clone = RoutingInstruction.create(
                  this.component.func ?? this.component.promise ?? this.component.type ?? this.component.name!,
                  this.endpoint.name!,
            Severity: Minor
            Found in packages/router/src/instructions/routing-instruction.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

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

              public isClearAll(context: IRouterConfiguration | IRouter): boolean {
                return this.isClear(context) && ((this.endpoint.name?.length ?? 0) === 0);
              }
            Severity: Major
            Found in packages/router/src/instructions/routing-instruction.ts and 1 other location - About 1 hr to fix
            packages/router/src/instructions/routing-instruction.ts on lines 358..360

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

            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

              public isAddAll(context: IRouterConfiguration | IRouter): boolean {
                return this.isAdd(context) && ((this.endpoint.name?.length ?? 0) === 0);
              }
            Severity: Major
            Found in packages/router/src/instructions/routing-instruction.ts and 1 other location - About 1 hr to fix
            packages/router/src/instructions/routing-instruction.ts on lines 364..366

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

            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

              public get viewport(): InstructionEndpoint | null {
                return this.endpoint.instance instanceof Viewport ||
                  this.endpoint.endpointType === null
                  ? this.endpoint
                  : null;
            Severity: Major
            Found in packages/router/src/instructions/routing-instruction.ts and 1 other location - About 1 hr to fix
            packages/router/src/instructions/routing-instruction.ts on lines 327..332

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

            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

              public get viewportScope(): InstructionEndpoint | null {
                return this.endpoint.instance instanceof ViewportScope ||
                  this.endpoint.endpointType === null
                  ? this.endpoint
                  : null;
            Severity: Major
            Found in packages/router/src/instructions/routing-instruction.ts and 1 other location - About 1 hr to fix
            packages/router/src/instructions/routing-instruction.ts on lines 316..321

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

            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

              public isClear(context: IRouterConfiguration | IRouter): boolean {
                return this.component.name === Separators.for(context).clear;
              }
            Severity: Major
            Found in packages/router/src/instructions/routing-instruction.ts and 1 other location - About 1 hr to fix
            packages/router/src/instructions/routing-instruction.ts on lines 346..348

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

            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

              public isAdd(context: IRouterConfiguration | IRouter): boolean {
                return this.component.name === Separators.for(context).add;
              }
            Severity: Major
            Found in packages/router/src/instructions/routing-instruction.ts and 1 other location - About 1 hr to fix
            packages/router/src/instructions/routing-instruction.ts on lines 352..354

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

            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