NGO-DB/ndb-core

View on GitHub

Showing 287 of 288 total issues

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

    const exportConfig: ExportColumnConfig[] = [
      { label: "activity", query: ".title" },
      {
        query: ".linkedGroups:toEntities(School)",
        subQueries: [
src/app/core/export/data-transformation-service/data-transformation.service.spec.ts on lines 144..159

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

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

      if (
        !this.combinedAttendance.periodTo ||
        moment(record.periodTo).isAfter(this.combinedAttendance.periodTo, "day")
      ) {
        this.combinedAttendance.periodTo = record.periodTo;
src/app/child-dev-project/attendance/activity-attendance-section/activity-attendance-section.component.ts on lines 113..121

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

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

    const exportConfig: ExportColumnConfig[] = [
      { label: "note", query: ".subject" },
      {
        query: ":getAttendanceArray",
        subQueries: [
src/app/core/export/data-transformation-service/data-transformation.service.spec.ts on lines 113..126

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

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

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

          if (
            !this.combinedAttendance.periodFrom ||
            moment(record.periodFrom).isBefore(
              this.combinedAttendance.periodFrom,
              "day",
    src/app/child-dev-project/attendance/activity-attendance-section/activity-attendance-section.component.ts on lines 123..128

    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

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

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

    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

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

      parseImportDefinition(
        configRaw: ConfigFieldRaw[],
        entityName: string,
        includingDefaultConfigs: boolean,
      ): GeneratedConfig {
    Severity: Minor
    Found in src/app/features/config-setup/config-import-parser.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 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 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 columnsToDisplay has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      @Input() set columnsToDisplay(value: string[]) {
        if (!value || value.length === 0) {
          value = (this._customColumns ?? this._columns).map((c) => c.id);
        }
        value = value.filter((c) => !c.startsWith("__")); // remove internal action columns

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

      private generateRows(
        data: any[],
        config: ExportColumnConfig[],
        from: Date,
        to: Date,

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

    export function makeCustomMatcher<T>(
      condition: (actual: T, ...expected: any[]) => boolean,
      compareMessage: (actual: T, ...expected: any[]) => string,
      negativeCompareMessage: (actual: T, ...expected: any[]) => string,
    ): jasmine.CustomMatcher {
    Severity: Minor
    Found in src/app/utils/test-utils/custom-matcher-utils.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 addMarker has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      private addMarker(m: L.Marker, highlighted: boolean = false) {
        m.addTo(this.map);
        const entity = m["entity"] as Entity;
        if (highlighted || entity) {
          const degree = entity ? getHueForEntity(entity) : "145";
    Severity: Minor
    Found in src/app/features/location/map/map.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 initColumnGroups has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      private initColumnGroups(columnGroup?: ColumnGroupsConfig) {
        if (columnGroup && columnGroup.groups.length > 0) {
          this.groups = columnGroup.groups;
          this.defaultColumnGroup =
            columnGroup.default || columnGroup.groups[0].name;
    Severity: Minor
    Found in src/app/core/entity-list/entity-list/entity-list.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 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 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 parseFieldDefinition has a Cognitive Complexity of 6 (exceeds 5 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 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

    Severity
    Category
    Status
    Source
    Language