Aam-Digital/ndb-core

View on GitHub

Showing 282 of 313 total issues

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

  static withState(
    loginState = LoginState.LOGGED_IN,
    data: Entity[] = [createEntityOfType("User", TEST_USER)],
  ): ModuleWithProviders<MockedTestingModule> {
    environment.session_type = SessionType.mock;
Severity: Minor
Found in src/app/utils/mocked-testing.module.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 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

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

          constructor(
            private alertService: AlertService,
            private backupService: BackupService,
            private downloadService: DownloadService,
            private db: Database,
        src/app/features/public-form/public-form.component.ts on lines 38..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 80.

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

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

        describe("When on a big screen, the filter component above the entity list should be visible", () => {
          before("GIVEN that the screen is big", () => {
            cy.visit("child");
            cy.viewport("macbook-15");
          });
        Severity: Major
        Found in e2e/integration/HidingFilterOnSmallScreen.cy.ts and 1 other location - About 1 hr to fix
        e2e/integration/HidingFilterOnSmallScreen.cy.ts on lines 12..21

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

        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

          constructor(
            private database: PouchDatabase,
            private route: ActivatedRoute,
            private entities: EntityRegistry,
            private entityMapper: EntityMapperService,
        Severity: Major
        Found in src/app/features/public-form/public-form.component.ts and 1 other location - About 1 hr to fix
        src/app/core/admin/admin-overview/admin-overview.component.ts on lines 35..44

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

        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

        describe("When on a small screen, the filter component above the entity list should not be visible", () => {
          before("GIVEN that the screen is small", () => {
            cy.visit("child");
            cy.viewport("iphone-6");
          });
        Severity: Major
        Found in e2e/integration/HidingFilterOnSmallScreen.cy.ts and 1 other location - About 1 hr to fix
        e2e/integration/HidingFilterOnSmallScreen.cy.ts on lines 1..10

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

        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

          private updateField() {
            if (!this.entity?.getConstructor()) {
              this._field = undefined;
              return;
            }
        src/app/core/common-components/entity-field-view/entity-field-view.component.ts on lines 44..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 79.

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

          private async initKeycloak() {
            try {
              await this.keycloak.init({
                config: window.location.origin + "/assets/keycloak.json",
                initOptions: {
        Severity: Minor
        Found in src/app/core/session/auth/keycloak/keycloak-auth.service.ts - About 1 hr to fix

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

            private updateField() {
              if (!this.entity?.getConstructor()) {
                this._field = undefined;
                return;
              }
          src/app/core/common-components/entity-field-edit/entity-field-edit.component.ts on lines 59..69

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

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

              private updateUrl(key: string, value: string) {
                const MAX_URL_LENGTH = 2000;
                let queryParams = { ...this.route.snapshot.queryParams, [key]: value };
            
                let potentialUrl = this.router
            Severity: Minor
            Found in src/app/core/filter/filter/filter.component.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) {

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

                  generateEntities(): Entity[] {
                    const data = [];
                
                    for (let i = 1; i <= this.config.count; i++) {
                      const school = createEntityOfType("School", String(i));

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

                  function generateChildEntities(): Entity[] {
                    const data = [];
                  
                    const a1 = createEntityOfType("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 applyChanges has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      private async applyChanges(externallyUpdatedEntity: T) {
                        if (this.formIsUpToDate(externallyUpdatedEntity)) {
                          Object.assign(this.entity, externallyUpdatedEntity);
                          return;
                        }

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

                        generateIndexOnProperty<
                          E extends Entity,
                          REF extends keyof E & string,
                          SEC extends keyof E & string,
                        >(
                      Severity: Minor
                      Found in src/app/core/entity/database-indexing/database-indexing.service.ts - About 1 hr to fix

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

                              const fields = Array.from(this.entityConstructor.schema.entries())
                                .filter(([key, field]) => field.label)
                                .map(([key, field]) => ({
                                  key: key,
                                  label: field.label,
                        src/app/core/entity/entity-actions/entity-bulk-edit/entity-bulk-edit.component.ts on lines 93..99

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

                        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