owncloud/core

View on GitHub
core/js/shareitemmodel.js

Summary

Maintainability
F
5 days
Test Coverage

File shareitemmodel.js has 645 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright (c) 2015
 *
 * This file is licensed under the Affero General Public License version 3
 * or later.
Severity: Major
Found in core/js/shareitemmodel.js - About 1 day to fix

    Function _handleUpdateShareAttributes has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            _handleUpdateShareAttributes: function(shareId, properties, options) {
                var shareAttributesV1 = [];
                var filteredAttributes = [];
                var filteredRegisteredAttributes = this._filterRegisteredAttributes(properties.permissions);
                _.map(filteredRegisteredAttributes, function(filteredRegisteredAttribute) {
    Severity: Major
    Found in core/js/shareitemmodel.js - About 2 hrs to fix

      Function addShare has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              addShare: function(properties, options) {
                  var shareType = properties.shareType;
                  options = options || {};
                  properties = _.extend({}, properties);
      
      
      Severity: Minor
      Found in core/js/shareitemmodel.js - About 1 hr to fix

        Function parse has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                parse: function(data) {
                    if(data === false) {
                        console.warn('no data was returned');
                        this.trigger('fetchError');
                        return {};
        Severity: Minor
        Found in core/js/shareitemmodel.js - About 1 hr to fix

          Function updateShare has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  updateShare: function(shareId, properties, options) {
                      var self = this;
          
                      // Extend attributes for update share if provided for update.
                      // note: required only for compatibility with attributes v1
          Severity: Minor
          Found in core/js/shareitemmodel.js - About 1 hr to fix

            Function _handleAddShareAttributes has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    _handleAddShareAttributes: function(properties, options) {
                        var shareAttributesV1 = [];
                        var filteredRegisteredAttributes = this._filterRegisteredAttributes(properties.permissions);
                        _.map(filteredRegisteredAttributes, function (filteredRegisteredAttribute) {
                            var isCompatible = true;
            Severity: Minor
            Found in core/js/shareitemmodel.js - About 1 hr to fix

              Function _legacyFillCurrentShares has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      _legacyFillCurrentShares: function(shares) {
                          var fileId = this.fileInfoModel.get('id');
                          if (!shares || !shares.length) {
                              delete OC.Share.statuses[fileId];
                              OC.Share.currentShares = {};
              Severity: Minor
              Found in core/js/shareitemmodel.js - About 1 hr to fix

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

                            return $.ajax({
                                type: 'DELETE',
                                url: this._getUrl('shares/' + encodeURIComponent(shareId)),
                            }).done(function() {
                                self.fetch({
                Severity: Major
                Found in core/js/shareitemmodel.js and 1 other location - About 4 hrs to fix
                core/js/shareitemmodel.js on lines 234..260

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

                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

                            return $.ajax({
                                type: 'PUT',
                                url: this._getUrl('shares/' + encodeURIComponent(shareId)),
                                data: JSON.stringify(properties),
                                dataType: 'json',
                Severity: Major
                Found in core/js/shareitemmodel.js and 1 other location - About 4 hrs to fix
                core/js/shareitemmodel.js on lines 272..295

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

                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

                                _.map(filteredRegisteredAttribute.incompatibleAttributes, function (incompatibleAttribute) {
                                    _.map(filteredRegisteredAttributes, function (checkAttr) {
                                        if (incompatibleAttribute.scope === checkAttr.scope &&
                                            incompatibleAttribute.key === checkAttr.key &&
                                            incompatibleAttribute.enabled === checkAttr.default) {
                Severity: Major
                Found in core/js/shareitemmodel.js and 1 other location - About 3 hrs to fix
                core/js/shareitemmodel.js on lines 1006..1014

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

                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

                                _.map(filteredAttribute.incompatibleAttributes, function(incompatibleAttribute) {
                                    _.map(filteredAttributes, function(checkAttr) {
                                        if (incompatibleAttribute.scope === checkAttr.scope &&
                                            incompatibleAttribute.key === checkAttr.key &&
                                            incompatibleAttribute.enabled === checkAttr.enabled) {
                Severity: Major
                Found in core/js/shareitemmodel.js and 1 other location - About 3 hrs to fix
                core/js/shareitemmodel.js on lines 926..934

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

                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

                        getShareWithDisplayName: function(shareIndex) {
                            /** @type OC.Share.Types.ShareInfo **/
                            var share = this.get('shares')[shareIndex];
                            if(!_.isObject(share)) {
                                throw "Unknown Share";
                Severity: Major
                Found in core/js/shareitemmodel.js and 2 other locations - About 1 hr to fix
                core/js/shareitemmodel.js on lines 442..449
                core/js/shareitemmodel.js on lines 468..475

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

                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

                        getShareWithAdditionalInfo: function(shareIndex) {
                            /** @type OC.Share.Types.ShareInfo **/
                            var share = this.get('shares')[shareIndex];
                            if(!_.isObject(share)) {
                                throw "Unknown Share";
                Severity: Major
                Found in core/js/shareitemmodel.js and 2 other locations - About 1 hr to fix
                core/js/shareitemmodel.js on lines 442..449
                core/js/shareitemmodel.js on lines 455..462

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

                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

                        getShareWith: function(shareIndex) {
                            /** @type OC.Share.Types.ShareInfo **/
                            var share = this.get('shares')[shareIndex];
                            if(!_.isObject(share)) {
                                throw "Unknown Share";
                Severity: Major
                Found in core/js/shareitemmodel.js and 2 other locations - About 1 hr to fix
                core/js/shareitemmodel.js on lines 455..462
                core/js/shareitemmodel.js on lines 468..475

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

                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

                                        filteredAttributes.push({
                                            scope : filteredRegisteredAttribute.scope,
                                            key: filteredRegisteredAttribute.key,
                                            incompatibleAttributes: filteredRegisteredAttribute.incompatibleAttributes,
                                            enabled: currentAttribute.enabled
                Severity: Minor
                Found in core/js/shareitemmodel.js and 1 other location - About 40 mins to fix
                core/js/shareitemmodel.js on lines 993..998

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

                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

                                    filteredAttributes.push({
                                        scope : filteredRegisteredAttribute.scope,
                                        key: filteredRegisteredAttribute.key,
                                        incompatibleAttributes: filteredRegisteredAttribute.incompatibleAttributes,
                                        enabled: filteredRegisteredAttribute.default
                Severity: Minor
                Found in core/js/shareitemmodel.js and 1 other location - About 40 mins to fix
                core/js/shareitemmodel.js on lines 979..984

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

                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

                                if (isCompatible) {
                                    shareAttributesV1.push({
                                        scope : filteredAttribute.scope,
                                        key: filteredAttribute.key,
                                        enabled: filteredAttribute.enabled
                Severity: Minor
                Found in core/js/shareitemmodel.js and 1 other location - About 35 mins to fix
                core/js/shareitemmodel.js on lines 936..942

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

                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

                                if (isCompatible) {
                                    shareAttributesV1.push({
                                        scope: filteredRegisteredAttribute.scope,
                                        key: filteredRegisteredAttribute.key,
                                        enabled: filteredRegisteredAttribute.default
                Severity: Minor
                Found in core/js/shareitemmodel.js and 1 other location - About 35 mins to fix
                core/js/shareitemmodel.js on lines 1016..1022

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

                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

                There are no issues that match your filters.

                Category
                Status