Aam-Digital/ndb-core

View on GitHub

Showing 131 of 308 total issues

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

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

    Avoid too many return statements within this function.
    Open

        return true;
    Severity: Major
    Found in src/app/core/entity/default-field-value/handle-default-values.usecase.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

        return entities;
      Severity: Major
      Found in src/app/core/entity/model/entity-update.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return;
        Severity: Major
        Found in src/app/core/entity/default-field-value/handle-default-values.usecase.ts - About 30 mins to fix

          Function loadActivities has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            private async loadActivities() {
              this.allActivities = await this.entityMapper
                .loadType(RecurringActivity)
                .then((res) => res.filter((a) => a.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 applyTextToCreatedEntity has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          export function applyTextToCreatedEntity(entity: Entity, input: string) {
            const toStringFields = entity.getConstructor().toStringAttributes;
            if (!toStringFields || toStringFields.length < 1) {
              return;
            }
          Severity: Minor
          Found in src/app/core/common-components/entity-select/entity-select.component.ts - About 25 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 logToRemoteMonitoring has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            private logToRemoteMonitoring(message: any, logLevel: LogLevel) {
              if (logLevel === LogLevel.ERROR) {
                if (message instanceof Error) {
                  Sentry.captureException(message);
                } else {
          Severity: Minor
          Found in src/app/core/logging/logging.service.ts - About 25 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 getActivitiesForChild has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            async getActivitiesForChild(childId: string): Promise<RecurringActivity[]> {
              const activities = await this.dbIndexing.queryIndexDocs(
                RecurringActivity,
                "activities_index/by_participant",
                childId,
          Severity: Minor
          Found in src/app/child-dev-project/attendance/attendance.service.ts - About 25 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 setEntityConfig has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            private setEntityConfig(newConfig: Config) {
              const entityConfigKey =
                EntityConfigService.PREFIX_ENTITY_CONFIG + this.entityType;
          
              // init config if not present
          Severity: Minor
          Found in src/app/core/admin/admin-entity/admin-entity.component.ts - About 25 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 getDaysSinceLastNoteOfEachEntity has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            public async getDaysSinceLastNoteOfEachEntity(
              entityType = Child.ENTITY_TYPE,
              forLastNDays: number = 30,
            ): Promise<Map<string, number>> {
              const startDay = moment().subtract(forLastNDays, "days");
          Severity: Minor
          Found in src/app/child-dev-project/children/children.service.ts - About 25 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 getValueDescription has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          function getValueDescription(value: any, property: string): string {
            if (typeof value === "boolean") {
              return value
                ? property
                : $localize`:Not a certain property|e.g. 'not male':not ${property}`;
          Severity: Minor
          Found in src/app/features/reporting/report-row.ts - About 25 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 ngOnChanges has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            ngOnChanges(changes: { [key in keyof this]?: any }) {
              if (changes.valueMapper) {
                this._options.forEach(
                  (opt) => (opt.asValue = this.valueMapper(opt.initial)),
                );

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

            generateSchema(): SqsSchema {
              const tables: SqlTables = {};
              for (const [name, ctr] of this.entities.entries()) {
                tables[name] = {};
                for (const [attr, attrSchema] of ctr.schema) {
          Severity: Minor
          Found in src/app/features/reporting/sql-report/sql-report.service.ts - About 25 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 loadParticipants has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            private async loadParticipants() {
              this.children = [];
              this.inactiveParticipants = [];
              for (const childId of this.eventEntity.children) {
                let child: Child;

          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

          Severity
          Category
          Status
          Source
          Language