aurelia/aurelia

View on GitHub
packages/__tests__/src/router/routing-hook.spec.ts

Summary

Maintainability
F
1 wk
Test Coverage

File routing-hook.spec.ts has 369 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { RoutingHook, RoutingInstruction, RouterConfiguration, IRouter, Navigation } from '@aurelia/router';
import { assert, TestContext } from '@aurelia/testing';
import { CustomElement, IPlatform, Aurelia } from '@aurelia/runtime-html';
import { isNode } from '../util.js';

Severity: Minor
Found in packages/__tests__/src/router/routing-hook.spec.ts - About 4 hrs to fix

    Function createFixture has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async function createFixture(config?, App?, dependencies: any[] = [], stateSpy?) {
        const ctx = TestContext.create();
        const { container, platform, doc, wnd } = ctx;
    
        const host = doc.createElement('div');
    Severity: Minor
    Found in packages/__tests__/src/router/routing-hook.spec.ts - About 1 hr to fix

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

        it('can transform from viewport instructions to string to url', async function () {
          let locationPath: string;
          const locationCallback = (type, data, title, path) => {
            // console.log(type, data, title, path);
            locationPath = path;
      Severity: Major
      Found in packages/__tests__/src/router/routing-hook.spec.ts and 2 other locations - About 2 days to fix
      packages/__tests__/src/router/routing-hook.spec.ts on lines 396..429
      packages/__tests__/src/router/routing-hook.spec.ts on lines 431..463

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

      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 3 locations. Consider refactoring.
      Open

        it('can transform from viewport instructions to url', async function () {
          let locationPath: string;
          const locationCallback = (type, data, title, path) => {
            // console.log(type, data, title, path);
            locationPath = path;
      Severity: Major
      Found in packages/__tests__/src/router/routing-hook.spec.ts and 2 other locations - About 2 days to fix
      packages/__tests__/src/router/routing-hook.spec.ts on lines 431..463
      packages/__tests__/src/router/routing-hook.spec.ts on lines 465..497

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

      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 3 locations. Consider refactoring.
      Open

        it('can transform from string to url', async function () {
          let locationPath: string;
          const locationCallback = (type, data, title, path) => {
            // console.log(type, data, title, path);
            locationPath = path;
      Severity: Major
      Found in packages/__tests__/src/router/routing-hook.spec.ts and 2 other locations - About 2 days to fix
      packages/__tests__/src/router/routing-hook.spec.ts on lines 396..429
      packages/__tests__/src/router/routing-hook.spec.ts on lines 465..497

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

      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

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

            input.length > 0
              ? typeof input === 'string' ? [RoutingInstruction.create(`hooked-${input}`) as RoutingInstruction] : `hooked-${input[0].component.name}`
              : input;
      Severity: Major
      Found in packages/__tests__/src/router/routing-hook.spec.ts and 1 other location - About 1 hr to fix
      packages/__tests__/src/router/routing-hook.spec.ts on lines 293..295

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

      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

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

            Promise.resolve(input.length > 0
              ? typeof input === 'string' ? [RoutingInstruction.create(`hooked-${input}`) as RoutingInstruction] : `hooked-${input[0].component.name}`
              : input);
      Severity: Major
      Found in packages/__tests__/src/router/routing-hook.spec.ts and 1 other location - About 1 hr to fix
      packages/__tests__/src/router/routing-hook.spec.ts on lines 268..270

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

      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

      Identical blocks of code found in 10 locations. Consider refactoring.
      Open

        const $load = async (path: string, router: IRouter, platform: IPlatform) => {
          await router.load(path);
          platform.domWriteQueue.flush();
        };
      Severity: Major
      Found in packages/__tests__/src/router/routing-hook.spec.ts and 9 other locations - About 1 hr to fix
      packages/__tests__/src/router/router.fast-switch.spec.ts on lines 196..199
      packages/__tests__/src/router/router.lifecycle-hooks.spec.ts on lines 482..485
      packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 240..243
      packages/__tests__/src/router/router.local-deps.spec.ts on lines 257..260
      packages/__tests__/src/router/router.redirect.spec.ts on lines 230..233
      packages/__tests__/src/router/router.spec.ts on lines 955..958
      packages/__tests__/src/router/router.title.spec.ts on lines 251..254
      packages/__tests__/src/router/router.viewport-scope.spec.ts on lines 127..130
      packages/__tests__/src/router/router.with-configuration.spec.ts on lines 311..314

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

      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 4 locations. Consider refactoring.
      Open

          RouterConfiguration.for(router).addHook((url: string, navigationInstruction: Navigation) => Promise.resolve(`hooked:${url}`),
            { type: 'transformFromUrl' });
      Severity: Major
      Found in packages/__tests__/src/router/routing-hook.spec.ts and 3 other locations - About 1 hr to fix
      packages/__tests__/src/router/routing-hook.spec.ts on lines 97..98
      packages/__tests__/src/router/routing-hook.spec.ts on lines 118..119
      packages/__tests__/src/router/routing-hook.spec.ts on lines 186..187

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

      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 4 locations. Consider refactoring.
      Open

          RouterConfiguration.for(router).addHook((url: string, navigationInstruction: Navigation) => Promise.resolve(`hooked-${url}`),
            { type: 'transformToUrl' });
      Severity: Major
      Found in packages/__tests__/src/router/routing-hook.spec.ts and 3 other locations - About 1 hr to fix
      packages/__tests__/src/router/routing-hook.spec.ts on lines 95..96
      packages/__tests__/src/router/routing-hook.spec.ts on lines 97..98
      packages/__tests__/src/router/routing-hook.spec.ts on lines 118..119

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

      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 4 locations. Consider refactoring.
      Open

          RouterConfiguration.for(router).addHook((url: string, navigationInstruction: Navigation) => Promise.resolve(`hooked2:${url}`),
            { type: 'transformFromUrl' });
      Severity: Major
      Found in packages/__tests__/src/router/routing-hook.spec.ts and 3 other locations - About 1 hr to fix
      packages/__tests__/src/router/routing-hook.spec.ts on lines 95..96
      packages/__tests__/src/router/routing-hook.spec.ts on lines 118..119
      packages/__tests__/src/router/routing-hook.spec.ts on lines 186..187

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

      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 4 locations. Consider refactoring.
      Open

          RouterConfiguration.for(router).addHook((url: string, navigationInstruction: Navigation) => Promise.resolve(`hooked:${url}`),
            { type: 'transformFromUrl' });
      Severity: Major
      Found in packages/__tests__/src/router/routing-hook.spec.ts and 3 other locations - About 1 hr to fix
      packages/__tests__/src/router/routing-hook.spec.ts on lines 95..96
      packages/__tests__/src/router/routing-hook.spec.ts on lines 97..98
      packages/__tests__/src/router/routing-hook.spec.ts on lines 186..187

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

      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 10 locations. Consider refactoring.
      Open

        function unspyNavigationStates(router, _push, _replace) {
          if (_push) {
            router.viewer.history.pushState = _push;
            router.viewer.history.replaceState = _replace;
          }
      Severity: Major
      Found in packages/__tests__/src/router/routing-hook.spec.ts and 9 other locations - About 1 hr to fix
      packages/__tests__/src/router/router.fallback.spec.ts on lines 34..39
      packages/__tests__/src/router/router.fast-switch.spec.ts on lines 34..39
      packages/__tests__/src/router/router.lifecycle-hooks.spec.ts on lines 34..39
      packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 34..39
      packages/__tests__/src/router/router.redirect.spec.ts on lines 34..39
      packages/__tests__/src/router/router.spec.ts on lines 34..39
      packages/__tests__/src/router/router.title.spec.ts on lines 34..39
      packages/__tests__/src/router/router.viewport-scope.spec.ts on lines 34..39
      packages/__tests__/src/router/router.with-configuration.spec.ts on lines 34..39

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

      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

          RouterConfiguration.for(router).addHook((routingInstructions: RoutingInstruction[], navigationInstruction: Navigation) => Promise.resolve(true),
            { type: 'beforeNavigation' });
      Severity: Minor
      Found in packages/__tests__/src/router/routing-hook.spec.ts and 1 other location - About 55 mins to fix
      packages/__tests__/src/router/routing-hook.spec.ts on lines 257..258

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

      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

          RouterConfiguration.for(router).addHook((routingInstructions: RoutingInstruction[], navigationInstruction: Navigation) => Promise.resolve(false),
            { type: 'beforeNavigation' });
      Severity: Minor
      Found in packages/__tests__/src/router/routing-hook.spec.ts and 1 other location - About 55 mins to fix
      packages/__tests__/src/router/routing-hook.spec.ts on lines 243..244

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

      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