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>
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:
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+
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');
Method translate
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode) {
Avoid too many return
statements within this method. Open
return (string) $l->t('Removed share of group %2$s', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('You shared %1$s with group %2$s', $params);
Avoid too many return
statements within this method. Open
return [
0 => 'file',
1 => 'username',
2 => 'username',
];
Avoid too many return
statements within this method. Open
return (string) $l->t('The share for %1$s expired', $params);
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return (string) $l->t('Shared via link by %2$s', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('You shared %1$s with %2$s', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('%2$s removed the share for %1$s', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('Unshared %1$s from self', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('Shared with group %3$s by %2$s', $params);
Avoid too many return
statements within this method. Open
return [0 => 'file', 1 => 'username'];
Avoid too many return
statements within this method. Open
return (string) $l->t('You unshared %1$s shared by %2$s from self', $params);
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);
Avoid too many return
statements within this method. Open
return (string) $l->t('Your public link for %1$s expired', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('%2$s removed share for %3$s', $params);
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return [
0 => 'file',
1 => 'group',
];
Avoid too many return
statements within this method. Open
return (string) $l->t('Public shared folder %1$s was downloaded', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('Public shared file %1$s was downloaded', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('You removed the share of %2$s for %1$s', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('The public link of %2$s for %1$s expired', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('%2$s shared %1$s with you', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('%2$s removed share of group %3$s', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('Shared by %2$s', $params);
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return (string) $l->t('%2$s shared %1$s with %3$s', $params);
Avoid too many return
statements within this method. Open
return [
0 => 'file',
1 => 'username',
2 => 'group',
];
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);
Avoid too many return
statements within this method. Open
return (string) $l->t('You removed the public link for %1$s', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('%2$s removed the public link for %1$s', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('Shared with group %2$s', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('Public link expired', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('Public link of %2$s expired', $params);
Avoid too many return
statements within this method. Open
return [
0 => 'file',
1 => '',// 'email' is neither supported nor planned for now
];
Avoid too many return
statements within this method. Open
return (string) $l->t('Shared via public link');
Avoid too many return
statements within this method. Open
return (string) $l->t('Shared with %2$s', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('%2$s shared %1$s with group %3$s', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('You shared %1$s via link', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('Received federated share from %s', $params);
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);
Avoid too many return
statements within this method. Open
return (string) $l->t('%2$s shared %1$s via link', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('You shared %1$s with %2$s', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('%2$s removed public link');
Avoid too many return
statements within this method. Open
return [0 => 'file', 1 => 'username'];
Avoid too many return
statements within this method. Open
return (string) $l->t('%1$s unshared %2$s from you', $params);
Avoid too many return
statements within this method. Open
return (string) $l->t('Removed public link');
Avoid too many return
statements within this method. Open
return [
0 => 'file',
1 => 'username',
2 => '',
];
Avoid too many return
statements within this method. Open
return (string) $l->t('Received federated share from %1$s', $params);
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;
}
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76