owncloud/core

View on GitHub
apps/files/lib/Activity.php

Summary

Maintainability
F
3 days
Test Coverage

File Activity.php has 311 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @author Joas Schilling <coding@schilljs.com>
 * @author Morris Jobke <hey@morrisjobke.de>
 * @author Thomas Müller <thomas.mueller@tmit.eu>
Severity: Minor
Found in apps/files/lib/Activity.php - About 3 hrs to fix

    Method getSpecialParameterList has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getSpecialParameterList($app, $text) {
            if ($app === self::APP_FILES) {
                switch ($text) {
                    case 'created_self':
                        return [
    Severity: Major
    Found in apps/files/lib/Activity.php - About 2 hrs to fix

      Method getQueryForFilter has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getQueryForFilter($filter) {
              $user = $this->activityManager->getCurrentUserId();
              // Display actions from all files
              if ($filter === self::FILTER_FILES) {
                  return ['`app` = ?', [self::APP_FILES]];
      Severity: Minor
      Found in apps/files/lib/Activity.php - About 1 hr to fix

        Method translateLong has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function translateLong($text, IL10N $l, array $params) {
                switch ($text) {
                    case 'created_self':
                        return (string) $l->t('You created %1$s', $params);
                    case 'created_by':
        Severity: Minor
        Found in apps/files/lib/Activity.php - About 1 hr to fix

          Function getQueryForFilter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getQueryForFilter($filter) {
                  $user = $this->activityManager->getCurrentUserId();
                  // Display actions from all files
                  if ($filter === self::FILTER_FILES) {
                      return ['`app` = ?', [self::APP_FILES]];
          Severity: Minor
          Found in apps/files/lib/Activity.php - About 1 hr 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 __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function __construct(IFactory $languageFactory, IURLGenerator $URLGenerator, IManager $activityManager, ActivityHelper $helper, IDBConnection $connection, IConfig $config) {
          Severity: Minor
          Found in apps/files/lib/Activity.php - About 45 mins to fix

            Method translate has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode) {
            Severity: Minor
            Found in apps/files/lib/Activity.php - About 45 mins to fix

              Avoid too many return statements within this method.
              Open

                              return (string) $l->t('%2$s moved %3$s to %1$s', $params);
              Severity: Major
              Found in apps/files/lib/Activity.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return false;
                Severity: Major
                Found in apps/files/lib/Activity.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return false;
                  Severity: Major
                  Found in apps/files/lib/Activity.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                        return [
                                            0 => 'file',
                                        ];
                    Severity: Major
                    Found in apps/files/lib/Activity.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return 'icon-move';
                      Severity: Major
                      Found in apps/files/lib/Activity.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return (string) $l->t('%2$s deleted %1$s', $params);
                        Severity: Major
                        Found in apps/files/lib/Activity.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return (string) $l->t('%2$s moved this file to %1$s', $params);
                          Severity: Major
                          Found in apps/files/lib/Activity.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                return [
                                                    0 => 'file',
                                                    1 => 'file',
                                                ];
                            Severity: Major
                            Found in apps/files/lib/Activity.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                      return false;
                              Severity: Major
                              Found in apps/files/lib/Activity.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                    return [
                                                        0 => 'file',
                                                    ];
                                Severity: Major
                                Found in apps/files/lib/Activity.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                  return (string) $l->t('%2$s changed %1$s', $params);
                                  Severity: Major
                                  Found in apps/files/lib/Activity.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                    return false;
                                    Severity: Major
                                    Found in apps/files/lib/Activity.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                      return (string) $l->t('You deleted %1$s', $params);
                                      Severity: Major
                                      Found in apps/files/lib/Activity.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                        return (string) $l->t('You restored %1$s', $params);
                                        Severity: Major
                                        Found in apps/files/lib/Activity.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                          return (string) $l->t('You renamed %2$s to %1$s', $params);
                                          Severity: Major
                                          Found in apps/files/lib/Activity.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                                return [
                                                                    0 => 'file',
                                                                    1 => 'username',
                                                                ];
                                            Severity: Major
                                            Found in apps/files/lib/Activity.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                              return (string) $l->t('You moved %2$s to %1$s', $params);
                                              Severity: Major
                                              Found in apps/files/lib/Activity.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                                    return [
                                                                        0 => 'file',
                                                                        1 => 'username',
                                                                        2 => 'file',
                                                                    ];
                                                Severity: Major
                                                Found in apps/files/lib/Activity.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                                      return [
                                                                          0 => 'file',
                                                                          1 => 'username',
                                                                          2 => 'file',
                                                                      ];
                                                  Severity: Major
                                                  Found in apps/files/lib/Activity.php - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                        return [
                                                                            0 => 'file',
                                                                            1 => 'username',
                                                                        ];
                                                    Severity: Major
                                                    Found in apps/files/lib/Activity.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                                      return (string) $l->t('%2$s restored %1$s', $params);
                                                      Severity: Major
                                                      Found in apps/files/lib/Activity.php - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                            return [
                                                                                0 => 'file',
                                                                                1 => 'file',
                                                                            ];
                                                        Severity: Major
                                                        Found in apps/files/lib/Activity.php - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                              return (string) $l->t('%1$s was deleted due to automation rule', $params);
                                                          Severity: Major
                                                          Found in apps/files/lib/Activity.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                            return (string) $l->t('%2$s renamed %3$s to %1$s', $params);
                                                            Severity: Major
                                                            Found in apps/files/lib/Activity.php - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                              return false;
                                                              Severity: Major
                                                              Found in apps/files/lib/Activity.php - About 30 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                                    return [
                                                                                        0 => 'file',
                                                                                        1 => 'username',
                                                                                    ];
                                                                Severity: Major
                                                                Found in apps/files/lib/Activity.php - About 30 mins to fix

                                                                  Similar blocks of code found in 4 locations. Consider refactoring.
                                                                  Open

                                                                      public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode) {
                                                                          if ($app !== self::APP_FILES) {
                                                                              return false;
                                                                          }
                                                                  
                                                                  
                                                                  Severity: Major
                                                                  Found in apps/files/lib/Activity.php and 3 other locations - About 1 hr to fix
                                                                  apps/comments/lib/Activity/Extension.php on lines 130..145
                                                                  apps/files_sharing/lib/Activity.php on lines 173..188
                                                                  apps/systemtags/lib/Activity/Extension.php on lines 120..135

                                                                  Duplicated Code

                                                                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                  Tuning

                                                                  This issue has a mass of 118.

                                                                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                  Refactorings

                                                                  Further Reading

                                                                  There are no issues that match your filters.

                                                                  Category
                                                                  Status