aurelia/aurelia

View on GitHub
packages/__tests__/src/router/router.fast-switch.spec.ts

Summary

Maintainability
F
5 days
Test Coverage

Function $setup has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async function $setup(
    config?: IRouterOptions,
    dependencies: any[] = [],
    routes: IRoute[] = [],
    stateSpy: NavigationStateCallback = void 0,
Severity: Minor
Found in packages/__tests__/src/router/router.fast-switch.spec.ts - About 1 hr to fix

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

      async function $setup(
        config?: IRouterOptions,
        dependencies: any[] = [],
        routes: IRoute[] = [],
        stateSpy: NavigationStateCallback = void 0,
    Severity: Major
    Found in packages/__tests__/src/router/router.fast-switch.spec.ts and 6 other locations - About 2 days to fix
    packages/__tests__/src/router/router.lifecycle-hooks.spec.ts on lines 41..83
    packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 41..78
    packages/__tests__/src/router/router.redirect.spec.ts on lines 41..78
    packages/__tests__/src/router/router.title.spec.ts on lines 41..78
    packages/__tests__/src/router/router.viewport-scope.spec.ts on lines 41..78
    packages/__tests__/src/router/router.with-configuration.spec.ts on lines 41..78

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

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

      function spyNavigationStates(router: IRouter, spy: NavigationStateCallback) {
        let _pushState;
        let _replaceState;
        if (spy) {
          _pushState = router.viewer.location.pushState;
    Severity: Major
    Found in packages/__tests__/src/router/router.fast-switch.spec.ts and 8 other locations - About 1 day to fix
    packages/__tests__/src/router/router.fallback.spec.ts on lines 17..33
    packages/__tests__/src/router/router.lifecycle-hooks.spec.ts on lines 17..33
    packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 17..33
    packages/__tests__/src/router/router.redirect.spec.ts on lines 17..33
    packages/__tests__/src/router/router.spec.ts on lines 17..33
    packages/__tests__/src/router/router.title.spec.ts on lines 17..33
    packages/__tests__/src/router/router.viewport-scope.spec.ts on lines 17..33
    packages/__tests__/src/router/router.with-configuration.spec.ts on lines 17..33

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

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

      function getModifiedRouter(container: IContainer) {
        const router = container.get(IRouter) as IRouter;
        const mockBrowserHistoryLocation = new MockBrowserHistoryLocation();
        mockBrowserHistoryLocation.changeCallback = async (ev) => { router.viewer.handlePopStateEvent(ev); };
        router.viewer.history = mockBrowserHistoryLocation as any;
    Severity: Major
    Found in packages/__tests__/src/router/router.fast-switch.spec.ts and 8 other locations - About 4 hrs to fix
    packages/__tests__/src/router/router.fallback.spec.ts on lines 7..14
    packages/__tests__/src/router/router.lifecycle-hooks.spec.ts on lines 7..14
    packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 7..14
    packages/__tests__/src/router/router.redirect.spec.ts on lines 7..14
    packages/__tests__/src/router/router.spec.ts on lines 7..14
    packages/__tests__/src/router/router.title.spec.ts on lines 7..14
    packages/__tests__/src/router/router.viewport-scope.spec.ts on lines 7..14
    packages/__tests__/src/router/router.with-configuration.spec.ts on lines 7..14

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

    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

    const $goBack = async (router: IRouter, platform?: IPlatform) => {
      await router.viewer.history.back();
      if (platform) {
        platform.domQueue.flush();
        await platform.domQueue.yield();
    Severity: Major
    Found in packages/__tests__/src/router/router.fast-switch.spec.ts and 1 other location - About 2 hrs to fix
    packages/__tests__/src/router/router.fast-switch.spec.ts on lines 209..215

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

    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

    const $goForward = async (router: IRouter, platform?: IPlatform) => {
      await router.viewer.history.forward();
      if (platform) {
        platform.domQueue.flush();
        await platform.domQueue.yield();
    Severity: Major
    Found in packages/__tests__/src/router/router.fast-switch.spec.ts and 1 other location - About 2 hrs to fix
    packages/__tests__/src/router/router.fast-switch.spec.ts on lines 201..207

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

    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.domQueue.flush();
    };
    Severity: Major
    Found in packages/__tests__/src/router/router.fast-switch.spec.ts and 9 other locations - About 1 hr to fix
    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
    packages/__tests__/src/router/routing-hook.spec.ts on lines 76..79

    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.location.pushState = _push;
          router.viewer.location.replaceState = _replace;
        }
    Severity: Major
    Found in packages/__tests__/src/router/router.fast-switch.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.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
    packages/__tests__/src/router/routing-hook.spec.ts on lines 70..75

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

        const DefaultPage = CustomElement.define({ name: 'defaultpage', template: '!root!' }, class {
          async loading() {
            return new Promise(resolve => setTimeout(resolve, 20));
          }
        });
    Severity: Major
    Found in packages/__tests__/src/router/router.fast-switch.spec.ts and 2 other locations - About 55 mins to fix
    packages/__tests__/src/router/router.fast-switch.spec.ts on lines 99..103
    packages/__tests__/src/router/router.fast-switch.spec.ts on lines 104..108

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

    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

        const One = CustomElement.define({ name: 'one', template: '!one!' }, class {
          async loading() {
            return new Promise(resolve => setTimeout(resolve, 20));
          }
        });
    Severity: Major
    Found in packages/__tests__/src/router/router.fast-switch.spec.ts and 2 other locations - About 55 mins to fix
    packages/__tests__/src/router/router.fast-switch.spec.ts on lines 94..98
    packages/__tests__/src/router/router.fast-switch.spec.ts on lines 104..108

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

    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

        const Two = CustomElement.define({ name: 'two', template: '!two!', }, class {
          async loading() {
            return new Promise(resolve => setTimeout(resolve, 20));
          }
        });
    Severity: Major
    Found in packages/__tests__/src/router/router.fast-switch.spec.ts and 2 other locations - About 55 mins to fix
    packages/__tests__/src/router/router.fast-switch.spec.ts on lines 94..98
    packages/__tests__/src/router/router.fast-switch.spec.ts on lines 99..103

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

    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

              assert.ok(host.textContent === '!one!' || host.textContent === '!two!', `${host.textContent} != !one! or !two!`);
    Severity: Minor
    Found in packages/__tests__/src/router/router.fast-switch.spec.ts and 1 other location - About 30 mins to fix
    packages/__tests__/src/router/router.fast-switch.spec.ts on lines 148..148

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

    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

              assert.ok(host.textContent === '!one!' || host.textContent === '!two!', `${host.textContent} != !one! or !two!`);
    Severity: Minor
    Found in packages/__tests__/src/router/router.fast-switch.spec.ts and 1 other location - About 30 mins to fix
    packages/__tests__/src/router/router.fast-switch.spec.ts on lines 187..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 45.

    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