owncloud/core

View on GitHub
lib/private/DateTimeFormatter.php

Summary

Maintainability
B
5 hrs
Test Coverage

Consider simplifying this complex logical expression.
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) {
Severity: Major
Found in lib/private/DateTimeFormatter.php - About 1 hr to fix

    Function formatDateSpan has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    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) {
    Severity: Minor
    Found in lib/private/DateTimeFormatter.php - About 55 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

    Method formatDateTimeRelativeDay has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function formatDateTimeRelativeDay($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null) {
    Severity: Minor
    Found in lib/private/DateTimeFormatter.php - About 35 mins to fix

      Method format has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          protected function format($timestamp, $type, $format, \DateTimeZone $timeZone = null, \OCP\IL10N $l = null) {
      Severity: Minor
      Found in lib/private/DateTimeFormatter.php - About 35 mins to fix

        Method formatDateTime has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function formatDateTime($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null) {
        Severity: Minor
        Found in lib/private/DateTimeFormatter.php - About 35 mins to fix

          Avoid too many return statements within this method.
          Open

                      return (string) $l->n('%n month ago', '%n months ago', $dateInterval->m);
          Severity: Major
          Found in lib/private/DateTimeFormatter.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return (string) $l->t('last year');
            Severity: Major
            Found in lib/private/DateTimeFormatter.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return (string) $l->n('%n year ago', '%n years ago', $dateInterval->y);
              Severity: Major
              Found in lib/private/DateTimeFormatter.php - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status