aurelia/aurelia

View on GitHub
packages/__tests__/src/router/router.with-configuration.spec.ts

Summary

Maintainability
F
1 wk
Test Coverage

File router.with-configuration.spec.ts has 256 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

Severity: Minor
Found in packages/__tests__/src/router/router.with-configuration.spec.ts - About 2 hrs to fix

    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) {
        const ctx = TestContext.create();
    
        const { container, platform } = ctx;
    
    
    Severity: Minor
    Found in packages/__tests__/src/router/router.with-configuration.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) {
          const ctx = TestContext.create();
      
          const { container, platform } = ctx;
      
      
      packages/__tests__/src/router/router.fast-switch.spec.ts on lines 41..83
      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

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

        for (const test of tests) {
          const path = test.path.replace(/@\w+/g, '');
          const url = test.url.replace(/@\w+/g, '');
          const title = test.title.replace(/@Parent/g, '');
          it(`to load route ${path} => ${url}`, async function () {
      packages/__tests__/src/router/router.with-configuration.spec.ts on lines 280..294

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

      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

        for (const test of tests) {
          const path = test.path.replace(/@\w+/g, '');
          const url = test.url.replace(/@\w+/g, '');
          const title = test.title.replace(/@Parent/g, '');
          it(`to load route (without viewports) ${path} => ${url}`, async function () {
      packages/__tests__/src/router/router.with-configuration.spec.ts on lines 215..229

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

      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

        it(`to load above routes in sequence`, async function () {
          const { platform, host, router, $teardown } = await $setup(void 0, appDependencies, appRoutes, locationCallback);
      
          for (const test of tests) {
            const path = test.path.replace(/@\w+/g, '');
      packages/__tests__/src/router/router.with-configuration.spec.ts on lines 295..308

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

      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

        it(`to load above routes (without viewports) in sequence`, async function () {
          const { platform, host, router, $teardown } = await $setup(void 0, appDependencies, appRoutes, locationCallback);
      
          for (const test of tests) {
            const path = test.path.replace(/@\w+/g, '');
      packages/__tests__/src/router/router.with-configuration.spec.ts on lines 230..243

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

      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;
      packages/__tests__/src/router/router.fallback.spec.ts on lines 17..33
      packages/__tests__/src/router/router.fast-switch.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

      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

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

        it(`to load above routes (without viewports) in sequence`, async function () {
          const { platform, host, router, $teardown } = await $setup(void 0, appDependencies, appRoutes, locationCallback);
      
          for (const test of tests) {
            await $load(test.path, router, platform);
      packages/__tests__/src/router/router.with-configuration.spec.ts on lines 203..213

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

      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

        it(`to load above routes in sequence`, async function () {
          const { platform, host, router, $teardown } = await $setup(void 0, appDependencies, appRoutes, locationCallback);
      
          for (const test of tests) {
            await $load(test.path, router, platform);
      packages/__tests__/src/router/router.with-configuration.spec.ts on lines 268..278

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

      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;
      packages/__tests__/src/router/router.fallback.spec.ts on lines 7..14
      packages/__tests__/src/router/router.fast-switch.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

      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 Parent = CustomElement.define({ name: 'parent', template: '!parent!<au-viewport name="parent"></au-viewport>' }, class {
          public static routes: IRoute[] = [
            { path: 'child-config', instructions: [{ component: 'child', viewport: 'parent' }], title: 'ChildConfig' },
          ];
        });
      packages/__tests__/src/router/router.title.spec.ts on lines 88..92

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

      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();
      };
      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/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;
          }
      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/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 5 locations. Consider refactoring.
      Open

          { path: 'parent-config/child-config', instructions: [{ component: 'parent', viewport: 'default', children: [{ component: 'child', viewport: 'parent' }] }], title: 'ParentConfigChildConfig' },
      packages/__tests__/src/router/router.title.spec.ts on lines 221..221
      packages/__tests__/src/router/router.title.spec.ts on lines 222..222
      packages/__tests__/src/router/router.title.spec.ts on lines 223..223
      packages/__tests__/src/router/router.with-configuration.spec.ts on lines 178..178

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

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

          { path: 'parent-config/child2', instructions: [{ component: 'parent', viewport: 'default', children: [{ component: 'child2', viewport: 'parent' }] }], title: 'ParentConfigChild2Config' },
      packages/__tests__/src/router/router.title.spec.ts on lines 221..221
      packages/__tests__/src/router/router.title.spec.ts on lines 222..222
      packages/__tests__/src/router/router.title.spec.ts on lines 223..223
      packages/__tests__/src/router/router.with-configuration.spec.ts on lines 177..177

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

      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