NGO-DB/ndb-core

View on GitHub

Showing 287 of 288 total issues

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

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

          {
            header: {
              label: "Total # of old children",
              groupedBy: [],
              result: 5,
Severity: Major
Found in src/app/features/reporting/data-aggregation.service.spec.ts and 1 other location - About 2 hrs to fix
src/app/features/reporting/reporting/reporting.component.spec.ts on lines 131..151

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

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 schools", groupedBy: [], result: 3 },
        subRows: [
          {
            header: {
src/app/features/reporting/data-aggregation.service.spec.ts on lines 557..581

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

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 transformRawDataToEntities has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

  async transformRawDataToEntities(
    rawData: any[],
    entityType: string,
    columnMapping: ColumnMapping[],
  ): Promise<Entity[]> {
Severity: Minor
Found in src/app/core/import/import.service.ts - About 2 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

Entity has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

export class Entity {
  /**
   * The entity's type.
   * In classes extending Entity this is usually overridden by the class annotation `@DatabaseEntity('NewEntity')`.
   * The type needs to be used as routing path in lower case. The routing path can be defined in the configuration file.
Severity: Minor
Found in src/app/core/entity/model/entity.ts - About 2 hrs to fix

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

    import { fakeAsync, TestBed, tick, waitForAsync } from "@angular/core/testing";
    
    import { AbilityService } from "./ability.service";
    import { BehaviorSubject, Subject } from "rxjs";
    import { Child } from "../../../child-dev-project/children/model/child";
    Severity: Minor
    Found in src/app/core/permissions/ability/ability.service.spec.ts - About 2 hrs to fix

      Function generate has 70 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 2 hrs to fix

        File entities-table.component.ts has 278 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import {
          AfterViewInit,
          Component,
          EventEmitter,
          Input,

          BasicAutocompleteComponent has 24 functions (exceeds 20 allowed). Consider refactoring.
          Open

          @Component({
            selector: "app-basic-autocomplete",
            templateUrl: "basic-autocomplete.component.html",
            styleUrls: ["./basic-autocomplete.component.scss"],
            providers: [

            File admin-entity-field.component.ts has 274 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import {
              Component,
              Inject,
              Input,
              OnChanges,

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

              import { fakeAsync, TestBed, tick } from "@angular/core/testing";
              import { EntityActionsService } from "./entity-actions.service";
              import { EntityMapperService } from "../entity-mapper/entity-mapper.service";
              import {
                MatSnackBar,
              Severity: Minor
              Found in src/app/core/entity/entity-actions/entity-actions.service.spec.ts - About 2 hrs to fix

                PouchDatabase has 23 functions (exceeds 20 allowed). Consider refactoring.
                Open

                @Injectable()
                export class PouchDatabase extends Database {
                  /**
                   * Small helper function which creates a database with in-memory PouchDB initialized
                   */
                Severity: Minor
                Found in src/app/core/database/pouch-database.ts - About 2 hrs to fix

                  Function delete has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async delete<E extends Entity>(
                      entityParam: E | E[],
                      navigate: boolean = false,
                    ): Promise<boolean> {
                      let textForDeleteEntity = "";
                  Severity: Major
                  Found in src/app/core/entity/entity-actions/entity-actions.service.ts - About 2 hrs to fix

                    CustomFormControlDirective has 22 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    @Directive()
                    export abstract class CustomFormControlDirective<T>
                      implements ControlValueAccessor, MatFormFieldControl<T>, OnDestroy, DoCheck
                    {
                      static nextId = 0;

                      File entity-list.component.ts has 263 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import {
                        Component,
                        EventEmitter,
                        Input,
                        OnChanges,
                      Severity: Minor
                      Found in src/app/core/entity-list/entity-list/entity-list.component.ts - About 2 hrs to fix

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

                          it("should mark relation with end date in the future as active", () => {
                            const relation = new TimePeriod();
                            relation.start = moment().subtract(1, "week").toDate();
                            relation.end = moment().add(1, "day").toDate();
                            expect(relation.isActive).toBeTrue();
                        src/app/core/entity-details/related-time-period-entities/time-period.spec.ts on lines 42..47

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

                        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 mark relation with end date in the past as inactive", () => {
                            const relation = new TimePeriod();
                            relation.start = moment().subtract(1, "week").toDate();
                            relation.end = moment().subtract(1, "day").toDate();
                            expect(relation.isActive).toBeFalse();
                        src/app/core/entity-details/related-time-period-entities/time-period.spec.ts on lines 49..54

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

                        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 anonymize has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          async anonymize<E extends Entity>(entityParam: E | E[]) {
                            let entities = Array.isArray(entityParam) ? entityParam : [entityParam];
                            let textForAnonymizeEntity = "";
                        
                            if (entities.length > 1) {
                        Severity: Major
                        Found in src/app/core/entity/entity-actions/entity-actions.service.ts - About 2 hrs to fix

                          QueryService has 21 functions (exceeds 20 allowed). Consider refactoring.
                          Open

                          @Injectable({
                            providedIn: "root",
                          })
                          export class QueryService {
                            private entities: { [type: string]: { [id: string]: Entity } } = {};
                          Severity: Minor
                          Found in src/app/core/export/query.service.ts - About 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language