NGO-DB/ndb-core

View on GitHub

Showing 287 of 288 total issues

Function testDatatype has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  dataType: D | (new (params: any) => D),
  objectValue,
  databaseValue,
  additionalSchemaFieldConfig?: any,
  additionalProviders?: any[],
Severity: Minor
Found in src/app/core/entity/schema/entity-schema.service.spec.ts - About 35 mins to fix

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

      generateEntities(): EventNote[] {
        const data = [];
    
        for (const activity of this.demoActivities.entities) {
          for (

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

      @Input() set icon(icon: string) {
        if (!icon) {
          this._icon = 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 detectOS has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      private detectOS(): OS {
        let os: OS;
        const userAgent = this.window.navigator.userAgent;
        if (/iphone|ipad|ipod|macintosh/i.test(userAgent)) {
          if (this.window.innerWidth < 1025) {
    Severity: Minor
    Found in src/app/core/pwa-install/pwa-install.service.ts - About 35 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 getAllDistances has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      private getAllDistances(compareCoordinates: Coordinates[], e: Entity) {
        const results: number[] = [];
        for (const prop of this.config.coordinatesProperties) {
          for (const coord of compareCoordinates) {
            if (e[prop] && coord) {
    Severity: Minor
    Found in src/app/features/location/view-distance/view-distance.component.ts - About 35 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 migrateFormFieldConfigView2ViewComponent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    const migrateFormFieldConfigView2ViewComponent: ConfigMigration = (
      key,
      configPart,
    ) => {
      if (
    Severity: Minor
    Found in src/app/core/config/config.service.ts - About 35 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 processToken has a Cognitive Complexity of 7 (exceeds 5 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 35 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 applyUpdate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    export function applyUpdate<T extends Entity>(
      entities: T[],
      next: UpdatedEntity<T>,
      addIfMissing: boolean = true,
    ): T[] {
    Severity: Minor
    Found in src/app/core/entity/model/entity-update.ts - About 35 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 anonymize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      async anonymize<E extends Entity>(entityParam: E | E[]) {
        let entities = Array.isArray(entityParam) ? entityParam : [entityParam];
        let textForAnonymizeEntity = "";
    
        if (entities.length > 1) {
    Severity: Minor
    Found in src/app/core/entity/entity-actions/entity-actions.service.ts - About 35 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 anonymizeEntity has a Cognitive Complexity of 7 (exceeds 5 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 35 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 transformDatabaseToEntityFormat has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      public transformDatabaseToEntityFormat<T = Entity>(
        data: any,
        schema: EntitySchema,
      ): T {
        const transformed = {};
    Severity: Minor
    Found in src/app/core/entity/schema/entity-schema.service.ts - About 35 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

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

        await TestBed.configureTestingModule({
          imports: [EditLocationComponent, MockedTestingModule.withState()],
          providers: [
            { provide: GeoService, useValue: mockGeoService },
            { provide: MatDialog, useValue: mockDialog },
    src/app/core/basic-datatypes/configurable-enum/enum-dropdown/enum-dropdown.component.spec.ts on lines 25..31
    src/app/core/session/auth/keycloak/account-page/account-page.component.spec.ts on lines 31..37

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

    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

        await TestBed.configureTestingModule({
          imports: [EnumDropdownComponent, MockedTestingModule.withState()],
          providers: [
            { provide: MatDialog, useValue: mockDialog },
            { provide: EntityAbility, useValue: mockAbility },
    src/app/core/session/auth/keycloak/account-page/account-page.component.spec.ts on lines 31..37
    src/app/features/location/edit-location/edit-location.component.spec.ts on lines 32..38

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

    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

        newMatchEntity[this.onMatch.newEntityMatchPropertyLeft] = this
          .sideDetails[0].multiSelect
          ? leftMatch.map((e) => e.getId())
          : leftMatch[0].getId();
    src/app/features/matching-entities/matching-entities/matching-entities.component.ts on lines 285..288

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

    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

        newMatchEntity[this.onMatch.newEntityMatchPropertyRight] = this
          .sideDetails[1].multiSelect
          ? rightMatch.map((e) => e.getId())
          : rightMatch[0].getId();
    src/app/features/matching-entities/matching-entities/matching-entities.component.ts on lines 281..284

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

    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

        await TestBed.configureTestingModule({
          imports: [AccountPageComponent, MockedTestingModule.withState()],
          providers: [
            { provide: KeycloakAuthService, useValue: mockAuthService },
            { provide: AlertService, useValue: mockAlerts },
    src/app/core/basic-datatypes/configurable-enum/enum-dropdown/enum-dropdown.component.spec.ts on lines 25..31
    src/app/features/location/edit-location/edit-location.component.spec.ts on lines 32..38

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

    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(waitForAsync(() => {
        fixture = TestBed.createComponent(HistoricalDataComponent);
        component = fixture.componentInstance;
    
        component.entity = new Child();
    src/app/features/todos/todos-related-to-entity/todos-related-to-entity.component.spec.ts on lines 24..31

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

    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(waitForAsync(() => {
        fixture = TestBed.createComponent(TodosRelatedToEntityComponent);
        component = fixture.componentInstance;
    
        component.entity = new Entity();
    src/app/features/historical-data/historical-data/historical-data.component.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 66.

    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

    Avoid too many return statements within this function.
    Open

          return order === "asc" ? 1 : -1;
    Severity: Major
    Found in src/app/utils/utils.ts - About 30 mins to fix

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

        it("should not show archived children in 'school' mode", fakeAsync(() => {
          component.entity = new School();
      
          fixture.detectChanges();
          tick();
      src/app/child-dev-project/schools/child-school-overview/child-school-overview.component.spec.ts on lines 98..105

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

      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