From f8f60426fb505cafde256c3505aed78ab70bcb68 Mon Sep 17 00:00:00 2001
From: Theodoros Katzalis <thodkatz@gmail.com>
Date: Fri, 15 Mar 2019 22:35:44 +0200
Subject: [PATCH] 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

---
 src/Helpers/TimeAndDate.cpp | 105 ++++++++++++++++++++++++------------
 1 file changed, 72 insertions(+), 33 deletions(-)

diff --git a/src/Helpers/TimeAndDate.cpp b/src/Helpers/TimeAndDate.cpp
index 1d93ac5e..0c5a1899 100644
--- a/src/Helpers/TimeAndDate.cpp
+++ b/src/Helpers/TimeAndDate.cpp
@@ -1,183 +1,221 @@
 #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;
+
+}
-- 
GitLab