owncloud/core

View on GitHub
apps/files/js/fileactions.js

Summary

Maintainability
D
2 days
Test Coverage

File fileactions.js has 499 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright (c) 2014
 *
 * This file is licensed under the Affero General Public License version 3
 * or later.
Severity: Minor
Found in apps/files/js/fileactions.js - About 1 day to fix

    Function registerDefaultActions has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            registerDefaultActions: function (excludeActions) {
                excludeActions = excludeActions || [];
    
                var self = this;
                var defaultActions = [
    Severity: Major
    Found in apps/files/js/fileactions.js - About 2 hrs to fix

      Function display has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              display: function (parent, triggerEvent, fileList) {
                  if (!fileList) {
                      console.warn('FileActions.display() MUST be called with a OCA.Files.FileList instance');
                      return;
                  }
      Severity: Major
      Found in apps/files/js/fileactions.js - About 2 hrs to fix

        Function _renderInlineAction has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                _renderInlineAction: function(actionSpec, isDefault, context) {
                    var renderFunc = actionSpec.render || _.bind(this._defaultRenderAction, this);
                    var $actionEl = renderFunc(actionSpec, isDefault, context);
                    if (!$actionEl || !$actionEl.length) {
                        return;
        Severity: Minor
        Found in apps/files/js/fileactions.js - About 1 hr to fix

          Function triggerAction has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  triggerAction: function(actionName, fileInfoModel, fileList) {
                      var actionFunc;
                      var actions = this.get(
                          fileInfoModel.get('mimetype'),
                          fileInfoModel.isDirectory() ? 'dir' : 'file',
          Severity: Minor
          Found in apps/files/js/fileactions.js - About 1 hr to fix

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

                     getDefaultFileActions: function(mime, type, permissions) {
                        var mimePart;
                        if (mime) {
                            mimePart = mime.substr(0, mime.indexOf('/'));
                        }
            Severity: Minor
            Found in apps/files/js/fileactions.js - About 1 hr to fix

              Function registerAction has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      registerAction: function (action) {
                          var mime = action.mime;
                          var name = action.name;
                          var actionSpec = {
                              action: action.actionHandler,
              Severity: Minor
              Found in apps/files/js/fileactions.js - About 1 hr to fix

                Function register has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        register: function(mime, name, permissions, icon, action, displayName) {
                Severity: Minor
                Found in apps/files/js/fileactions.js - About 45 mins to fix

                  Function register has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      window.FileActions.register = function (mime, name, permissions, icon, action, displayName) {
                  Severity: Minor
                  Found in apps/files/js/fileactions.js - About 45 mins to fix

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

                                    if (_.isFunction(actionSpec.icon)) {
                                        params.icon = actionSpec.icon(context.$file.attr('data-file'), context);
                                    }
                    Severity: Minor
                    Found in apps/files/js/fileactions.js and 1 other location - About 50 mins to fix
                    apps/files/js/fileactions.js on lines 362..364

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

                    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 (_.isFunction(actionSpec.iconClass)) {
                                        params.iconClass = actionSpec.iconClass(context.$file.attr('data-file'), context);
                                    }
                    Severity: Minor
                    Found in apps/files/js/fileactions.js and 1 other location - About 50 mins to fix
                    apps/files/js/fileactions.js on lines 359..361

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

                    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