owncloud/core

View on GitHub

Showing 4,504 of 4,504 total issues

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

        if (! \pg_fetch_row($result)) {
            //user does not exist, so let's create them :)
            $query = "CREATE USER \"$e_name\" CREATEDB PASSWORD '$e_password';";
            $result = \pg_query($connection, $query);
            if (!$result) {
Severity: Major
Found in lib/private/Setup/PostgreSQL.php and 1 other location - About 1 hr to fix
lib/private/Setup/PostgreSQL.php on lines 167..175

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

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

        } else { // change password of the existing role
            $query = "ALTER ROLE \"$e_name\" WITH PASSWORD '$e_password';";
            $result = \pg_query($connection, $query);
            if (!$result) {
                $entry = $this->trans->t('DB Error: "%s"', [\pg_last_error($connection)]) . '<br />';
Severity: Major
Found in lib/private/Setup/PostgreSQL.php and 1 other location - About 1 hr to fix
lib/private/Setup/PostgreSQL.php on lines 158..175

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

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 rebuildNavigation has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    rebuildNavigation: function() {
        $.getJSON(OC.filePath('settings', 'ajax', 'navigationdetect.php')).done(function(response){
            if(response.status === 'success'){
                var idsToKeep = {};
                var navEntries=response.nav_entries;
Severity: Minor
Found in settings/js/admin-apps.js - 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

Function prompt has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    prompt: function (text, title, callback, modal, name, password, buttonDeclineText, buttonConfirmText) {
        return $.when(this._getMessageTemplate()).then(function ($tmpl) {
            var dialogName = 'oc-dialog-' + OCdialogs.dialogsCounter + '-content';
            var dialogId = '#' + dialogName;
            var $dlg = $tmpl.octemplate({
Severity: Minor
Found in core/js/oc-dialogs.js - 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

Function testRemoteUrl has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function testRemoteUrl(IClientService $clientService, string $remote) {
        $parsed_host = parse_url($remote, PHP_URL_HOST);
        $parsed_port = parse_url($remote, PHP_URL_PORT);
        if (\is_string($parsed_host)) {
            $remote = $parsed_host;
Severity: Minor
Found in apps/files_sharing/lib/External/Manager.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

Function checkStorageAvailability has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function checkStorageAvailability() {
        // WARNING: Disabling this setting is recommended only in tightly integrated federated setups as temporarly setting,
        // should NOT be used in decentralized federation setup. It could cause bad user experience when dealing
        // with deleted external shares
        // NOTE: This allows administrator to disable cleanup of invalid shares so only manual removal by user or admin is possible,
Severity: Minor
Found in apps/files_sharing/lib/External/Storage.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

Function updateShareState has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function updateShareState($id, $state) {
        $eventName = '';
        if ($state === Share::STATE_ACCEPTED) {
            $eventName = 'accept';
        } elseif ($state === Share::STATE_REJECTED) {
Severity: Minor
Found in apps/files_sharing/lib/Controller/Share20OcsController.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

Function copy_recursive has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private static function copy_recursive($source, $destination, View $view) {
        $size = 0;
        if ($view->is_dir($source)) {
            $view->mkdir($destination);
            $view->touch($destination, $view->filemtime($source));
Severity: Minor
Found in apps/files_trashbin/lib/Trashbin.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

Function expireTrash has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function expireTrash(string $uid) {
        $trashBinSize = Trashbin::getTrashbinSize($uid);
        $availableSpace = $this->quota->calculateFreeSpace($trashBinSize, $uid);

        // delete all files older then $retention_obligation
Severity: Minor
Found in apps/files_trashbin/lib/TrashExpiryManager.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

Function getCalendarsForUser has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function getCalendarsForUser($principalUri) {
        $principalUriOriginal = $principalUri;
        $principalUri = $this->convertPrincipal($principalUri, true);
        $fields = \array_values($this->propertyMap);
        $fields[] = 'id';
Severity: Minor
Found in apps/dav/lib/CalDAV/CalDavBackend.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

Function getChild has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function getChild($name) {
        // Special nodes
        if ($name === 'inbox' && $this->caldavBackend instanceof SchedulingSupport) {
            return new Inbox($this->caldavBackend, $this->principalInfo['uri']);
        }
Severity: Minor
Found in apps/dav/lib/CalDAV/CalendarHome.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

Function httpGet has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function httpGet(RequestInterface $request, ResponseInterface $response) {
        // Only handle valid files
        $node = $this->tree->getNodeForPath($request->getPath());
        if (!($node instanceof IFile)) {
            return;
Severity: Minor
Found in apps/dav/lib/Connector/Sabre/FilesPlugin.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

Function parseRetentionObligation has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function parseRetentionObligation() {
        $splitValues = \explode(',', $this->retentionObligation);
        if (!isset($splitValues[0])) {
            $minValue = 'auto';
        } else {
Severity: Minor
Found in apps/files_versions/lib/Expiration.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

Function renameOrCopy has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public static function renameOrCopy($sourcePath, $targetPath, $operation) {
        list($sourceOwner, $sourcePath) = self::getSourcePathAndUser($sourcePath);

        // it was a upload of a existing file if no old path exists
        // in this case the pre-hook already called the store method and we can
Severity: Minor
Found in apps/files_versions/lib/Storage.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

Function pixelArrayToImage has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function pixelArrayToImage() {
        $x = 0;
        $y = 0;
        foreach ($this->pixelArray as $pixelRow) {
            foreach ($pixelRow as $column) {
Severity: Minor
Found in lib/private/Image/BmpToResource.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 14 arguments (exceeds 4 allowed). Consider refactoring.
Open

        IL10N $l,
        IAppManager $appManager,
        IUserSession $userSession,
        ILogger $logger,
        IGroupManager $groupManager,
Severity: Major
Found in lib/private/Settings/SettingsManager.php - About 1 hr to fix

    Function doFind has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        public function doFind($script) {
            $fullScript = $this->addExtension($script);
            $themeDirectory = $this->theme->getDirectory();
            $baseDirectory = $this->theme->getBaseDirectory();
            $webRoot = '';
    Severity: Minor
    Found in lib/private/Template/JSResourceLocator.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

    Function rename has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        public function rename($path1, $path2) {
            $srcParent = \dirname($path1);
            $dstParent = \dirname($path2);
    
            if (!$this->isUpdatable($srcParent)) {
    Severity: Minor
    Found in lib/private/Files/Storage/Local.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

    Function get has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        public function get($file) {
            if (\is_string($file) or $file == '') {
                // normalize file
                $file = $this->normalize($file);
    
    
    Severity: Minor
    Found in lib/private/Files/Cache/Cache.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

    Function createDBUser has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        private function createDBUser($connection) {
            $name = $this->dbUser;
            $password = $this->dbPassword;
            $query = 'SELECT * FROM all_users WHERE USERNAME = :un';
            $stmt = \oci_parse($connection, $query);
    Severity: Minor
    Found in lib/private/Setup/OCI.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

    Severity
    Category
    Status
    Source
    Language