owncloud/core

View on GitHub

Showing 4,504 of 4,504 total issues

Identical blocks of code found in 5 locations. Consider refactoring.
Open

            this._client.request(
                'PUT',
                this._buildUrl(path),
                headers,
                body || ''
Severity: Major
Found in core/js/files/client.js and 4 other locations - About 2 hrs to fix
core/js/files/client.js on lines 684..696
core/js/files/client.js on lines 726..739
core/js/files/client.js on lines 762..776
core/js/files/client.js on lines 805..820

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 87.

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

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

  return "    <li class=\"tabHeader\" data-tabid=\""
    + alias4(((helper = (helper = helpers.tabId || (depth0 != null ? depth0.tabId : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"tabId","hash":{},"data":data}) : helper)))
Severity: Major
Found in apps/files/js/templates/detailsview.handlebars.js and 2 other locations - About 2 hrs to fix
apps/files/js/templates/detailsview.handlebars.js on lines 12..15
apps/files/js/templates/detailsview.handlebars.js on lines 12..17

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 87.

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

Function listen has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    listen:function(type,callback){
        if(callback && callback.call){

            if(type){
                if(this.useFallBack){
Severity: Minor
Found in core/js/eventsource.js - About 2 hrs 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

Function restore has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public static function restore($filename, $targetLocation = null) {
        $user = User::getUser();
        $view = new View('/' . $user);
        $nameOfFile = \basename($filename);
        $dirOfFile = \dirname($filename);
Severity: Minor
Found in apps/files_trashbin/lib/Trashbin.php - About 2 hrs 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

Function removeFromGroup has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function removeFromGroup($parameters) {
        // Check if user is logged in
        $loggedInUser = $this->userSession->getUser();
        if ($loggedInUser === null) {
            return new Result(null, API::RESPOND_UNAUTHORISED);
Severity: Minor
Found in apps/provisioning_api/lib/Users.php - About 2 hrs 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

Function store has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public static function store($filename) {
        if (\OC::$server->getConfig()->getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
            // if the file gets streamed we need to remove the .part extension
            // to get the right target
            $ext = \pathinfo($filename, PATHINFO_EXTENSION);
Severity: Minor
Found in apps/files_versions/lib/Storage.php - About 2 hrs 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

Function search has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function search($search, $limit = null, $offset = null, $scope = null, $alwaysReturnAllMatches = false) {
        $groups = [];
        if ($alwaysReturnAllMatches || $this->userSearch->isSearchable($search)) {
            foreach ($this->backends as $backend) {
                if (!$backend->isVisibleForScope($scope)) {
Severity: Minor
Found in lib/private/Group/Manager.php - About 2 hrs 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

Function __construct has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct($params) {
        $this->statCache = new ArrayCache();
        $this->httpClientService = \OC::$server->getHTTPClientService();
        $this->webDavClientService = \OC::$server->getWebDavClientService();
        if (isset($params['host'], $params['user'], $params['password'])) {
Severity: Minor
Found in lib/private/Files/Storage/DAV.php - About 2 hrs 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

Function save has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    protected function save() {
        if (\is_array($this->tags)) {
            foreach ($this->tags as $tag) {
                try {
                    if (!$this->mapper->tagExists($tag)) {
Severity: Minor
Found in lib/private/Tags.php - About 2 hrs 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

Function sendInternalShareMail has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function sendInternalShareMail($sender, $node, $shareType, $recipientList): array {
        if ($this->config->getAppValue('core', 'shareapi_allow_mail_notification', 'no') !== 'yes') {
            $message_t = $this->l->t('Internal mail notification for shared files is not allowed');
            throw new GenericShareException($message_t, $message_t, 403);
        }
Severity: Minor
Found in lib/private/Share/MailNotifications.php - About 2 hrs 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

Function delete has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public static function delete($parent, $excludeParent = false, $uidOwner = null, $newParent = null, $excludeGroupChildren = false) {
        $ids = [$parent];
        $deletedItems = [];
        $changeParent = [];
        $parents = [$parent];
Severity: Minor
Found in lib/private/Share/Helper.php - About 2 hrs 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

Function isAvailable has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function isAvailable(\OCP\Files\FileInfo $file) {
        if (!$this->config->getSystemValue('enable_previews', true)) {
            return false;
        }

Severity: Minor
Found in lib/private/PreviewManager.php - About 2 hrs 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

Function findAppInDirectories has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    protected function findAppInDirectories($appId) {
        $sanitizedAppId = \OC_App::cleanAppId($appId);
        if ($sanitizedAppId !== $appId) {
            return false;
        }
Severity: Minor
Found in lib/private/App/AppManager.php - About 2 hrs 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

Function checkAppForUser has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    private function checkAppForUser($enabled, $appName, $user) {
        if ($user !== null) {
            $userAppAttributes = $user->getExtendedAttributes();
            /**
             * Guests will only have access to some whitelisted apps
Severity: Minor
Found in lib/private/App/AppManager.php - About 2 hrs 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

Function loadRoutes has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function loadRoutes($app = null) {
        if (\is_string($app)) {
            $app = \OC_App::cleanAppId($app);
        }

Severity: Minor
Found in lib/private/Route/Router.php - About 2 hrs 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

Function execute has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    protected function execute(InputInterface $input, OutputInterface $output): int {
        try {
            $this->checkInput($input);
        } catch (\InvalidArgumentException $e) {
            $output->writeln('<error>' . $e->getMessage() . '</error>');
Severity: Minor
Found in core/Command/User/Setting.php - About 2 hrs 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

Function execute has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    protected function execute(InputInterface $input, OutputInterface $output): int {
        $outputType = $input->getOption('output');

        \OC_App::loadApps();
        $this->router->loadRoutes();
Severity: Minor
Found in core/Command/Security/ListRoutes.php - About 2 hrs 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

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

        if (!empty($shipped['failed'])) {
            // Which shipped response do we use if they all failed?
            // They may have failed for different reasons (different status codes)
            // Which response code should we return?
            // Maybe any that are not \OCP\API::RESPOND_SERVER_ERROR
Severity: Major
Found in lib/private/legacy/api.php and 1 other location - About 2 hrs to fix
lib/private/legacy/api.php on lines 265..277

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 133.

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

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

        try {
            $stmt = \OCP\DB::prepare('SELECT `id` FROM `' . self::TAG_TABLE . '` '
                . 'WHERE `uid` = ?');
            $result = $stmt->execute([$arguments['uid']]);
            if (\OCP\DB::isError($result)) {
Severity: Major
Found in lib/private/Tags.php and 1 other location - About 2 hrs to fix
lib/private/Tags.php on lines 570..580

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 133.

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

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

        } elseif (!empty($thirdparty['failed'])) {
            // Merge failed responses if more than one
            $data = [];
            foreach ($thirdparty['failed'] as $failure) {
                $data = \array_merge_recursive($data, $failure['response']->getData());
Severity: Major
Found in lib/private/legacy/api.php and 1 other location - About 2 hrs to fix
lib/private/legacy/api.php on lines 247..279

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 133.

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

Severity
Category
Status
Source
Language