Aam-Digital/ndb-core

View on GitHub

Showing 282 of 313 total issues

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

  it("adds a danger alert", function () {
    const message = "danger alert";
    service.addDanger(message);

    expect(service.alerts[0].message).toEqual(message);
Severity: Major
Found in src/app/core/alerts/alert.service.spec.ts and 2 other locations - About 1 hr to fix
src/app/core/alerts/alert.service.spec.ts on lines 33..39
src/app/core/alerts/alert.service.spec.ts on lines 41..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 85.

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

  it("adds an info alert", function () {
    const message = "info alert";
    service.addInfo(message);

    expect(service.alerts[0].message).toEqual(message);
Severity: Major
Found in src/app/core/alerts/alert.service.spec.ts and 2 other locations - About 1 hr to fix
src/app/core/alerts/alert.service.spec.ts on lines 41..47
src/app/core/alerts/alert.service.spec.ts on lines 49..55

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

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

  toBeEnabled: (util) => {
    return makeCustomMatcher(
      (form: AbstractControl) => form.enabled,
      (form) => `Expected form ${util.pp(form.value)} to be enabled`,
      (form) => `Expected form ${util.pp(form.value)} not to be enabled`,
Severity: Major
Found in src/app/utils/test-utils/form-matchers.spec.ts and 1 other location - About 1 hr to fix
src/app/utils/test-utils/form-matchers.spec.ts on lines 29..35

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

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

  toBeValidForm: (util) => {
    return makeCustomMatcher(
      (form: AbstractControl) => form.valid,
      (form) => `Expected form ${util.pp(form.value)} to be valid`,
      (form) => `Expected form ${util.pp(form.value)} not to be valid`,
Severity: Major
Found in src/app/utils/test-utils/form-matchers.spec.ts and 1 other location - About 1 hr to fix
src/app/utils/test-utils/form-matchers.spec.ts on lines 36..42

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

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

  async handleEntityForm<T extends Entity>(
    form: EntityForm<T>,
    entity: Entity,
  ): Promise<void> {
    if (!(form.defaultValueConfigs?.size > 0)) {
Severity: Minor
Found in src/app/core/default-values/default-value.service.ts - About 1 hr to fix

    Function initSideDetails has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private async initSideDetails(
        side: MatchingSideConfig,
        sideIndex: number,
      ): Promise<MatchingSide> {
        const newSide = Object.assign({}, side) as MatchingSide; // we are transforming it into this type here

      Function generateOrUpdateDetailsViewConfig has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        private generateOrUpdateDetailsViewConfig(
          fieldDef: ConfigFieldRaw,
          entityType: string,
          fieldId: string,
        ) {
      Severity: Minor
      Found in src/app/features/config-setup/config-import-parser.service.ts - About 1 hr 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 cascadeActionToRelatedEntities has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        protected async cascadeActionToRelatedEntities(
          entity: Entity,
          compositeAction: (
            relatedEntity: Entity,
            refField?: string,
      Severity: Minor
      Found in src/app/core/entity/entity-actions/cascading-entity-action.ts - About 1 hr 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 onRowMouseDown has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        onRowMouseDown(event: MouseEvent, row: TableRow<T>) {
          if (!this._selectable) {
            this.onRowClick(row);
            return;
          }

      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

          components.addAll([
            [
              "AdminOverview",
              () =>
                import("./admin-overview/admin-overview.component").then(
      Severity: Major
      Found in src/app/core/admin/admin.module.ts and 1 other location - About 1 hr to fix
      src/app/features/location/location-components.ts on lines 3..25

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

      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 locationComponents: ComponentTuple[] = [
        [
          "EditLocation",
          () =>
            import("./edit-location/edit-location.component").then(
      Severity: Major
      Found in src/app/features/location/location-components.ts and 1 other location - About 1 hr to fix
      src/app/core/admin/admin.module.ts on lines 21..43

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

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

        public generateEntities(): Note[] {
          const data = [];
      
          for (const child of this.demoChildren.entities) {
            if (!child.isActive) {

        Function createMatch has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async createMatch() {
            const newMatchEntity = new (this.entityRegistry.get(
              this.onMatch.newEntityType,
            ))();
        
        

          Function calculateGroupBy has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private calculateGroupBy(
              properties: string[],
              aggregations: any[],
              label: string,
              data: any[],
          Severity: Minor
          Found in src/app/features/reporting/data-aggregation.service.ts - About 1 hr to fix

            Function initSettings has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private initSettings() {
                this.fieldIdForm = this.fb.control(this.fieldId, {
                  validators: [Validators.required],
                  asyncValidators: [
                    uniqueIdValidator(Array.from(this.entityType.schema.keys())),

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

                it("calculates individual's absent events", () => {
                  expect(testInstance.countEventsAbsent("1")).toBe(0);
                  expect(testInstance.countEventsAbsent("2")).toBe(1);
                  expect(testInstance.countEventsAbsent("3")).toBe(1);
                });
              src/app/child-dev-project/attendance/model/activity-attendance.spec.ts on lines 51..55

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

              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("calculates individual's present events", () => {
                  expect(testInstance.countEventsPresent("1")).toBe(2);
                  expect(testInstance.countEventsPresent("2")).toBe(1);
                  expect(testInstance.countEventsPresent("3")).toBe(0);
                });
              src/app/child-dev-project/attendance/model/activity-attendance.spec.ts on lines 45..49

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

              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 33 lines of code (exceeds 25 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 1 hr to fix

                Function onDropListEntered has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  onDropListEntered({ item, container }: CdkDragEnter) {
                    if (container == this.placeholder) {
                      return;
                    }
                    const placeholderElement: HTMLElement =
                Severity: Minor
                Found in src/app/core/admin/admin-entity-list/admin-entity-list.component.ts - About 1 hr to fix

                  Function createEventsIndex has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    private createEventsIndex(): Promise<void> {
                      const designDoc = {
                        _id: "_design/events_index",
                        views: {
                          by_date: {
                  Severity: Minor
                  Found in src/app/child-dev-project/attendance/attendance.service.ts - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language