aurelia/aurelia

View on GitHub
packages/__tests__/src/3-runtime-html/observer-locator.spec.ts

Summary

Maintainability
F
6 days
Test Coverage

File observer-locator.spec.ts has 325 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { CollectionLengthObserver, CollectionSizeObserver, ComputedObserver, DirtyCheckProperty, PrimitiveObserver, PropertyAccessor, SetterObserver } from '@aurelia/runtime';
import {
  AttributeNSAccessor,
  CheckedObserver,
  ClassAttributeAccessor,
Severity: Minor
Found in packages/__tests__/src/3-runtime-html/observer-locator.spec.ts - About 3 hrs to fix

    Avoid deeply nested control flow statements.
    Open

              for (const enumerable of [true, false]) {
                for (const hasOverrides of [true, false]) {
                  for (const isVolatile of hasOverrides ? [true, false, undefined] : [false]) {
                    for (const hasAdapterObserver of [true, false]) {
                      for (const adapterIsDefined of hasAdapterObserver ? [true, false] : [false]) {
    Severity: Major
    Found in packages/__tests__/src/3-runtime-html/observer-locator.spec.ts - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  if (adapterIsDefined) {
                    sut.addAdapter({getObserver() {
                      return dummyObserver;
                    }});
                  } else {
      Severity: Major
      Found in packages/__tests__/src/3-runtime-html/observer-locator.spec.ts - About 45 mins to fix

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

          for (const markup of [
            `<div _:=""></div>`,
            `<div _4:=""></div>`,
            `<div a:=""></div>`,
            `<div _:a=""></div>`,
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 65..81
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 100..122

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

        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 (const markup of [
            `<a href="foo"></a>`,
            `<img src="foo"></img>`,
            `<div data-=""></div>`,
            `<div data-a=""></div>`,
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 82..98
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 100..122

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

        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 (const markup of [
            `<a foo="foo"></a>`,
            `<img foo="foo"></img>`,
            `<div _=""></div>`,
            `<div 4=""></div>`,
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 65..81
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 82..98

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

        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

          it(`getObserver() - Set.foo - returns SetObserver`, function () {
            const { sut } = createFixture();
            const obj = new Set();
            const actual = sut.getObserver(obj, 'foo');
            assert.strictEqual(actual.constructor.name, SetterObserver.name, `actual.constructor.name`);
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 323..329
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 331..337
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 339..345

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

        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

          it(`getObserver() - Map.foo - returns MapObserver`, function () {
            const { sut } = createFixture();
            const obj = new Map();
            const actual = sut.getObserver(obj, 'foo');
            assert.strictEqual(actual.constructor.name, SetterObserver.name, `actual.constructor.name`);
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 315..321
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 323..329
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 339..345

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

        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

          it(`getObserver() - Map.size - returns MapObserver`, function () {
            const { sut } = createFixture();
            const obj = new Map();
            const actual = sut.getObserver(obj, 'size');
            assert.strictEqual(actual.constructor.name, CollectionSizeObserver.name, `actual.constructor.name`);
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 315..321
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 323..329
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 331..337

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

        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

          it(`getObserver() - Set.size - returns SetObserver`, function () {
            const { sut } = createFixture();
            const obj = new Set();
            const actual = sut.getObserver(obj, 'size');
            assert.strictEqual(actual.constructor.name, CollectionSizeObserver.name, `actual.constructor.name`);
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 315..321
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 331..337
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 339..345

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

        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(`getObserver() - Array.length - returns ArrayObserver`, function () {
            const { sut } = createFixture();
            const obj = [];
            const actual = sut.getObserver(obj, 'length');
            assert.strictEqual(actual.constructor.name, CollectionLengthObserver.name, `actual.constructor.name`);
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 299..305

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

        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(`getObserver() - Array.foo - returns ArrayObserver`, function () {
            const { sut } = createFixture();
            const obj = [];
            const actual = sut.getObserver(obj, 'foo');
            assert.strictEqual(actual.constructor.name, SetterObserver.name, `actual.constructor.name`);
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 307..313

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

        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(_`getObserver() - {} - twice in a row different property - returns different observer`, function () {
            const { sut } = createFixture();
            const obj = {};
            const expected = sut.getObserver(obj, 'foo');
            const actual = sut.getObserver(obj, 'bar');
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 148..154

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

        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(_`getObserver() - {} - twice in a row - reuses existing observer`, function () {
            const { sut } = createFixture();
            const obj = {};
            const expected = sut.getObserver(obj, 'foo');
            const actual = sut.getObserver(obj, 'foo');
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 156..162

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

        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

                  if (hasAdapterObserver) {
                    if (adapterIsDefined) {
                      sut.addAdapter({getObserver() {
                        return dummyObserver;
                      }});
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 202..212

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

        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

                              if (hasAdapterObserver) {
                                if (adapterIsDefined) {
                                  sut.addAdapter({getObserver() {
                                    return dummyObserver;
                                  }});
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 274..284

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

        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

                                  if (!configurable) {
                                    assert.strictEqual(actual.constructor.name, DirtyCheckProperty.name, `actual.constructor.name`);
                                    assert.instanceOf(actual, DirtyCheckProperty, `actual`);
                                  } else {
                                    if (hasGetObserver) {
        Severity: Minor
        Found in packages/__tests__/src/3-runtime-html/observer-locator.spec.ts and 1 other location - About 50 mins to fix
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 233..249

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

        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

                                } else if (!(hasGetter || hasSetter)) {
                                  assert.strictEqual(actual.constructor.name, SetterObserver.name, `actual.constructor.name`);
                                  assert.instanceOf(actual, SetterObserver, `actual`);
                                } else if (hasGetObserver) {
                                  assert.strictEqual(actual, dummyObserver, `actual`);
        Severity: Minor
        Found in packages/__tests__/src/3-runtime-html/observer-locator.spec.ts and 1 other location - About 50 mins to fix
        packages/__tests__/src/3-runtime-html/observer-locator.spec.ts on lines 239..248

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

        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