OwenKelvin/Angular-School-Management-System

View on GitHub
src/app/pages/curriculum-maintenance/units/create-unit/create-unit.component.ts

Summary

Maintainability
F
3 days
Test Coverage

File create-unit.component.ts has 282 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import {
  FormBuilder,
  FormGroup,
  Validators,

    Function ngOnInit has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      ngOnInit() {
        this.newForm = true;
        this.errors = {
          name: '',
          abbr: '',

      Function submit has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        submit() {
          if (this.unitForm.valid) {
            this.unit.submit(this.unitForm.value).subscribe(() => {
              this.submitted.emit();
              if (this.newForm) {

        Function ngOnInit has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          ngOnInit() {
            this.newForm = true;
            this.errors = {
              name: '',
              abbr: '',

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

          validateAbbr() {
            if (
              (this.unitForm.get('abbr').dirty || this.unitForm.get('abbr').touched) &&
              !this.unitForm.get('abbr').valid
            ) {

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

          validateUnitCategory() {
            if (
              (this.unitForm.get('unitCategory').dirty ||
                this.unitForm.get('unitCategory').touched) &&
              !this.unitForm.get('unitCategory').valid

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

          validateName() {
            if (
              (this.unitForm.get('name').dirty || this.unitForm.get('name').touched) &&
              !this.unitForm.get('name').valid
            ) {

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

          validatesubjectLevelName(i) {
            const form = (this.unitForm.get('subjectLevels') as FormArray).controls[i];
            if (
              (form.get('name').dirty || form.get('name').touched) &&
              !form.get('name').valid

        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 12 locations. Consider refactoring.
        Open

          validateName() {
            if (
              (this.unitForm.get('name').dirty || this.unitForm.get('name').touched) &&
              !this.unitForm.get('name').valid
            ) {
        src/app/pages/academic-year/create-academic-year/create-academic-year.component.ts on lines 87..99
        src/app/pages/academic-year/create-academic-year/create-academic-year.component.ts on lines 100..112
        src/app/pages/academic-year/create-academic-year/create-academic-year.component.ts on lines 113..125
        src/app/pages/admissions/students/student-academic-year-allocation/student-academic-year-allocation.component.ts on lines 23..35
        src/app/pages/admissions/students/student-identification-form/student-identification-form.component.ts on lines 215..224
        src/app/pages/curriculum-maintenance/class-levels/create-class-level-category/create-class-level-category.component.ts on lines 75..87
        src/app/pages/curriculum-maintenance/class-levels/create-class-level/create-class-level.component.ts on lines 113..125
        src/app/pages/curriculum-maintenance/class-levels/create-class-level/create-class-level.component.ts on lines 127..139
        src/app/pages/curriculum-maintenance/subject-category/create-subject-category/create-subject-category.component.ts on lines 75..87
        src/app/pages/curriculum-maintenance/units/create-unit/create-unit.component.ts on lines 183..195
        src/app/pages/curriculum-maintenance/units/create-unit/create-unit.component.ts on lines 203..214

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

        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 12 locations. Consider refactoring.
        Open

          validateUnitCategory() {
            if (
              (this.unitForm.get('unitCategory').dirty ||
                this.unitForm.get('unitCategory').touched) &&
              !this.unitForm.get('unitCategory').valid
        src/app/pages/academic-year/create-academic-year/create-academic-year.component.ts on lines 87..99
        src/app/pages/academic-year/create-academic-year/create-academic-year.component.ts on lines 100..112
        src/app/pages/academic-year/create-academic-year/create-academic-year.component.ts on lines 113..125
        src/app/pages/admissions/students/student-academic-year-allocation/student-academic-year-allocation.component.ts on lines 23..35
        src/app/pages/admissions/students/student-identification-form/student-identification-form.component.ts on lines 215..224
        src/app/pages/curriculum-maintenance/class-levels/create-class-level-category/create-class-level-category.component.ts on lines 75..87
        src/app/pages/curriculum-maintenance/class-levels/create-class-level/create-class-level.component.ts on lines 113..125
        src/app/pages/curriculum-maintenance/class-levels/create-class-level/create-class-level.component.ts on lines 127..139
        src/app/pages/curriculum-maintenance/subject-category/create-subject-category/create-subject-category.component.ts on lines 75..87
        src/app/pages/curriculum-maintenance/units/create-unit/create-unit.component.ts on lines 171..182
        src/app/pages/curriculum-maintenance/units/create-unit/create-unit.component.ts on lines 203..214

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

        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 12 locations. Consider refactoring.
        Open

          validateAbbr() {
            if (
              (this.unitForm.get('abbr').dirty || this.unitForm.get('abbr').touched) &&
              !this.unitForm.get('abbr').valid
            ) {
        src/app/pages/academic-year/create-academic-year/create-academic-year.component.ts on lines 87..99
        src/app/pages/academic-year/create-academic-year/create-academic-year.component.ts on lines 100..112
        src/app/pages/academic-year/create-academic-year/create-academic-year.component.ts on lines 113..125
        src/app/pages/admissions/students/student-academic-year-allocation/student-academic-year-allocation.component.ts on lines 23..35
        src/app/pages/admissions/students/student-identification-form/student-identification-form.component.ts on lines 215..224
        src/app/pages/curriculum-maintenance/class-levels/create-class-level-category/create-class-level-category.component.ts on lines 75..87
        src/app/pages/curriculum-maintenance/class-levels/create-class-level/create-class-level.component.ts on lines 113..125
        src/app/pages/curriculum-maintenance/class-levels/create-class-level/create-class-level.component.ts on lines 127..139
        src/app/pages/curriculum-maintenance/subject-category/create-subject-category/create-subject-category.component.ts on lines 75..87
        src/app/pages/curriculum-maintenance/units/create-unit/create-unit.component.ts on lines 171..182
        src/app/pages/curriculum-maintenance/units/create-unit/create-unit.component.ts on lines 183..195

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

        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

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

                  this.unit
                    .get({ id, includeUnitLevels: 1, includeClassLevels: 1 })
                    .pipe(
                      map(res => {
                        return {
        src/app/pages/curriculum-maintenance/units/create-unit/create-unit.component.ts on lines 257..272

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

        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

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

                  this.unit
                    .get({
                      id: this.formId,
                      includeUnitLevels: 1,
                      includeClassLevels: 1
        src/app/pages/curriculum-maintenance/units/create-unit/create-unit.component.ts on lines 93..104

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

        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

                if (this.newForm) {
                  this.generateUnitForm();
                  this.unitForm.get('name').clearValidators();
                  this.unitForm.get('name').updateValueAndValidity();
                } else {
        src/app/pages/curriculum-maintenance/class-levels/create-class-level-category/create-class-level-category.component.ts on lines 94..111
        src/app/pages/curriculum-maintenance/class-levels/create-class-level/create-class-level.component.ts on lines 144..163

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

        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

        Identical blocks of code found in 6 locations. Consider refactoring.
        Open

            if (
              this.router.routerState.root &&
              this.router.routerState.root.children &&
              this.router.routerState.root.children[0]
            ) {
        src/app/pages/academic-year/view-academic-year/view-academic-year.component.ts on lines 30..44
        src/app/pages/curriculum-maintenance/class-levels/create-class-level-category/create-class-level-category.component.ts on lines 42..60
        src/app/pages/curriculum-maintenance/class-levels/view-class-level-category/view-class-level-category.component.ts on lines 22..36
        src/app/pages/curriculum-maintenance/subject-category/create-subject-category/create-subject-category.component.ts on lines 42..58
        src/app/pages/curriculum-maintenance/subject-category/view-subject-category/view-subject-category.component.ts on lines 22..34

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

        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

        There are no issues that match your filters.

        Category
        Status