aurelia/aurelia

View on GitHub

Showing 1,020 of 5,369 total issues

Function matchSpecifiedViewport has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  private static matchSpecifiedViewport(
    routingInstructions: Collection<RoutingInstruction>,
    availableEndpoints: (Viewport | ViewportScope)[],
    matchedInstructions: RoutingInstruction[],
    disregardViewports: boolean,
Severity: Minor
Found in packages/router/src/endpoint-matcher.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 watch has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

export function watch<T extends object = object, TV extends AnyMethod = AnyMethod>(
  expressionOrPropertyAccessFn: PropertyKey | IDepCollectionFn<object>,
  changeHandlerOrCallback?: PropertyKey | IWatcherCallback<T>,
): WatchClassDecorator<T> | WatchMethodDecorator<T, TV> {
  if (expressionOrPropertyAccessFn == null) {
Severity: Minor
Found in packages/runtime-html/src/watch.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 _hydrate has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  public _hydrate(): void {
    if (this._lifecycleHooks!.hydrating != null) {
      this._lifecycleHooks!.hydrating.forEach(callHydratingHook, this);
    }
    if (this._vmHooks._hydrating) {
Severity: Minor
Found in packages/runtime-html/src/templating/controller.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 register has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  public register(container: IContainer): void {
    let existingMapping = container.get(own(ICssClassMapping));
    if (existingMapping == null) {
      container.register(
        instanceRegistration(ICssClassMapping, existingMapping = createLookup()),
Severity: Minor
Found in packages/runtime-html/src/templating/styles.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 parseArgs has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

async function parseArgs(args: string[]): Promise<null | HttpServerOptions> {
  const cmd = args[0];
  if (cmd === 'help') { return null; }

  const configuration: HttpServerOptions = new HttpServerOptions();
Severity: Minor
Found in packages-tooling/http-server/src/cli.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

File instruction-parser.spec.ts has 280 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { IRouter, RouterConfiguration, RoutingInstruction } from '@aurelia/router';
import { CustomElement, Aurelia } from '@aurelia/runtime-html';
import { assert, MockBrowserHistoryLocation, TestContext } from '@aurelia/testing';

describe('router/instruction-parser.spec.ts', function () {
Severity: Minor
Found in packages/__tests__/src/router/instruction-parser.spec.ts - About 2 hrs to fix

    Function baseCase has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const baseCase = /*@__PURE__*/(function () {
      _START_CONST_ENUM();
      const enum CharKind {
        none  = 0,
        digit = 1,
    Severity: Major
    Found in packages/kernel/src/functions.ts - About 2 hrs to fix

      Function runTest has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                    function runTest(spec: ISpec) {
                      const { t1: [t1, t1c], t2: [t2, t2c], t3: [t3, t3c], t4: [t4, t4c] } = spec;
                      spec.configure();
                      it(`'${t1}' -> '${t2}' -> '${t3}' -> '${t4}'`, async function () {
                        const { router, hia, host, tearDown } = await createFixture(Root1, A, getDefaultHIAConfig, getRouterOptions);
      Severity: Major
      Found in packages/__tests__/src/router/config-tests.spec.ts - About 2 hrs to fix

        Function verifyBindingInstructionsEqual has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function verifyBindingInstructionsEqual(actual: any, expected: any, errors?: string[], path?: string): any {
          if (path === undefined) {
            path = 'instruction';
          }
          if (errors === undefined) {
        Severity: Major
        Found in packages/testing/src/specialized-assertions.ts - About 2 hrs to fix

          Function matchEndpoints has 67 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public static matchEndpoints(routingScope: RoutingScope, instructions: RoutingInstruction[], alreadyMatched: RoutingInstruction[], disregardViewports: boolean = false): IMatchEndpointsResult {
              const matchedInstructions: RoutingInstruction[] = [];
          
              // Get all the routing scopes owned by this scope
              // TODO: Investigate if Infinity needs to be a timestamp
          Severity: Major
          Found in packages/router/src/endpoint-matcher.ts - About 2 hrs to fix

            TestRouteViewModelBase has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export abstract class TestRouteViewModelBase implements ITestRouteViewModel {
              public readonly $controller!: ICustomElementController<this>;
              public get name(): string {
                return this.$controller.definition.name;
              }
            Severity: Minor
            Found in packages/__tests__/src/router-lite/_shared/view-models.ts - About 2 hrs to fix

              TestVM has 24 functions (exceeds 20 allowed). Consider refactoring.
              Open

              abstract class TestVM implements IViewModel {
                public readonly $controller!: ICustomElementController<this>;
                public get name(): string { return this.$controller.definition.name; }
              
                public readonly bindingDI: DelayedInvoker<'binding'>;
              Severity: Minor
              Found in packages/__tests__/src/router-lite/hook-tests.spec.ts - About 2 hrs to fix

                TestRouteViewModelBase has 24 functions (exceeds 20 allowed). Consider refactoring.
                Open

                export abstract class TestRouteViewModelBase implements ITestRouteViewModel {
                  public readonly $controller!: ICustomElementController<this>;
                  public viewport: Viewport;
                  public get name(): string {
                    return this.$controller.definition.name;
                Severity: Minor
                Found in packages/__tests__/src/router/_shared/view-models.ts - About 2 hrs to fix

                  Consider simplifying this complex logical expression.
                  Open

                      if (typeof configOrPath === 'string' || configOrPath instanceof Array) {
                        const path = ensureArrayOfStrings(configOrPath);
                  
                        const redirectTo = Type?.redirectTo ?? null;
                        const caseSensitive = Type?.caseSensitive ?? false;
                  Severity: Critical
                  Found in packages/router-lite/src/route.ts - About 2 hrs to fix

                    Function getHmrCode has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const getHmrCode = (className: string): string => {
                    
                      const code = `
                        import { Metadata as $$M } from '@aurelia/metadata';
                        import { Controller as $$C, CustomElement as $$CE, IHydrationContext as $$IHC } from '@aurelia/runtime-html';
                    Severity: Major
                    Found in packages-tooling/webpack-loader/src/index.ts - About 2 hrs to fix

                      Function deactivate has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        public deactivate(
                          initiator: IHydratedController,
                          _parent: IHydratedController | null,
                        ): void | Promise<void> {
                          let prevActivation: void | Promise<void> = void 0;
                      Severity: Major
                      Found in packages/runtime-html/src/templating/controller.ts - About 2 hrs to fix

                        Function from has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                        Open

                          public static from(def: CustomElementDefinition | null, alias: string): ElementInfo | null {
                            if (def === null) {
                              return null;
                            }
                            let rec = elementInfoLookup.get(def);

                        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 jsonStringify has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export function jsonStringify(
                          o: unknown,
                          ctx: { result: string },
                        ): string {
                          if (ctx.result.length > 100) {
                        Severity: Minor
                        Found in packages/testing/src/string-manipulation.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 reduceToSingleString has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function reduceToSingleString(
                          ctx: IInspectContext,
                          output: string[],
                          base: string,
                          braces: [string, string],
                        Severity: Minor
                        Found in packages/testing/src/inspect.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 verifyEqual has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export function verifyEqual(actual: any, expected: any, depth?: number, property?: string, index?: number): any {
                          if (depth === undefined) {
                            depth = 0;
                          }
                          if (typeof expected !== 'object' || expected === null) {
                        Severity: Minor
                        Found in packages/testing/src/specialized-assertions.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

                        Severity
                        Category
                        Status
                        Source
                        Language