lib/private/DateTimeFormatter.php
Consider simplifying this complex logical expression. Open
Open
if ($dateInterval->y == 0 && $dateInterval->m == 0 && $dateInterval->d == 0) {
return (string) $l->t('today');
} elseif ($dateInterval->y == 0 && $dateInterval->m == 0 && $dateInterval->d == 1) {
return (string) $l->t('yesterday');
} elseif ($dateInterval->y == 0 && $dateInterval->m == 0) {
Function formatDateSpan
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
public function formatDateSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null) {
$l = $this->getLocale($l);
$timestamp = $this->getDateTime($timestamp);
$timestamp->setTime(0, 0, 0);
if ($baseTimestamp === null) {
- 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
Method formatDateTimeRelativeDay
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
public function formatDateTimeRelativeDay($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null) {
Method format
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
protected function format($timestamp, $type, $format, \DateTimeZone $timeZone = null, \OCP\IL10N $l = null) {
Method formatDateTime
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
public function formatDateTime($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null) {
Avoid too many return
statements within this method. Open
Open
return (string) $l->n('%n month ago', '%n months ago', $dateInterval->m);
Avoid too many return
statements within this method. Open
Open
return (string) $l->t('last year');
Avoid too many return
statements within this method. Open
Open
return (string) $l->n('%n year ago', '%n years ago', $dateInterval->y);