owncloud/core

View on GitHub

Showing 4,504 of 4,504 total issues

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

    protected function canEnableTheme($appId) {
        $info = $this->getAppInfo($appId);
        if (
            isset($info['types'])
            && \is_array($info['types'])
Severity: Minor
Found in lib/private/App/AppManager.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 analyzeOC has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private function analyzeOC(array $dependencies, array $appInfo) {
        $missing = [];
        $minVersion = null;
        if (isset($dependencies['owncloud']['@attributes']['min-version'])) {
            $minVersion = $dependencies['owncloud']['@attributes']['min-version'];
Severity: Minor
Found in lib/private/App/DependencyAnalyzer.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 html_select_options has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function html_select_options($options, $selected, $params= []) {
    if (!\is_array($selected)) {
        $selected= [$selected];
    }
    if (isset($params['combine']) && $params['combine']) {
Severity: Minor
Found in lib/private/legacy/template/functions.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 emit has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public static function emit($signalClass, $signalName, $params = []) {
        // Return false if no hook handlers are listening to this
        // emitting class
        if (!\array_key_exists($signalClass, self::$registered)) {
            return false;
Severity: Minor
Found in lib/private/legacy/hook.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 getAccessList has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function getAccessList($path) {
        // Make sure that a share key is generated for the owner too
        list($owner, $ownerPath) = $this->util->getUidAndFilename($path);

        // always add owner to the list of users with access to the file
Severity: Minor
Found in lib/private/Encryption/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 isAuthorised has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private static function isAuthorised($action) {
        $level = $action['authlevel'];
        switch ($level) {
            case API::GUEST_AUTH:
                // Anyone can access
Severity: Minor
Found in lib/private/legacy/api.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 getFile has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function getFile($size) {
        $ext = $this->getExtension();

        $basePath = "{$this->path}/avatar.$ext";

Severity: Minor
Found in lib/private/Avatar.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 getProviders has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function getProviders(IUser $user) {
        $allApps = $this->appManager->getEnabledAppsForUser($user);
        $providers = [];

        foreach ($allApps as $appId) {
Severity: Minor
Found in lib/private/Authentication/TwoFactorAuth/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 updateHtaccess has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public static function updateHtaccess() {
        $config = \OC::$server->getConfig();
        $il10n = \OC::$server->getL10N('lib');

        // For CLI read the value from overwrite.cli.url
Severity: Minor
Found in lib/private/Setup.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 clear has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function clear($prefix = '') {
        $storage = $this->getStorage();
        if ($storage and $storage->is_dir('/')) {
            $dh = $storage->opendir('/');
            if (\is_resource($dh)) {
Severity: Minor
Found in lib/private/Cache/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 findAvailableLanguageFiles has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    protected function findAvailableLanguageFiles($dir) {
        $availableLanguageFiles = [];
        if (\is_dir($dir)) {
            $files = \scandir($dir);
            if ($files !== false) {
Severity: Minor
Found in lib/private/L10N/Factory.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 loginWithApache has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function loginWithApache(IApacheBackend $apacheBackend) {
        $uidAndBackend = $apacheBackend->getCurrentUserId();
        if (\is_array($uidAndBackend)
            && \count($uidAndBackend) === 2
            && $uidAndBackend[0] !== ''
Severity: Minor
Found in lib/private/User/Session.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 guessTimeZoneFromOffset has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    protected function guessTimeZoneFromOffset($offset, $timestamp) {
        try {
            // Note: the timeZone name is the inverse to the offset,
            // so a positive offset means negative timeZone
            // and the other way around.
Severity: Minor
Found in lib/private/DateTimeZone.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 checkInput has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    protected function checkInput(InputInterface $input) {
        $uid = $input->getArgument('uid');
        if (!$input->getOption('ignore-missing-user') && !$this->userManager->userExists($uid)) {
            throw new \InvalidArgumentException('The user "' . $uid . '" does not exist.');
        }
Severity: Minor
Found in core/Command/User/Setting.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 execute has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    protected function execute(InputInterface $input, OutputInterface $output): int {
        if (Filesystem::isPrimaryObjectStorageEnabled() === true) {
            $output->writeln('<info>We detected that the instance is running on a S3 primary object storage, users might not be accurate</info>');
        }

Severity: Minor
Found in core/Command/User/HomeListUsers.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 sendEmail has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function sendEmail($user, $token, $link) {
        if ($this->userManager->userExists($user)) {
            $userObject = $this->userManager->get($user);
            $email = $userObject->getEMailAddress();

Severity: Minor
Found in core/Controller/LostController.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 buildWebUri has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private function buildWebUri(array $app_info, string $fileId): ?string {
        $uri = null;
        $app_name = $app_info['oc_app_name'];
        # https://github.com/ONLYOFFICE/onlyoffice-owncloud/blob/2afca075249f24d857f0b3097d565f5129e88d17/appinfo/routes.php#LL27C47-L27C53
        if ($app_name === 'onlyoffice') {
Severity: Minor
Found in core/Controller/AppRegistryController.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

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

                    button.children('span').first().text(settings.labels.length > 0
                        ? settings.labels.join(', ')
                        : settings.title);
Severity: Major
Found in core/js/multiselect.js and 1 other location - About 1 hr to fix
core/js/multiselect.js on lines 268..270

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

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

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

                            button.children('span').first().text(settings.labels.length > 0
                                ? settings.labels.join(', ')
                                : settings.title);
Severity: Major
Found in core/js/multiselect.js and 1 other location - About 1 hr to fix
core/js/multiselect.js on lines 191..193

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

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 query has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

                query: _.debounce(function(query) {
                    var queryData = {};
                    if (self._cachedGroups && query.term === '') {
                        query.callback({results: self._cachedGroups});
                        return;
Severity: Minor
Found in settings/js/settings.js - About 1 hr to fix
    Severity
    Category
    Status
    Source
    Language