OwenKelvin/Angular-School-Management-System

View on GitHub

Showing 218 of 218 total issues

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

describe('HttpCacheService', () => {
  beforeEach(() => TestBed.configureTestingModule({}));

  it('should be created', () => {
    const service: HttpCacheService = TestBed.get(HttpCacheService);
Severity: Major
Found in src/app/core/services/http-cache/http-cache.service.spec.ts and 7 other locations - About 2 hrs to fix
src/app/core/menu-item/menu-item.service.spec.ts on lines 5..12
src/app/core/services/language/language.service.spec.ts on lines 5..12
src/app/pages/academic-year/services/menu-items.service.spec.ts on lines 5..14
src/app/pages/admissions/services/menu-items.service.spec.ts on lines 5..12
src/app/pages/curriculum-maintenance/services/menu-items.service.spec.ts on lines 5..12
src/app/pages/library/services/menu-items.service.spec.ts on lines 5..12
src/app/shared/services/message/message.service.spec.ts on lines 5..12

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

describe('MessageService', () => {
  beforeEach(() => TestBed.configureTestingModule({}));

  it('should be created', () => {
    const service: MessageService = TestBed.get(MessageService);
Severity: Major
Found in src/app/shared/services/message/message.service.spec.ts and 7 other locations - About 2 hrs to fix
src/app/core/menu-item/menu-item.service.spec.ts on lines 5..12
src/app/core/services/http-cache/http-cache.service.spec.ts on lines 5..12
src/app/core/services/language/language.service.spec.ts on lines 5..12
src/app/pages/academic-year/services/menu-items.service.spec.ts on lines 5..14
src/app/pages/admissions/services/menu-items.service.spec.ts on lines 5..12
src/app/pages/curriculum-maintenance/services/menu-items.service.spec.ts on lines 5..12
src/app/pages/library/services/menu-items.service.spec.ts on lines 5..12

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

describe('MenuItemsService', () => {
  beforeEach(() => TestBed.configureTestingModule({}));

  it('should be created', () => {
    const service: MenuItemsService = TestBed.get(MenuItemsService);
src/app/core/menu-item/menu-item.service.spec.ts on lines 5..12
src/app/core/services/http-cache/http-cache.service.spec.ts on lines 5..12
src/app/core/services/language/language.service.spec.ts on lines 5..12
src/app/pages/academic-year/services/menu-items.service.spec.ts on lines 5..14
src/app/pages/curriculum-maintenance/services/menu-items.service.spec.ts on lines 5..12
src/app/pages/library/services/menu-items.service.spec.ts on lines 5..12
src/app/shared/services/message/message.service.spec.ts on lines 5..12

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

describe('MenuItemsService', () => {
  beforeEach(() => TestBed.configureTestingModule({}));

  it('should be created', () => {
    const service: MenuItemsService = TestBed.get(MenuItemsService);
src/app/core/menu-item/menu-item.service.spec.ts on lines 5..12
src/app/core/services/http-cache/http-cache.service.spec.ts on lines 5..12
src/app/core/services/language/language.service.spec.ts on lines 5..12
src/app/pages/academic-year/services/menu-items.service.spec.ts on lines 5..14
src/app/pages/admissions/services/menu-items.service.spec.ts on lines 5..12
src/app/pages/library/services/menu-items.service.spec.ts on lines 5..12
src/app/shared/services/message/message.service.spec.ts on lines 5..12

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

  it('should call dispatch method when "closeDialog" is called', () => {
    const store = jasmine.createSpyObj({ dispatch: () => { } });
    const errorMessageTopBarComponent = new ErrorMessageTopBarComponent(store);
    errorMessageTopBarComponent.closeDialog();
    expect(store.dispatch).toHaveBeenCalled();
src/app/core/error-message-top-bar/error-message-top-bar.component.spec.ts on lines 34..39

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

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

  it('should have as showMessage = true when "openDialog" is called', () => {
    const store = jasmine.createSpyObj({ dispatch: () => { } });
    const errorMessageTopBarComponent = new ErrorMessageTopBarComponent(store);
    errorMessageTopBarComponent.openDialog();
    expect(errorMessageTopBarComponent.showMessage).toBeTruthy();
src/app/core/error-message-top-bar/error-message-top-bar.component.spec.ts on lines 28..33

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

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

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

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

      findIfEmailExists(email: string): Observable<any> {
        const url = `${this.config.apiUrl}/api/users/email/?q=${email}`;
        return this.http.get(url).pipe(map(data => {
          return data;
        },
    Severity: Major
    Found in src/app/shared/services/users/users.service.ts and 1 other location - About 2 hrs to fix
    src/app/pages/admissions/services/guardian-details/guardian.service.ts on lines 15..24

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

    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

      getGuardiansFor(studentId: string) {
        const url = `${this.config.apiUrl}/api/student/guardians/?q=${studentId}`;
        return this.http.get(url).pipe(map(data => {
          return data;
        },
    src/app/shared/services/users/users.service.ts on lines 16..25

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

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

      getItems(): object {
        const items: object = {
          preIcon: 'group_add',
          label: 'Admission',
          postIcon: 'arrow_right',
    Severity: Major
    Found in src/app/pages/admissions/services/menu-items.service.ts - About 2 hrs to fix

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

        getAll() {
          const url = `${this.config.apiUrl}/api/curriculum/class-level-categories`;
          return this.http.get<any>(url).pipe(
            map(res => {
              return res;
      src/app/pages/academic-year/services/academic-year.service.ts on lines 12..19

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

      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

        getAll() {
          const url = `${this.config.apiUrl}/api/academic-years`;
          return this.http.get<any>(url).pipe(
            map(res => {
              return res;
      src/app/pages/curriculum-maintenance/class-levels/services/class-level-category.service.ts on lines 13..20

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

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

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

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

              }, {
                preIcon: 'account_box',
                label: 'My Account',
                // postIcon: 'arrow_right',
                children: [{
        Severity: Major
        Found in src/app/pages/library/services/menu-items.service.ts and 2 other locations - About 1 hr to fix
        src/app/pages/library/services/menu-items.service.ts on lines 41..58
        src/app/pages/library/services/menu-items.service.ts on lines 58..75

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

        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

                children: [{
                  preIcon: 'book',
                  label: 'Books Management',
                  // postIcon: 'arrow_right',
                  children: [{
        Severity: Major
        Found in src/app/pages/library/services/menu-items.service.ts and 2 other locations - About 1 hr to fix
        src/app/pages/library/services/menu-items.service.ts on lines 20..37
        src/app/pages/library/services/menu-items.service.ts on lines 58..75

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

        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

                }, {
                  preIcon: 'edit',
                  label: 'Book Author Management',
                  // postIcon: 'arrow_right',
                  children: [{
        Severity: Major
        Found in src/app/pages/library/services/menu-items.service.ts and 2 other locations - About 1 hr to fix
        src/app/pages/library/services/menu-items.service.ts on lines 20..37
        src/app/pages/library/services/menu-items.service.ts on lines 41..58

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

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

          ngOnInit() {
        
            this.getGenders.getAll().subscribe(data => {
              this.genders = data;
            });

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

            ngOnInit() {
              this.phoneErrorMatcher = new MyErrorStateMatcher();
              this.selectedPhone = { code: 254, country: 'KE' };
              this.allowedPhoneNumbers.getAllowedCountries().subscribe(data => {
                this.allowedPhoneCountries = data;

            Function validateFirstName has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              validateFirstName(i): void {
                this.createError(i);
                const changeFirstNameError = () => {
                  if ((this.guardians().controls[i].get('firstName').dirty || this.guardians().controls[i].get('firstName').touched) &&
                    !this.guardians().controls[i].get('firstName').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 validateFirstName has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              validateFirstName({ blur } = { blur: true }) {
                const changeFirstNameError = () => {
                  if ((this.userIdentificaionForm.get('firstName').dirty || this.userIdentificaionForm.get('firstName').touched) &&
                    !this.userIdentificaionForm.get('firstName').valid) {
                    if (this.userIdentificaionForm.get('firstName').errors.required) {

            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