NGO-DB/ndb-core

View on GitHub

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

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

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

                        async ngOnInit() {
                          if (!this.entityToDisplay) {
                            this.entityId = this.entityId ?? this.value;
                            this.entityType = (this.entityId ?? "").includes(":")
                              ? Entity.extractTypeFromId(this.entityId)

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

                          generateEntities(): School[] {
                            const data = [];
                        
                            for (let i = 1; i <= this.config.count; i++) {
                              const school = new School(String(i));
                        Severity: Minor
                        Found in src/app/child-dev-project/schools/demo-school-generator.service.ts - About 1 hr to fix

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

                          function generateChildEntities(): Child[] {
                            const data = [];
                          
                            const a1 = new Child("1");
                            a1.name = "Arjun A.";
                          Severity: Minor
                          Found in src/app/child-dev-project/children/children.service.spec.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
                              Severity
                              Category
                              Status
                              Source
                              Language