owncloud/core

View on GitHub

Showing 4,504 of 4,504 total issues

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

    protected function groupCreateChecks(\OCP\Share\IShare $share) {
        // Verify group shares are allowed
        if (!$this->allowGroupSharing()) {
            throw new \Exception('Group sharing is not allowed');
        }
Severity: Minor
Found in lib/private/Share20/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 getMessageForLicense has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function getMessageForLicense(array $info, string $language = null): array {
        $l = $this->l10nFactory->get('core', $language);

        // check if present
        if ($info['licenseState'] === ILicenseManager::LICENSE_STATE_MISSING) {
Severity: Minor
Found in lib/private/License/MessageService.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 moveAvatars has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function moveAvatars(IOutput $out, IUser $user) {
        $userId = $user->getUID();

        try {
            \OC\Files\Filesystem::initMountPoints($userId);
Severity: Minor
Found in lib/private/Repair/MoveAvatarIntoSubFolder.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 getLicenseWithState has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function getLicenseWithState(string $appid) {
        // check if license is missing
        $licenseObj = $this->licenseFetcher->getOwncloudLicense();
        if ($licenseObj === null) {
            $licenseState = ILicenseManager::LICENSE_STATE_MISSING;
Severity: Minor
Found in lib/private/License/LicenseManager.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 rmdirr has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public static function rmdirr($dir, $deleteSelf = true) {
        if (\is_dir($dir)) {
            $files = new RecursiveIteratorIterator(
                new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
                RecursiveIteratorIterator::CHILD_FIRST
Severity: Minor
Found in lib/private/legacy/helper.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 getSupportedDatabases has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function getSupportedDatabases($allowAllDatabases = false) {
        $availableDatabases = [
            'sqlite' =>  [
                'type' => 'class',
                'call' => 'SQLite3',
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 saveColumn has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private static function saveColumn($column, $xml) {
        $xml->addChild('name', $column->getName());
        switch ($column->getType()) {
            case 'SmallInt':
            case 'Integer':
Severity: Minor
Found in lib/private/DB/MDB2SchemaWriter.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 addExternalResource has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private static function addExternalResource($application, $prepend, $path, $type = "script") {
        if ($type === "style") {
            if (!\in_array($path, self::$styles)) {
                if ($prepend === true) {
                    \array_unshift(self::$styles, $path);
Severity: Minor
Found in lib/private/legacy/util.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 verifyAuthHeaders has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function verifyAuthHeaders($request) {
        $shallLogout = false;
        try {
            $lastUser = null;
            foreach ($this->getAuthModules(true) as $module) {
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 validateInput has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    protected function validateInput(InputInterface $input, OutputInterface $output, $supportedDatabases) {
        $db = \strtolower($input->getOption('database'));

        if (!\in_array($db, $supportedDatabases)) {
            throw new InvalidArgumentException("Database <$db> is not supported.");
Severity: Minor
Found in core/Command/Maintenance/Install.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

        $appName,
        IRequest $request,
        IURLGenerator $urlGenerator,
        IUserManager $userManager,
        OC_Defaults $defaults,
Severity: Major
Found in core/Controller/LostController.php - About 1 hr to fix

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

        $('#pass2').strengthify({
            zxcvbn: OC.linkTo('core','vendor/zxcvbn/dist/zxcvbn.js'),
            titles: [
                t('settings', 'Very weak password'),
                t('settings', 'Weak password'),
    Severity: Major
    Found in settings/js/panels/profile.js and 1 other location - About 1 hr to fix
    core/js/setup.js on lines 109..119

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

    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

        $('#adminpass').strengthify({
            zxcvbn: OC.linkTo('core','vendor/zxcvbn/dist/zxcvbn.js'),
            titles: [
                t('core', 'Very weak password'),
                t('core', 'Weak password'),
    Severity: Major
    Found in core/js/setup.js and 1 other location - About 1 hr to fix
    settings/js/panels/profile.js on lines 312..322

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

    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 43 lines of code (exceeds 25 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

      Function _initFilterField has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  _initFilterField: function ($container) {
                      this.$filterField = $('<input type="hidden" name="tags"/>');
                      $container.append(this.$filterField);
                      this.$filterField.select2({
                          placeholder: t('systemtags', 'Select tags to filter by'),
      Severity: Minor
      Found in apps/systemtags/js/systemtagsfilelist.js - About 1 hr to fix

        Function getAuthUrl has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        OCA.External.Settings.OAuth2.getAuthUrl = function (backendUrl, data) {
            var $tr = data['tr'];
            var configured = $tr.find('[data-parameter="configured"]');
            var token = $tr.find('.configuration [data-parameter="token"]');
        
        
        Severity: Minor
        Found in apps/files_external/js/settings.js - About 1 hr to fix

          Function EventSource has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          OC.EventSource=function(src,data){
              var dataStr='';
              var name;
              var joinChar;
              this.typelessListeners=[];
          Severity: Minor
          Found in core/js/eventsource.js - About 1 hr to fix

            Function showNotification has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                showNotification: function() {
                    if (!this._template) {
                        this._template = Handlebars.compile(this.NOTIFICATION_TEMPLATE);
                    }
            
            
            Severity: Minor
            Found in core/js/license-trial-notification.js - About 1 hr to fix

              Function davSync has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function davSync(method, model, options) {
                      var params = {type: getTypeForMethod(method, model)};
                      var isCollection = (model instanceof Backbone.Collection);
              
                      // Ensure that we have a URL.
              Severity: Minor
              Found in core/js/oc-backbone-webdav.js - About 1 hr to fix

                Method setDisplayName has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function setDisplayName($username, $displayName) {
                        $resp = $this->validateString($displayName, 64);
                        if ($resp) {
                            return $resp;
                        }
                Severity: Minor
                Found in settings/Controller/UsersController.php - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language