NGO-DB/ndb-core

View on GitHub

Showing 128 of 288 total issues

Function parseFieldDefinition has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private parseFieldDefinition(
    fieldDef: ConfigFieldRaw,
    entityType: string,
  ): { id: string; schema: EntitySchemaField } {
    const fieldId = fieldDef.id ?? generateIdFromLabel(fieldDef.label);
Severity: Minor
Found in src/app/features/config-setup/config-import-parser.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 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 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 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 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 createMatch has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

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

            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())),

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

                  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 generateOrUpdateDetailsViewConfig has 32 lines of code (exceeds 25 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

                      Function selectDay has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

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

                        Function generateEntities has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

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

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

                          private async alignAvailableAndSelectedEntities(availableEntities: E[]) {
                            if (this.form.value === null || this.form.value === undefined) {
                              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

                        Function recalculateStats has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                          recalculateStats() {
                            this.individualStatusTypeCounts = new Map();
                            this.individualLogicalStatusCounts = new Map();
                        
                            for (const event of this.events) {
                        Severity: Minor
                        Found in src/app/child-dev-project/attendance/model/activity-attendance.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 countPercentage has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          private countPercentage(
                            matchingType: AttendanceLogicalStatus,
                            rounded: boolean = false,
                          ) {
                            const calculatedStats = this.events
                        Severity: Minor
                        Found in src/app/child-dev-project/attendance/model/activity-attendance.ts - About 1 hr to fix

                          Function exportFile has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async exportFile(data: any[], entityConstructor: EntityConstructor) {
                              const entitySchema = entityConstructor.schema;
                              const columnLabels = new Map<string, string>();
                          
                              for (const [id, field] of entitySchema.entries()) {
                          Severity: Minor
                          Found in src/app/core/export/download-service/download.service.ts - About 1 hr to fix

                            Function anonymizeEntity has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              async anonymizeEntity(entity: Entity): Promise<CascadingActionResult> {
                                if (!entity.getConstructor().hasPII) {
                                  // entity types that are generally without PII by default retain all fields
                                  // this should only be called through a cascade action anyway
                                  return new CascadingActionResult();
                            Severity: Minor
                            Found in src/app/core/entity/entity-actions/entity-anonymize.service.ts - About 1 hr to fix

                              Function descriptionForValidator has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                private descriptionForValidator(
                                  validator: DynamicValidator | string,
                                  validationValue: any,
                                ): string {
                                  switch (validator) {
                                Severity
                                Category
                                Status
                                Source
                                Language