owncloud/core

View on GitHub

Showing 4,504 of 4,504 total issues

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

        $query->andWhere($query->expr()->orX(
            $query->expr()->eq('share_type', $query->createNamedParameter(\OCP\Share::SHARE_TYPE_USER)),
            $query->expr()->eq('share_type', $query->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)),
            $query->expr()->eq('share_type', $query->createNamedParameter(\OCP\Share::SHARE_TYPE_LINK)),
            $query->expr()->eq('share_type', $query->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE))
Severity: Major
Found in apps/files/lib/Command/TroubleshootTransferOwnership.php and 1 other location - About 1 hr to fix
apps/files/lib/Command/TroubleshootTransferOwnership.php on lines 349..369

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

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

    joinPaths: function () {
        if (arguments.length < 1) {
            return '';
        }
        var path = '';
Severity: Minor
Found in core/js/js.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 exec has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function exec($folder, $license, $gitRoot = false) {
        if (isset($this->licenseText[$license])) {
            echo "Unknown license $license. Supported: agpl, gpl or ocl";
        }
        $license = $this->licenseText[$license];
Severity: Minor
Found in build/license.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 getPanel has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function getPanel() {
        // create htaccess test file
        $util = new \OC_Util();
        $util->createHtaccessTestFile($this->config);

Severity: Minor
Found in settings/Panels/Admin/SecurityWarning.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 resolveReshares has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    protected static function resolveReshares($source) {
        if (isset($source['parent'])) {
            $parent = $source['parent'];
            while (isset($parent)) {
                $query = \OCP\DB::prepare('SELECT `parent`, `uid_owner` FROM `*PREFIX*share` WHERE `id` = ?', 1);
Severity: Minor
Found in apps/files_sharing/lib/ShareBackend/File.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 getShareById has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private function getShareById($id, $recipient = null) {
        $share = null;
        $providerIds = \array_keys($this->shareManager->getProvidersCapabilities());
        
        // First check if it is an internal share.
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 syncThemAll has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function syncThemAll(\Closure $callback) {
        $trustedServers = $this->dbHandler->getAllServer();
        foreach ($trustedServers as $trustedServer) {
            $url = $trustedServer['url'];
            $callback($url, null);
Severity: Minor
Found in apps/federation/lib/SyncFederationAddressBooks.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 10 arguments (exceeds 4 allowed). Consider refactoring.
Open

        IDBConnection $connection,
        EventDispatcherInterface $eventDispatcher,
        AddressHandler $addressHandler,
        Notifications $notifications,
        TokenHandler $tokenHandler,
Severity: Major
Found in apps/federatedfilesharing/lib/FederatedShareProvider.php - About 1 hr to fix

    Function getChangesForCalendar has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null) {
            // Current synctoken
            $stmt = $this->db->prepare('SELECT `synctoken` FROM `*PREFIX*calendars` WHERE `id` = ?');
            $stmt->execute([ $calendarId ]);
            $currentToken = $stmt->fetchColumn(0);
    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 create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public function create(IShare $share) {
            $shareWith = $share->getSharedWith();
            $itemSource = $share->getNodeId();
            $itemType = $share->getNodeType();
            $permissions = $share->getPermissions();
    Severity: Minor
    Found in apps/federatedfilesharing/lib/FederatedShareProvider.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 getSharePermissions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getSharePermissions($user) {
            // check of we access a federated share
            if ($user !== null) {
                try {
                    $share = $this->shareManager->getShareByToken($user);
    Severity: Minor
    Found in apps/dav/lib/Connector/Sabre/Node.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 getDavPermissions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getDavPermissions() {
            $p = '';
            if ($this->info->isShared()) {
                $p .= 'S';
            }
    Severity: Minor
    Found in apps/dav/lib/Connector/Sabre/Node.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 splitUserRemote has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public function splitUserRemote($address) {
            if (\strpos($address, '@') === false) {
                $hint = $this->l->t('Invalid Federated Cloud ID');
                throw new HintException('Invalid Federated Cloud ID', $hint);
            }
    Severity: Minor
    Found in apps/federatedfilesharing/lib/AddressHandler.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 createShare has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public function createShare(
            $shareWith,
            $name,
            $description,
            $providerId,
    Severity: Minor
    Found in apps/federatedfilesharing/lib/Controller/OcmController.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 getUsersGroups has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getUsersGroups($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 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 update has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public function update($name, $userVisible, $userAssignable, $userEditable = false) {
            try {
                if (!$this->tagManager->canUserSeeTag($this->tag, $this->user)) {
                    throw new NotFound('Tag with id ' . $this->tag->getId() . ' does not exist');
                }
    Severity: Minor
    Found in apps/dav/lib/SystemTag/SystemTagNode.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 extractCollectionList has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        private function extractCollectionList($array) {
            if (isset($array['sabre']) && \is_array($array['sabre'])) {
                if (isset($array['sabre']['collections']) && \is_array($array['sabre']['collections'])) {
                    if (isset($array['sabre']['collections']['collection'])) {
                        $items = $array['sabre']['collections']['collection'];
    Severity: Minor
    Found in apps/dav/lib/AppInfo/PluginManager.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 updateProperties has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function updateProperties($path, INode $node, $changedProperties) {
            $existingProperties = $this->getProperties($path, $node, []);
    
            // TODO: use "insert or update" strategy ?
            $this->connection->beginTransaction();
    Severity: Minor
    Found in apps/dav/lib/DAV/MiscCustomPropertiesBackend.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 extractPluginList has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        private function extractPluginList($array) {
            if (isset($array['sabre']) && \is_array($array['sabre'])) {
                if (isset($array['sabre']['plugins']) && \is_array($array['sabre']['plugins'])) {
                    if (isset($array['sabre']['plugins']['plugin'])) {
                        $items = $array['sabre']['plugins']['plugin'];
    Severity: Minor
    Found in apps/dav/lib/AppInfo/PluginManager.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 updateProperties has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function updateProperties($path, INode $node, $changedProperties) {
            $existingProperties = $this->getProperties($path, $node, []);
            '@phan-var \OCA\DAV\Connector\Sabre\Node $node';
            $fileId = $node->getId();
    
    
    Severity: Minor
    Found in apps/dav/lib/DAV/FileCustomPropertiesBackend.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