owncloud/core

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

Summary

Maintainability
F
4 days
Test Coverage

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

<?php
/**
 * @author Björn Schießle <bjoern@schiessle.org>
 * @author Joas Schilling <coding@schilljs.com>
 * @author Morris Jobke <hey@morrisjobke.de>
Severity: Minor
Found in apps/files_sharing/lib/Activity.php - About 3 hrs to fix

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

        public function getSpecialParameterList($app, $text) {
            if ($app === self::FILES_SHARING_APP) {
                switch ($text) {
                    case self::SUBJECT_REMOTE_SHARE_RECEIVED:
                    case self::SUBJECT_REMOTE_SHARE_UNSHARED:
    Severity: Major
    Found in apps/files_sharing/lib/Activity.php - About 2 hrs to fix

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

          protected function translateLong($text, IL10N $l, array $params) {
              switch ($text) {
                  case self::SUBJECT_REMOTE_SHARE_RECEIVED:
                      if (\sizeof($params) > 1) {
                          // New activity ownCloud 8.2+
      Severity: Major
      Found in apps/files_sharing/lib/Activity.php - About 2 hrs to fix

        Method translateShort has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function translateShort($text, IL10N $l, array $params) {
                switch ($text) {
                    case self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED:
                    case self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED:
                        return (string) $l->t('Downloaded via public link');
        Severity: Minor
        Found in apps/files_sharing/lib/Activity.php - About 1 hr 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_sharing/lib/Activity.php - About 45 mins to fix

            Avoid too many return statements within this method.
            Open

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

              Avoid too many return statements within this method.
              Open

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

                Avoid too many return statements within this method.
                Open

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

                  Avoid too many return statements within this method.
                  Open

                                      return (string) $l->t('The share for %1$s expired', $params);
                  Severity: Major
                  Found in apps/files_sharing/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_sharing/lib/Activity.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

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

                        Avoid too many return statements within this method.
                        Open

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

                          Avoid too many return statements within this method.
                          Open

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

                            Avoid too many return statements within this method.
                            Open

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

                              Avoid too many return statements within this method.
                              Open

                                              return (string) $l->t('Shared with group %3$s by %2$s', $params);
                              Severity: Major
                              Found in apps/files_sharing/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_sharing/lib/Activity.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

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

                                    Avoid too many return statements within this method.
                                    Open

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

                                      Avoid too many return statements within this method.
                                      Open

                                                      return (string) $l->t('Your public link for %1$s expired', $params);
                                      Severity: Major
                                      Found in apps/files_sharing/lib/Activity.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                        return (string) $l->t('%2$s removed share for %3$s', $params);
                                        Severity: Major
                                        Found in apps/files_sharing/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_sharing/lib/Activity.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

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

                                              Avoid too many return statements within this method.
                                              Open

                                                              return (string) $l->t('Public shared folder %1$s was downloaded', $params);
                                              Severity: Major
                                              Found in apps/files_sharing/lib/Activity.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                                return (string) $l->t('Public shared file %1$s was downloaded', $params);
                                                Severity: Major
                                                Found in apps/files_sharing/lib/Activity.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

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

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                    return (string) $l->t('The public link of %2$s for %1$s expired', $params);
                                                    Severity: Major
                                                    Found in apps/files_sharing/lib/Activity.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

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

                                                        Avoid too many return statements within this method.
                                                        Open

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

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                          return (string) $l->t('Shared by %2$s', $params);
                                                          Severity: Major
                                                          Found in apps/files_sharing/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_sharing/lib/Activity.php - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

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

                                                                Avoid too many return statements within this method.
                                                                Open

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

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                                  return (string) $l->t('You removed the share of group %2$s for %1$s', $params);
                                                                  Severity: Major
                                                                  Found in apps/files_sharing/lib/Activity.php - About 30 mins to fix

                                                                    Avoid too many return statements within this method.
                                                                    Open

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

                                                                      Avoid too many return statements within this method.
                                                                      Open

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

                                                                        Avoid too many return statements within this method.
                                                                        Open

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

                                                                          Avoid too many return statements within this method.
                                                                          Open

                                                                                          return (string) $l->t('Public link expired', $params);
                                                                          Severity: Major
                                                                          Found in apps/files_sharing/lib/Activity.php - About 30 mins to fix

                                                                            Avoid too many return statements within this method.
                                                                            Open

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

                                                                              Avoid too many return statements within this method.
                                                                              Open

                                                                                                  return [
                                                                                                      0 => 'file',
                                                                                                      1 => '',// 'email' is neither supported nor planned for now
                                                                                                  ];
                                                                              Severity: Major
                                                                              Found in apps/files_sharing/lib/Activity.php - About 30 mins to fix

                                                                                Avoid too many return statements within this method.
                                                                                Open

                                                                                                return (string) $l->t('Shared via public link');
                                                                                Severity: Major
                                                                                Found in apps/files_sharing/lib/Activity.php - About 30 mins to fix

                                                                                  Avoid too many return statements within this method.
                                                                                  Open

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

                                                                                    Avoid too many return statements within this method.
                                                                                    Open

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

                                                                                      Avoid too many return statements within this method.
                                                                                      Open

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

                                                                                        Avoid too many return statements within this method.
                                                                                        Open

                                                                                                        return (string) $l->t('Received federated share from %s', $params);
                                                                                        Severity: Major
                                                                                        Found in apps/files_sharing/lib/Activity.php - About 30 mins to fix

                                                                                          Avoid too many return statements within this method.
                                                                                          Open

                                                                                                          return (string) $l->t('%2$s removed the share of group %3$s for %1$s', $params);
                                                                                          Severity: Major
                                                                                          Found in apps/files_sharing/lib/Activity.php - About 30 mins to fix

                                                                                            Avoid too many return statements within this method.
                                                                                            Open

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

                                                                                              Avoid too many return statements within this method.
                                                                                              Open

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

                                                                                                Avoid too many return statements within this method.
                                                                                                Open

                                                                                                                return (string) $l->t('%2$s removed public link');
                                                                                                Severity: Major
                                                                                                Found in apps/files_sharing/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_sharing/lib/Activity.php - About 30 mins to fix

                                                                                                    Avoid too many return statements within this method.
                                                                                                    Open

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

                                                                                                      Avoid too many return statements within this method.
                                                                                                      Open

                                                                                                                      return (string) $l->t('Removed public link');
                                                                                                      Severity: Major
                                                                                                      Found in apps/files_sharing/lib/Activity.php - About 30 mins to fix

                                                                                                        Avoid too many return statements within this method.
                                                                                                        Open

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

                                                                                                          Avoid too many return statements within this method.
                                                                                                          Open

                                                                                                                              return (string) $l->t('Received federated share from %1$s', $params);
                                                                                                          Severity: Major
                                                                                                          Found in apps/files_sharing/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::FILES_SHARING_APP) {
                                                                                                                        return false;
                                                                                                                    }
                                                                                                            
                                                                                                            
                                                                                                            Severity: Major
                                                                                                            Found in apps/files_sharing/lib/Activity.php and 3 other locations - About 1 hr to fix
                                                                                                            apps/comments/lib/Activity/Extension.php on lines 130..145
                                                                                                            apps/files/lib/Activity.php on lines 156..171
                                                                                                            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