Aam-Digital/ndb-core

View on GitHub

Showing 282 of 313 total issues

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

    TestBed.configureTestingModule({
      imports: [EntityDetailsComponent, MockedTestingModule.withState()],
      providers: [
        { provide: ChildrenService, useValue: mockChildrenService },
        { provide: EntityActionsService, useValue: mockEntityRemoveService },
src/app/core/admin/admin-overview/admin-overview.component.spec.ts on lines 48..58
src/app/core/ui/navigation/navigation/navigation.component.spec.ts on lines 57..64

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

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

    expect(report).toEqual([
      {
        header: { label: "christians", groupedBy: [], result: 1 },
        subRows: [],
      },
Severity: Major
Found in src/app/features/reporting/data-aggregation.service.spec.ts and 1 other location - About 1 hr to fix
src/app/features/reporting/data-aggregation.service.spec.ts on lines 596..602

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

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

    expect(result).toEqual([
      {
        header: { label: "!!", groupedBy: [], result: 1 },
        subRows: [],
      },
Severity: Major
Found in src/app/features/reporting/data-aggregation.service.spec.ts and 1 other location - About 1 hr to fix
src/app/features/reporting/data-aggregation.service.spec.ts on lines 56..62

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

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

    TestBed.configureTestingModule({
      imports: [NavigationComponent, MockedTestingModule.withState()],
      providers: [
        { provide: UserRoleGuard, useValue: mockRoleGuard },
        { provide: EntityPermissionGuard, useValue: mockEntityGuard },
src/app/core/admin/admin-overview/admin-overview.component.spec.ts on lines 48..58
src/app/core/entity-details/entity-details/entity-details.component.spec.ts on lines 57..64

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

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

    TestBed.configureTestingModule({
      imports: [AdminOverviewComponent, MockedTestingModule.withState()],
      providers: [
        { provide: BackupService, useValue: mockBackupService },
        {
src/app/core/entity-details/entity-details/entity-details.component.spec.ts on lines 57..64
src/app/core/ui/navigation/navigation/navigation.component.spec.ts on lines 57..64

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

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

  @Input() set icon(icon: string) {
    if (!icon) {
      this._icon = undefined;
      return;
    }

    Function updateIfPossible has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private updateIfPossible() {
        const currentVersion =
          localStorage.getItem(LatestChangesDialogService.VERSION_KEY) || "";
        if (currentVersion.startsWith(this.UPDATE_PREFIX)) {
          // Sometimes this is triggered multiple times for one update
    Severity: Minor
    Found in src/app/core/ui/latest-changes/update-manager.service.ts - About 1 hr to fix

      Function processToken has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private processToken(token: string): SessionInfo {
          if (!token) {
            throw new Error("No token received from Keycloak");
          }
      
      
      Severity: Minor
      Found in src/app/core/session/auth/keycloak/keycloak-auth.service.ts - About 1 hr to fix

        Function resizeImage has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function resizeImage(
          file: File,
          maxSize = 360,
        ): Promise<HTMLCanvasElement> {
          const image = new Image();
        Severity: Minor
        Found in src/app/features/file/file-utils.ts - About 1 hr to fix

          Function putAll has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async putAll(objects: any[], forceOverwrite = false): Promise<any> {
              if (forceOverwrite) {
                objects.forEach((obj) => (obj._rev = undefined));
              }
          
          
          Severity: Minor
          Found in src/app/core/database/pouch-database.ts - About 1 hr to fix

            Function generateHealthCheckHistoryForChild has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private generateHealthCheckHistoryForChild(child: Entity): Entity[] {
                const data = [];
            
                let date = new Date(child["admissionDate"].getTime());
                let previousRecord = createEntityOfType("HealthCheck");

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

                beforeEach(() => {
                  mockDialog = jasmine.createSpyObj("MatDialog", ["open"]);
              
                  TestBed.configureTestingModule({
                    providers: [{ provide: MatDialog, useValue: mockDialog }],
              src/app/core/common-components/entity-form/dynamic-form-validators/dynamic-validators.service.spec.ts on lines 21..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 75.

              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

                beforeEach(() => {
                  mockedEntityMapper = jasmine.createSpyObj("EntityMapperService", [
                    "loadType",
                  ]);
              
              
              src/app/features/template-export/template-export-service/template-export.service.spec.ts on lines 11..18

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

              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

                  this.potentiallyRetainingPII = [
                    ...this.potentiallyRetainingPII,
                    ...otherResult.potentiallyRetainingPII.filter(
                      (e) =>
                        !this.potentiallyRetainingPII.some((x) => x.getId() === e.getId()),
              Severity: Minor
              Found in src/app/core/entity/entity-actions/cascading-entity-action.ts and 1 other location - About 55 mins to fix
              src/app/core/entity/entity-actions/cascading-entity-action.ts on lines 25..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 74.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

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

                  this.originalEntitiesBeforeChange = [
                    ...this.originalEntitiesBeforeChange,
                    ...otherResult.originalEntitiesBeforeChange.filter(
                      (e) =>
                        !this.originalEntitiesBeforeChange.some(
              Severity: Minor
              Found in src/app/core/entity/entity-actions/cascading-entity-action.ts and 1 other location - About 55 mins to fix
              src/app/core/entity/entity-actions/cascading-entity-action.ts on lines 34..40

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 74.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Function getRouteDataFromRouter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                private getRouteDataFromRouter(path: string, routes: Route[]) {
                  // removing leading slash
                  path = path.replace(/^\//, "");
              
                  function isPathMatch(genericPath: string, path: string) {
              Severity: Minor
              Found in src/app/core/permissions/permission-guard/abstract-permission.guard.ts - About 55 mins 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

              Function setDefaultValue has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                setDefaultValue(
                  targetFormControl: AbstractControl<any, any>,
                  fieldConfig: EntitySchemaField,
                ) {
                  switch (fieldConfig.defaultValue.value) {
              Severity: Minor
              Found in src/app/core/default-values/dynamic-placeholder-value.service.ts - About 55 mins 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

              Function detectBrowser has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                private detectBrowser(): Browser {
                  let browser: Browser;
                  const userAgent = this.window.navigator.userAgent;
                  if (/opera/i.test(userAgent)) {
                    browser = Browser.Opera;
              Severity: Minor
              Found in src/app/core/pwa-install/pwa-install.service.ts - About 55 mins 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

              Function selectDay has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                selectDay(newDate?: Date) {
                  if (!newDate) {
                    this.selectedDate = undefined;
                    this.selectedEvent = undefined;
                    this.selectedEventAttendance = undefined;

              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

                  const allAbsent = ActivityAttendance.create(new Date(), [
                    generateEventWithAttendance([
                      ["1", AttendanceLogicalStatus.ABSENT],
                      ["2", AttendanceLogicalStatus.ABSENT],
                      ["3", AttendanceLogicalStatus.ABSENT],
              src/app/child-dev-project/attendance/model/activity-attendance.spec.ts on lines 102..112

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

              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

              Severity
              Category
              Status
              Source
              Language