OwenKelvin/Angular-School-Management-System

View on GitHub

Showing 54 of 218 total issues

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

  ngOnChanges(changes: SimpleChanges) {
    if (changes.submit.currentValue && changes.submit && !changes.submit.firstChange) {
      if (this.userIdentificaionForm.valid) {
        this.submitted.emit(true);
        this.formSubmit.submit({ ...this.serverStudentData, ...this.userIdentificaionForm.value }, this.idNumber).subscribe(

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

      submit() {
        if (this.classLevelCategoryForm.valid) {
          this.classLevelCategory
            .submit(this.classLevelCategoryForm.value)
            .subscribe(() => {

      Function reducer has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function reducer(state, action) {
      
        const admissions = state ? state.admissions : {};
        switch (action.type) {
          case SET_STUDENT_ID_NUMBER:
      Severity: Minor
      Found in src/app/pages/admissions/store/reducers/index.ts - About 1 hr to fix

        Function get has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          get(key: string): IMessage {
            switch (key) {
              case 'ERROR':
                return {
                  type: 'error',
        Severity: Minor
        Found in src/app/shared/services/message/message.service.ts - About 1 hr to fix

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

            submit(data: IClassLevel) {
              let url = `${this.config.apiUrl}/api/curriculum/class-levels`;
              if (data.id) {
                url += '/' + data.id;
                return this.http

            Function save has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              save(data) {
                let url = `${this.config.apiUrl}/api/academic-years`;
                if (data.id) {
                  url += '/' + data.id;
                  return this.http
            Severity: Minor
            Found in src/app/pages/academic-year/services/academic-year.service.ts - About 1 hr to fix

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

                submit(data: any): Observable<any> {
                  const submitData = {
                    id: data.id,
                    email: data.email,
                    first_name: data.firstName,

                Function levenshtein has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  levenshtein(a: string, b: string): number {
                    if (a.length === 0) {
                      return b.length;
                    }
                    if (b.length === 0) {
                Severity: Minor
                Found in src/app/core/services/path-resolve/path-resolve.service.ts - About 1 hr to fix

                  Function getItems has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    getItems(): object {
                      const items: object = {
                        preIcon: 'date_range',
                        label: 'Academic Years',
                        postIcon: 'arrow_right',

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

                      validateUsername() {
                        if ((this.loginForm.get('username').dirty || this.loginForm.get('username').touched) &&
                          !this.loginForm.get('username').valid) {
                          if (this.loginForm.get('username').errors.required) {
                            this.errors.username = 'Username is required';
                    Severity: Minor
                    Found in src/app/login/login.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 validateLastName has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      validateLastName() {
                        if ((this.userIdentificaionForm.get('lastName').dirty || this.userIdentificaionForm.get('lastName').touched) &&
                          !this.userIdentificaionForm.get('lastName').valid) {
                          if (this.userIdentificaionForm.get('lastName').errors.required) {
                            this.errors.lastName = 'First Name is 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

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

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

                      validateLastName(i): void {
                        this.createError(i);
                        if ((this.guardians().controls[i].get('lastName').dirty || this.guardians().controls[i].get('lastName').touched) &&
                          !this.guardians().controls[i].get('lastName').valid) {
                          if (this.guardians().controls[i].get('lastName').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

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

                      validateIdNumber() {
                        const idNumber = this.userIdentificaionForm.get('idNumber');
                        if ((idNumber.dirty || idNumber.touched) &&
                          !idNumber.valid) {
                          if (idNumber.errors && idNumber.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

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

                        intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
                            // add authorization header with jwt token if available
                            let authToken;
                            if (this.authenticationService.authorizationToken() === undefined) {
                    
                    
                    Severity: Minor
                    Found in src/app/core/interceptors/jwt.interceptor.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 value + 'th';
                    Severity: Major
                    Found in src/app/shared/pipes/ordinal.pipe.ts - About 30 mins to fix

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

                        validateName() {
                          if (
                            (this.academicYearForm.get('name').dirty ||
                              this.academicYearForm.get('name').touched) &&
                            !this.academicYearForm.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 validateDateOfBirth has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        validateDateOfBirth() {
                          if ((this.userIdentificaionForm.get('dateOfBirth').dirty || this.userIdentificaionForm.get('dateOfBirth').touched) &&
                            !this.userIdentificaionForm.get('dateOfBirth').valid) {
                            if (this.userIdentificaionForm.get('dateOfBirth').errors.required) {
                              this.errors.dateOfBirth = 'Date Of Birth is 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