NGO-DB/ndb-core

View on GitHub

Showing 281 of 282 total issues

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

    if (entities.length > 1) {
      textForDeleteEntity =
        $localize`:Demonstrative pronoun plural:these` +
        " " +
        entities.length +
Severity: Major
Found in src/app/core/entity/entity-actions/entity-actions.service.ts and 1 other location - About 3 hrs to fix
src/app/core/entity/entity-actions/entity-actions.service.ts on lines 151..166

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

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

File query.service.ts has 320 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Injectable } from "@angular/core";
import { Entity, EntityConstructor } from "../entity/model/entity";
import { Note } from "../../child-dev-project/notes/model/note";
import { EventNote } from "../../child-dev-project/attendance/model/event-note";
import { EntityMapperService } from "../entity/entity-mapper/entity-mapper.service";
Severity: Minor
Found in src/app/core/export/query.service.ts - About 3 hrs to fix

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

                  {
                    header: {
                      label: "Total # of children",
                      groupedBy: [
                        { property: "gender", value: genders[1] },
    Severity: Major
    Found in src/app/features/reporting/data-aggregation.service.spec.ts and 1 other location - About 3 hrs to fix
    src/app/features/reporting/data-aggregation.service.spec.ts on lines 490..513

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

    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

                  {
                    header: {
                      label: "Total # of children",
                      groupedBy: [
                        { property: "gender", value: genders[1] },
    Severity: Major
    Found in src/app/features/reporting/data-aggregation.service.spec.ts and 1 other location - About 3 hrs to fix
    src/app/features/reporting/data-aggregation.service.spec.ts on lines 466..489

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

    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

    export const childrenComponents: ComponentTuple[] = [
      [
        "ChildrenList",
        () =>
          import("./children-list/children-list.component").then(
    Severity: Major
    Found in src/app/child-dev-project/children/children-components.ts and 1 other location - About 3 hrs to fix
    src/app/child-dev-project/schools/schools-components.ts on lines 3..32

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

    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

    export const schoolsComponents: ComponentTuple[] = [
      [
        "PreviousSchools",
        () =>
          import("./child-school-overview/child-school-overview.component").then(
    Severity: Major
    Found in src/app/child-dev-project/schools/schools-components.ts and 1 other location - About 3 hrs to fix
    src/app/child-dev-project/children/children-components.ts on lines 3..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 127.

    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("should not suggest auto delete conflicts if no strategy applies", () => {
        const testDoc = { _id: "abc", _rev: "rev-1a", value: 1 };
        const testConflictDoc = { _id: "abc", _rev: "rev-1b", value: 2 };
    
        mockResolutionStrategy.autoDeleteConflictingRevision.and.returnValue(false);
    src/app/features/conflict-resolution/auto-resolution/auto-resolution.service.spec.ts on lines 35..50

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

    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("should suggest auto delete conflict if a strategy applies", () => {
        const testDoc = { _id: "abc", _rev: "rev-1a", value: 1 };
        const testConflictDoc = { _id: "abc", _rev: "rev-1b", value: 2 };
    
        mockResolutionStrategy.autoDeleteConflictingRevision.and.returnValue(true);
    src/app/features/conflict-resolution/auto-resolution/auto-resolution.service.spec.ts on lines 52..67

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

    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

    Function generate has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      async generate<T extends Entity>(
        filterConfigs: FilterConfig[],
        entityConstructor: EntityConstructor<T>,
        data: T[],
        onlyShowUsedOptions = false,
    Severity: Minor
    Found in src/app/core/filter/filter-generator/filter-generator.service.ts - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

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

      it("correctly saves an array of homogeneous entities", async () => {
        const result = await entityMapper.saveAll([
          new MockEntityA("1"),
          new MockEntityB("10"),
          new MockEntityA("42"),
    src/app/core/entity/entity-mapper/entity-mapper.service.spec.ts on lines 212..232

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

    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("correctly saves an array of heterogeneous entities", async () => {
        const result = await entityMapper.saveAll([
          new MockEntityA("1"),
          new MockEntityA("10"),
          new MockEntityA("42"),
    src/app/core/entity/entity-mapper/entity-mapper.service.spec.ts on lines 234..254

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

    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

    File children.service.spec.ts has 302 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { ChildrenService } from "./children.service";
    import { EntityMapperService } from "../../core/entity/entity-mapper/entity-mapper.service";
    import { ChildSchoolRelation } from "./model/childSchoolRelation";
    import { Child } from "./model/child";
    import { School } from "../schools/model/school";
    Severity: Minor
    Found in src/app/child-dev-project/children/children.service.spec.ts - About 3 hrs to fix

      File attendance.service.spec.ts has 302 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { TestBed, waitForAsync } from "@angular/core/testing";
      
      import { AttendanceService } from "./attendance.service";
      import { EntityMapperService } from "../../core/entity/entity-mapper/entity-mapper.service";
      import { Database } from "../../core/database/database";
      Severity: Minor
      Found in src/app/child-dev-project/attendance/attendance.service.spec.ts - About 3 hrs to fix

        File couchdb-file.service.spec.ts has 296 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { fakeAsync, TestBed, tick } from "@angular/core/testing";
        
        import { CouchdbFileService } from "./couchdb-file.service";
        import {
          HttpClient,
        Severity: Minor
        Found in src/app/features/file/couchdb-file.service.spec.ts - About 3 hrs to fix

          File config-import-parser.service.ts has 294 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { Injectable } from "@angular/core";
          import {
            EntityListConfig,
            GroupConfig,
          } from "../../core/entity-list/EntityListConfig";
          Severity: Minor
          Found in src/app/features/config-setup/config-import-parser.service.ts - About 3 hrs to fix

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

              it("should not cascade delete the 'composite'-type entity that still references additional other entities but remove id", async () => {
                const result = await service.deleteEntity(
                  ENTITIES.ReferencedAsOneOfMultipleComposites1,
                );
            
            
            src/app/core/entity/entity-actions/entity-delete.service.spec.ts on lines 133..153

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

            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("should not cascade delete the 'aggregate'-type entity that only references the entity user acts on but remove id", async () => {
                const result = await service.deleteEntity(
                  ENTITIES.ReferencingAggregate_ref,
                );
            
            
            src/app/core/entity/entity-actions/entity-delete.service.spec.ts on lines 84..110

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

            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

            File config.service.spec.ts has 293 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { fakeAsync, TestBed, tick, waitForAsync } from "@angular/core/testing";
            import { ConfigService } from "./config.service";
            import { EntityMapperService } from "../entity/entity-mapper/entity-mapper.service";
            import { Config } from "./config";
            import { firstValueFrom, Subject } from "rxjs";
            Severity: Minor
            Found in src/app/core/config/config.service.spec.ts - About 3 hrs to fix

              Function generate has 75 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async generate<T extends Entity>(
                  filterConfigs: FilterConfig[],
                  entityConstructor: EntityConstructor<T>,
                  data: T[],
                  onlyShowUsedOptions = false,
              Severity: Major
              Found in src/app/core/filter/filter-generator/filter-generator.service.ts - About 3 hrs to fix

                File entity-form.service.spec.ts has 290 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { TestBed, waitForAsync } from "@angular/core/testing";
                
                import { EntityFormService } from "./entity-form.service";
                import {
                  FormControl,
                  Severity
                  Category
                  Status
                  Source
                  Language