aurelia/aurelia

View on GitHub
packages/__tests__/src/router/router.link-click-navigation.spec.ts

Summary

Maintainability
F
1 wk
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) {
    const ctx = TestContext.create();

    const { container, platform } = ctx;

Severity: Minor
Found in packages/__tests__/src/router/router.link-click-navigation.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.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 3 locations. Consider refactoring.
    Open

      for (let i = 0; i < tests.length; i++) {
        const test = tests[i];
        it(`for "${test.load}"`, async function () {
          const { platform, host, router, $teardown } = await $setup({}, [Nav, One, Two, OneRoute, TwoRoute], routes);
    
    
    packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 186..206
    packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 217..237

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

    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

      for (let i = 0; i < attributesTests.length; i++) {
        const test = attributesTests[i];
        it(`for "${test.load}"`, async function () {
          const { platform, host, router, $teardown } = await $setup({}, [NavAttributes, One, Two, OneRoute, TwoRoute], routes);
    
    
    packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 155..175
    packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 186..206

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

    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

      for (let i = 0; i < bindTests.length; i++) {
        const test = bindTests[i];
        it(`for "${test.load}"`, async function () {
          const { platform, host, router, $teardown } = await $setup({}, [NavBind, One, Two, OneRoute, TwoRoute], routes);
    
    
    packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 155..175
    packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 217..237

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

    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.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;
    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.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 TwoRoute = CustomElement.define({ name: 'two-route', template: '!two-route${id}!' }, class {
        public static parameters = ['id'];
        public id: string;
        public loading(params) { if (params.id != null) { this.id = `:${params.id}`; } }
      });
    packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 134..138

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

    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 Two = CustomElement.define({ name: 'two', template: '!two${id}!' }, class {
        public static parameters = ['id'];
        public id: string;
        public loading(params) { if (params.id != null) { this.id = `:${params.id}`; } }
      });
    packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 140..144

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

    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

      const tests = [
        { load: 'one', result: '!one!', },
        { load: 'two(123)', result: '!two:123!', },
        { load: 'two(456)', result: '!two:456!', },
        { load: 'route-one', result: '!one-route!', },
    packages/__tests__/src/3-runtime-html/target-observers.spec.ts on lines 37..44
    packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 177..184
    packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 208..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 80.

    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

      const attributesTests = [
        { load: 'attributes: one', result: '!one!', },
        { load: 'attributes: two(123)', result: '!two:123!', },
        { load: 'attributes: two(456)', result: '!two:456!', },
        { load: 'attributes: route-one', result: '!one-route!', },
    packages/__tests__/src/3-runtime-html/target-observers.spec.ts on lines 37..44
    packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 146..153
    packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 177..184

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

    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

      const bindTests = [
        { load: 'bind: one', result: '!one!', },
        { load: 'bind: two(123)', result: '!two:123!', },
        { load: 'bind: two(456)', result: '!two:456!', },
        { load: 'bind: route-one', result: '!one-route!', },
    packages/__tests__/src/3-runtime-html/target-observers.spec.ts on lines 37..44
    packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 146..153
    packages/__tests__/src/router/router.link-click-navigation.spec.ts on lines 208..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 80.

    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.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;
        }
    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.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

    There are no issues that match your filters.

    Category
    Status