File bootstrap.js
has 2830 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*!
* Bootstrap v4.1.3 (https://getbootstrap.com/)
* Copyright 2011-2018 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
Function Tooltip
has 515 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Tooltip = function ($$$1) {
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
Function Tooltip
has 432 lines of code (exceeds 25 allowed). Consider refactoring. Open
function () {
function Tooltip(element, config) {
/**
* Check for Popper dependency
* Popper - https://popper.js.org
Function Modal
has 414 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Modal = function ($$$1) {
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
Function Carousel
has 368 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Carousel = function ($$$1) {
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
Function Modal
has 335 lines of code (exceeds 25 allowed). Consider refactoring. Open
function () {
function Modal(element, config) {
this._config = this._getConfig(config);
this._element = element;
this._dialog = element.querySelector(Selector.DIALOG);
Function Dropdown
has 335 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Dropdown = function ($$$1) {
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
Function Carousel
has 292 lines of code (exceeds 25 allowed). Consider refactoring. Open
function () {
function Carousel(element, config) {
this._items = null;
this._interval = null;
this._activeElement = null;
Function Collapse
has 262 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Collapse = function ($$$1) {
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
Function Dropdown
has 254 lines of code (exceeds 25 allowed). Consider refactoring. Open
function () {
function Dropdown(element, config) {
this._element = element;
this._popper = null;
this._config = this._getConfig(config);
Function ScrollSpy
has 220 lines of code (exceeds 25 allowed). Consider refactoring. Open
var ScrollSpy = function ($$$1) {
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
Function Collapse
has 203 lines of code (exceeds 25 allowed). Consider refactoring. Open
function () {
function Collapse(element, config) {
this._isTransitioning = false;
this._element = element;
this._config = this._getConfig(config);
Function Tab
has 170 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Tab = function ($$$1) {
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
Function ScrollSpy
has 161 lines of code (exceeds 25 allowed). Consider refactoring. Open
function () {
function ScrollSpy(element, config) {
var _this = this;
this._element = element;
Function Popover
has 137 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Popover = function ($$$1) {
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
Function Tab
has 127 lines of code (exceeds 25 allowed). Consider refactoring. Open
function () {
function Tab(element) {
this._element = element;
} // Getters
Function Alert
has 108 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Alert = function ($$$1) {
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
Function Button
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Button = function ($$$1) {
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
Function Util
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Util = function ($$$1) {
/**
* ------------------------------------------------------------------------
* Private TransitionEnd Helpers
* ------------------------------------------------------------------------
Function Popover
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
function (_Tooltip) {
_inheritsLoose(Popover, _Tooltip);
function Popover() {
return _Tooltip.apply(this, arguments) || this;
Function Alert
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
function () {
function Alert(element) {
this._element = element;
} // Getters
Function show
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
_proto.show = function show() {
var _this = this;
if ($$$1(this.element).css('display') === 'none') {
throw new Error('Please use show on visible elements');
Function _slide
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
_proto._slide = function _slide(direction, element) {
var _this3 = this;
var activeElement = this._element.querySelector(Selector.ACTIVE_ITEM);
Function Button
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
function () {
function Button(element) {
this._element = element;
} // Getters
Function _showBackdrop
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
_proto._showBackdrop = function _showBackdrop(callback) {
var _this8 = this;
var animate = $$$1(this._element).hasClass(ClassName.FADE) ? ClassName.FADE : '';
Function show
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
_proto.show = function show() {
var _this = this;
if (this._isTransitioning || $$$1(this._element).hasClass(ClassName.SHOW)) {
return;
Function show
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
_proto.show = function show() {
var _this = this;
if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $$$1(this._element).hasClass(ClassName.ACTIVE) || $$$1(this._element).hasClass(ClassName.DISABLED)) {
return;
Function toggle
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
_proto.toggle = function toggle() {
if (this._element.disabled || $$$1(this._element).hasClass(ClassName.DISABLED)) {
return;
}
Function _clearMenus
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Dropdown._clearMenus = function _clearMenus(event) {
if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
return;
}
Function hide
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
_proto.hide = function hide(callback) {
var _this2 = this;
var tip = this.getTipElement();
var hideEvent = $$$1.Event(this.constructor.Event.HIDE);
Function show
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
_proto.show = function show(relatedTarget) {
var _this = this;
if (this._isTransitioning || this._isShown) {
return;
Function hide
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
_proto.hide = function hide() {
var _this2 = this;
if (this._isTransitioning || !$$$1(this._element).hasClass(ClassName.SHOW)) {
return;
Function toggle
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
_proto.toggle = function toggle() {
var triggerChangeEvent = true;
var addAriaPressed = true;
var rootElement = $$$1(this._element).closest(Selector.DATA_TOGGLE)[0];
Function _dataApiKeydownHandler
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
// If not input/textarea:
// - And not a key in REGEXP_KEYDOWN => not a dropdown command
// If input/textarea:
// - If space key => not a dropdown command
Function _showElement
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
_proto._showElement = function _showElement(relatedTarget) {
var _this3 = this;
var transition = $$$1(this._element).hasClass(ClassName.FADE);
Function hide
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
_proto.hide = function hide(event) {
var _this2 = this;
if (event) {
event.preventDefault();
Function refresh
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
_proto.refresh = function refresh() {
var _this2 = this;
var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
Function _getPopperConfig
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
_proto._getPopperConfig = function _getPopperConfig() {
var _this2 = this;
var offsetConf = {};
Function _setListeners
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
_proto._setListeners = function _setListeners() {
var _this3 = this;
var triggers = this.config.trigger.split(' ');
triggers.forEach(function (trigger) {
Function _transitionComplete
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
_proto._transitionComplete = function _transitionComplete(element, active, callback) {
if (active) {
$$$1(active).removeClass(ClassName.SHOW + " " + ClassName.ACTIVE);
var dropdownChild = $$$1(active.parentNode).find(Selector.DROPDOWN_ACTIVE_CHILD)[0];
Avoid deeply nested control flow statements. Open
if (activeElement) {
$$$1(activeElement).removeClass(ClassName.ACTIVE);
}
Consider simplifying this complex logical expression. Open
if (!isActive && (event.which !== ESCAPE_KEYCODE || event.which !== SPACE_KEYCODE) || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
if (event.which === ESCAPE_KEYCODE) {
var toggle = parent.querySelector(Selector.DATA_TOGGLE);
$$$1(toggle).trigger('focus');
}
Consider simplifying this complex logical expression. Open
if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $$$1.contains(parent, event.target)) {
continue;
}
Consider simplifying this complex logical expression. Open
if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
}
Identical blocks of code found in 2 locations. Consider refactoring. Open
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('jquery'), require('popper.js')) :
typeof define === 'function' && define.amd ? define(['exports', 'jquery', 'popper.js'], factory) :
(factory((global.bootstrap = {}),global.jQuery,global.Popper));
}(this, (function (exports,$,Popper) { 'use strict';
- Read upRead up
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 31449.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76