Showing 4,504 of 4,504 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function __construct(
IUserManager $userManager,
IGroupManager $groupManager,
ILockingProvider $lockingProvider,
IMimeTypeLoader $mimeTypeLoader,
- 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 107.
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
Function createDragShadow
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
var createDragShadow = function(event) {
// FIXME: inject file list instance somehow
/* global FileList, Files */
//select dragged file
Function _updateDetailsView
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
_updateDetailsView: function(fileName, show) {
if (!this._detailsView) {
return;
}
Function addResults
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function addResults(results) {
var $template = $searchResults.find('tr.template');
jQuery.each(results, function (i, result) {
var $row = $template.clone();
$row.removeClass('template');
Method sendTestMail
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function sendTestMail() {
$email = $this->request->getParam('mail_to_address');
if (empty($email)) {
$email = $this->userSession->getUser()->getEMailAddress();
Method getMissingInitiator
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getMissingInitiator($n = 1000) {
$query = $this->connection->getQueryBuilder();
$query->select(['id', 'uid_owner', 'share_type'])
->from($this->table)
->where($query->expr()->in(
Method acceptShare
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function acceptShare($id) {
$share = $this->getShare($id);
if ($share) {
$mountPoint = $this->getShareRecipientMountPoint($share);
Method emitAccessShareHook
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function emitAccessShareHook($share, $errorCode = 200, $errorMessage = '') {
$itemType = $itemSource = $uidOwner = '';
$token = $share;
$exception = null;
if ($share instanceof \OCP\Share\IShare) {
Method parseRetentionObligation
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function parseRetentionObligation() {
$splitValues = \explode(',', $this->retentionObligation);
if (!isset($splitValues[0])) {
$minValue = self::DEFAULT_RETENTION_OBLIGATION;
} else {
Method createConfidentialObject
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static function createConfidentialObject($calData) {
$vObject = Reader::read($calData);
/** @var Component $vElement */
$vElement = null;
Method unshare
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function unshare($remoteId, $shareToken) {
$query = $this->dbConnection->getQueryBuilder();
$query->select('*')->from($this->externalShareTable)
->where(
$query->expr()->eq(
Method copy
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function copy($source, $destination) {
if (!$this->fileView) {
throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup');
}
Method loadChildrenProperties
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function loadChildrenProperties(INode $node, $requestedProperties) {
// note: pre-fetching only supported for depth <= 1
if (!($node instanceof Directory)) {
return;
}
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':
Method verifyPath
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function verifyPath($path, $fileName) {
$l10n = \OC::$server->getL10N('lib');
// verify empty and dot files
$trimmed = \trim($fileName);
Method touch
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function touch($path, $mtime = null) {
$this->init();
if ($mtime === null) {
$mtime = \OC::$server->getTimeFactory()->getTime();
}
Method getTempBaseDir
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getTempBaseDir(): string {
if ($this->tmpBaseDir) {
return $this->tmpBaseDir;
}
Method getTagsForObjects
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getTagsForObjects(array $objIds) {
$entries = [];
try {
$conn = \OC::$server->getDatabaseConnection();
Method splitUserRemote
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function splitUserRemote($id) {
if (\strpos($id, '@') === false) {
$l = \OC::$server->getL10N('lib');
$hint = $l->t('Invalid Federated Cloud ID');
throw new HintException('Invalid Federated Cloud ID', $hint);
Method run
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run(IOutput $out) {
$ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0');
// NOTE TO DEVELOPERS: when adding new mime types, please make sure to
// add a version comparison to avoid doing it every time