Skip to content
Snippets Groups Projects
Commit f8f60426 authored by Theodoros Katzalis's avatar Theodoros Katzalis
Browse files

Clang-tidy complaints, so the if-else structure of the implementation of the...

Clang-tidy complaints, so the if-else structure of the implementation of the operators changed. The code is a little bit ugly so it should be evaluated
parent 742ea082
No related branches found
No related tags found
No related merge requests found
#include "Helpers/TimeHelper.hpp"
bool TimeAndDate::operator<(const TimeAndDate &Date) {
//@note clang tidy complaints when using else after return so that's why there are these
// numerous if checks. Sorry for the ugly code...
// compare years
if (this->year < Date.year) {
return true;
} else if (this->year > Date.year) {
}
if (this->year > Date.year) {
return false;
}
// compare months
if (this->month < Date.month) {
return true;
} else if (this->month > Date.month) {
}
if (this->month > Date.month) {
return false;
}
// compare days
if (this->day < Date.day) {
return true;
} else if (this->day > Date.day) {
}
if (this->day > Date.day) {
return false;
}
// compare hours
if (this->hour < Date.hour) {
return true;
} else if (this->hour > Date.hour) {
}
if (this->hour > Date.hour) {
return false;
}
// compare minutes
if (this->minute < Date.minute) {
return true;
} else if (this->minute > Date.minute) {
}
if (this->minute > Date.minute) {
return false;
}
// compare seconds
if (this->second < Date.second) {
return true;
} else {
return false;
}
return false;
}
bool TimeAndDate::operator>(const TimeAndDate &Date) {
//@note clang tidy complaints when using else after return so that's why there are these
// numerous if checks. Sorry for the ugly code...
// compare years
if (this->year > Date.year) {
return true;
} else if (this->year < Date.year) {
}
if (this->year < Date.year) {
return false;
}
// compare months
if (this->month > Date.month) {
return true;
} else if (this->month < Date.month) {
}
if (this->month < Date.month) {
return false;
}
// compare days
if (this->day > Date.day) {
return true;
} else if (this->day < Date.day) {
}
if (this->day < Date.day) {
return false;
}
// compare hours
if (this->hour > Date.hour) {
return true;
} else if (this->hour < Date.hour) {
}
if (this->hour < Date.hour) {
return false;
}
// compare minutes
if (this->minute > Date.minute) {
return true;
} else if (this->minute < Date.minute) {
}
if (this->minute < Date.minute) {
return false;
}
// compare seconds
if (this->second > Date.second) {
return true;
} else {
return false;
}
return false;
}
bool TimeAndDate::operator<=(const TimeAndDate &Date) {
//@note clang tidy complaints when using else after return so that's why there are these
// numerous if checks. Sorry for the ugly code...
// compare years
if (this->year < Date.year) {
return true;
} else if (this->year > Date.year) {
}
if (this->year > Date.year) {
return false;
}
// compare months
if (this->month < Date.month) {
return true;
} else if (this->month > Date.month) {
}
if (this->month > Date.month) {
return false;
}
// compare days
if (this->day < Date.day) {
return true;
} else if (this->day > Date.day) {
}
if (this->day > Date.day) {
return false;
}
// compare hours
if (this->hour < Date.hour) {
return true;
} else if (this->hour > Date.hour) {
}
if (this->hour > Date.hour) {
return false;
}
// compare minutes
if (this->minute < Date.minute) {
return true;
} else if (this->minute > Date.minute) {
}
if (this->minute > Date.minute) {
return false;
}
// compare seconds
if (this->second < Date.second) {
return true;
} else if (this->second > Date.second) {
}
if (this->second > Date.second) {
return false;
} else {
return true;
}
return true;
}
bool TimeAndDate::operator>=(const TimeAndDate &Date) {
//@note clang tidy complaints when using else after return so that's why there are these
// numerous if checks. Sorry for the ugly code...
// compare years
if (this->year > Date.year) {
return true;
} else if (this->year < Date.year) {
}
if (this->year < Date.year) {
return false;
}
// compare months
if (this->month > Date.month) {
return true;
} else if (this->month < Date.month) {
}
if (this->month < Date.month) {
return false;
}
// compare days
if (this->day > Date.day) {
return true;
} else if (this->day < Date.day) {
}
if (this->day < Date.day) {
return false;
}
// compare hours
if (this->hour > Date.hour) {
return true;
} else if (this->hour < Date.hour) {
}
if (this->hour < Date.hour) {
return false;
}
// compare minutes
if (this->minute > Date.minute) {
return true;
} else if (this->minute < Date.minute) {
}
if (this->minute < Date.minute) {
return false;
}
// compare seconds
if (this->second > Date.second) {
return true;
} else if (this->second < Date.second) {
}
if (this->second < Date.second) {
return false;
} else {
return true;
}
return true;
}
bool TimeAndDate::operator==(const TimeAndDate &Date) {
......@@ -209,7 +247,8 @@ bool TimeAndDate::operator==(const TimeAndDate &Date) {
// compare seconds
if (this->second != Date.second) {
return false;
} else {
return true;
}
}
\ No newline at end of file
return true;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment