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: '',
- Read upRead up
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:
Function get
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
get(key: string): IMessage {
switch (key) {
case 'ERROR':
return {
type: 'error',
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
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) {
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: '',
- Read upRead up
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';
- Read upRead up
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';
- Read upRead up
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) {
- Read upRead up
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) {
- Read upRead up
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) {
- Read upRead up
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) {
- Read upRead up
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';
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
- Read upRead up
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';
- Read upRead up
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"