mgcrea/angular-strap

View on GitHub
src/dropdown/dropdown.js

Summary

Maintainability
D
2 days
Test Coverage

Function $get has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    this.$get = function ($window, $rootScope, $tooltip, $timeout) {

      var bodyEl = angular.element($window.document.body);
      var matchesSelector = Element.prototype.matchesSelector || Element.prototype.webkitMatchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector;

Severity: Major
Found in src/dropdown/dropdown.js - About 2 hrs to fix

Function DropdownFactory has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      function DropdownFactory (element, config) {

        var $dropdown = {};

        // Common vars
Severity: Major
Found in src/dropdown/dropdown.js - About 2 hrs to fix

Function compile has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      compile: function (tElement, tAttrs) {

        // Support for inlined template (next sibling)
        // It must be fetched before compilation
        if (!tAttrs.bsDropdown) {
Severity: Major
Found in src/dropdown/dropdown.js - About 2 hrs to fix

Function postLink has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        return function postLink (scope, element, attr) {

          // Directive options
          var options = {
            scope: scope
Severity: Minor
Found in src/dropdown/dropdown.js - About 1 hr to fix

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

          if (attr.bsShow) {
            scope.$watch(attr.bsShow, function (newValue, oldValue) {
              if (!dropdown || !angular.isDefined(newValue)) return;
              if (angular.isString(newValue)) newValue = !!newValue.match(/true|,?(dropdown),?/i);
              if (newValue === true) {
Severity: Major
Found in src/dropdown/dropdown.js and 4 other locations - About 4 hrs to fix
src/datepicker/datepicker.js on lines 334..344
src/popover/popover.js on lines 122..132
src/timepicker/timepicker.js on lines 473..483
src/tooltip/tooltip.js on lines 833..843

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

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 7 locations. Consider refactoring.
Open

          angular.forEach(['onBeforeShow', 'onShow', 'onBeforeHide', 'onHide'], function (key) {
            var bsKey = 'bs' + key.charAt(0).toUpperCase() + key.slice(1);
            if (angular.isDefined(attr[bsKey])) {
              options[key] = scope.$eval(attr[bsKey]);
            }
Severity: Major
Found in src/dropdown/dropdown.js and 6 other locations - About 3 hrs to fix
src/aside/aside.js on lines 62..67
src/datepicker/datepicker.js on lines 312..317
src/modal/modal.js on lines 473..478
src/popover/popover.js on lines 74..79
src/timepicker/timepicker.js on lines 455..460
src/tooltip/tooltip.js on lines 774..779

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

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 10 locations. Consider refactoring.
Open

          scope.$on('$destroy', function () {
            if (dropdown) dropdown.destroy();
            options = null;
            dropdown = null;
          });
Severity: Major
Found in src/dropdown/dropdown.js and 9 other locations - About 35 mins to fix
src/alert/alert.js on lines 124..128
src/aside/aside.js on lines 96..100
src/datepicker/datepicker.js on lines 478..482
src/modal/modal.js on lines 513..517
src/popover/popover.js on lines 159..163
src/select/select.js on lines 404..408
src/timepicker/timepicker.js on lines 592..596
src/tooltip/tooltip.js on lines 871..875
src/typeahead/typeahead.js on lines 343..347

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

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