owncloud/core

View on GitHub
settings/js/admin-apps.js

Summary

Maintainability
F
1 wk
Test Coverage

File admin-apps.js has 555 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global Handlebars */

Handlebars.registerHelper('score', function() {
    if(this.score) {
        var score = Math.round( this.score / 10 );
Severity: Major
Found in settings/js/admin-apps.js - About 1 day to fix

    Function enableApp has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        enableApp:function(appId, active, element, groups) {
            var self = this;
            OC.Settings.Apps.hideErrorMessage(appId);
            groups = groups || [];
            var appItem = $('div#app-'+appId+'');
    Severity: Major
    Found in settings/js/admin-apps.js - About 3 hrs to fix

      Function loadCategory has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          loadCategory: function(categoryId) {
              var self = this;
              if (OC.Settings.Apps.State.currentCategory === categoryId) {
                  return;
              }
      Severity: Major
      Found in settings/js/admin-apps.js - About 2 hrs to fix

        Function initialize has 62 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            initialize: function($el) {
                OC.Plugins.register('OCA.Search', OC.Settings.Apps.Search);
                OC.Settings.Apps.loadCategories();
                OC.Util.History.addOnPopStateHandler(_.bind(this._onPopState, this));
        
        
        Severity: Major
        Found in settings/js/admin-apps.js - About 2 hrs to fix

          Function filter has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              filter: function(query) {
                  // FIXME: the caller doesn't properly set the "this" context
                  var self = OC.Settings.Apps;
                  self._filterQuery = query;
          
          
          Severity: Major
          Found in settings/js/admin-apps.js - About 2 hrs to fix

            Function renderApp has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                renderApp: function(app, template, selector, firstExperimental) {
                    if (!template) {
                        var source   = $("#app-template").html();
                        template = Handlebars.compile(source);
                    }
            Severity: Minor
            Found in settings/js/admin-apps.js - About 2 hrs 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 renderApp has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                renderApp: function(app, template, selector, firstExperimental) {
                    if (!template) {
                        var source   = $("#app-template").html();
                        template = Handlebars.compile(source);
                    }
            Severity: Minor
            Found in settings/js/admin-apps.js - About 1 hr to fix

              Function rebuildNavigation has a Cognitive Complexity of 14 (exceeds 5 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

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

                            success: function (apps) {
                                var appListWithIndex = _.indexBy(apps.apps, 'id');
                                OC.Settings.Apps.State.apps = appListWithIndex;
                                var appList = _.map(appListWithIndex, function(app) {
                                    // default values for missing fields
                Severity: Minor
                Found in settings/js/admin-apps.js - About 1 hr to fix

                  Function _parseAppAuthor has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      _parseAppAuthor: function (author) {
                          if (_.isObject(author) && !_.isUndefined(author['@value'])) {
                              return author['@value'];
                          }
                  
                  
                  Severity: Minor
                  Found in settings/js/admin-apps.js - About 55 mins 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 loadCategory has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      loadCategory: function(categoryId) {
                          var self = this;
                          if (OC.Settings.Apps.State.currentCategory === categoryId) {
                              return;
                          }
                  Severity: Minor
                  Found in settings/js/admin-apps.js - About 35 mins 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 filter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      filter: function(query) {
                          // FIXME: the caller doesn't properly set the "this" context
                          var self = OC.Settings.Apps;
                          self._filterQuery = query;
                  
                  
                  Severity: Minor
                  Found in settings/js/admin-apps.js - About 35 mins 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

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

                                  if(!result || result.status !== 'success') {
                                      if (result.data && result.data.message) {
                                          OC.Settings.Apps.showErrorMessage(appId, result.data.message);
                                          appItem.data('errormsg', result.data.message);
                                      } else {
                  Severity: Major
                  Found in settings/js/admin-apps.js and 1 other location - About 5 hrs to fix
                  settings/js/admin-apps.js on lines 300..360

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

                  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(!result || result.status !== 'success') {
                                      if (result.data && result.data.message) {
                                          OC.Settings.Apps.showErrorMessage(appId, result.data.message);
                                          appItem.data('errormsg', result.data.message);
                                      } else {
                  Severity: Major
                  Found in settings/js/admin-apps.js and 1 other location - About 5 hrs to fix
                  settings/js/admin-apps.js on lines 274..294

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

                  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

                          $(document).on('click', '.app-description-toggle-hide', function () {
                              $(this).addClass('hidden');
                              $(this).siblings('.app-description-toggle-show').removeClass('hidden');
                              $(this).siblings('.app-description-container').slideUp();
                          });
                  Severity: Major
                  Found in settings/js/admin-apps.js and 1 other location - About 2 hrs to fix
                  settings/js/admin-apps.js on lines 598..602

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

                  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

                          $(document).on('click', '.app-description-toggle-show', function () {
                              $(this).addClass('hidden');
                              $(this).siblings('.app-description-toggle-hide').removeClass('hidden');
                              $(this).siblings('.app-description-container').slideDown();
                          });
                  Severity: Major
                  Found in settings/js/admin-apps.js and 1 other location - About 2 hrs to fix
                  settings/js/admin-apps.js on lines 603..607

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

                  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

                          apps = apps.concat(_.filter(OC.Settings.Apps.State.apps, function (app) {
                              return app.description.toLowerCase().indexOf(query) !== -1;
                          }));
                  Severity: Major
                  Found in settings/js/admin-apps.js and 1 other location - About 2 hrs to fix
                  settings/js/admin-apps.js on lines 521..523

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

                  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

                          apps = apps.concat(_.filter(OC.Settings.Apps.State.apps, function (app) {
                              return app.id.toLowerCase().indexOf(query) !== -1;
                          }));
                  Severity: Major
                  Found in settings/js/admin-apps.js and 1 other location - About 2 hrs to fix
                  settings/js/admin-apps.js on lines 526..528

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

                  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

                          $(document).on('click', '#apps-list input.update', function () {
                              var appId = $(this).data('appid');
                              var element = $(this);
                  
                              OC.Settings.Apps.updateApp(appId, element);
                  Severity: Major
                  Found in settings/js/admin-apps.js and 1 other location - About 1 hr to fix
                  settings/js/admin-apps.js on lines 617..622

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

                  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

                          $(document).on('click', '#apps-list input.uninstall', function () {
                              var appId = $(this).data('appid');
                              var element = $(this);
                  
                              OC.Settings.Apps.uninstallApp(appId, element);
                  Severity: Major
                  Found in settings/js/admin-apps.js and 1 other location - About 1 hr to fix
                  settings/js/admin-apps.js on lines 624..629

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

                  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 (t('settings', 'Official').toLowerCase().indexOf(query) !== -1) {
                              apps = apps.concat(_.filter(OC.Settings.Apps.State.apps, function (app) {
                                  return app.level === 200;
                              }));
                          }
                  Severity: Major
                  Found in settings/js/admin-apps.js and 1 other location - About 1 hr to fix
                  settings/js/admin-apps.js on lines 544..548

                  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

                          if (t('settings', 'Approved').toLowerCase().indexOf(query) !== -1) {
                              apps = apps.concat(_.filter(OC.Settings.Apps.State.apps, function (app) {
                                  return app.level === 100;
                              }));
                          }
                  Severity: Major
                  Found in settings/js/admin-apps.js and 1 other location - About 1 hr to fix
                  settings/js/admin-apps.js on lines 539..543

                  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

                  There are no issues that match your filters.

                  Category
                  Status