File ui.ts
has 999 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint-disable max-len */
/* tslint:disable:max-line-length */
import _, {difference, filter, mapValues, sortBy, union, without} from 'lodash';
import moment from 'moment-timezone';
Function DatepickerInnerDirective
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
function DatepickerInnerDirective($compile, $document, popupService, datetimeHelper) {
var popupTpl = '<div sd-datepicker-wrapper ng-model="date">' +
'<div datepicker format-day="d" starting-day="' + appConfig.startingDay + '" show-weeks="false"></div>' +
'</div>';
Function splitterWidget
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
function splitterWidget(superdesk, $timeout, $rootScope) {
return {
link: function(scope, element) {
const MONITORING_MIN_WIDTH = 532;
const AUTHORING_MIN_WIDTH = 730;
Function TimepickerInnerDirective
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
function TimepickerInnerDirective($compile, $document, popupService, datetimeHelper) {
var popupTpl = '<div sd-timepicker-popup ' +
'data-open="open" data-time="time" data-select="timeSelection({time: time})" data-keydown="keydown(e)">' +
'</div>';
Function DropdownFocus
has 88 lines of code (exceeds 25 allowed). Consider refactoring. Open
function DropdownFocus(Keys) {
return {
require: 'dropdown',
link: function(scope, elem, attrs, dropdown) {
scope.$watch(dropdown.isOpen, (isOpen) => {
Function link
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
link: function(scope, element) {
const MONITORING_MIN_WIDTH = 532;
const AUTHORING_MIN_WIDTH = 730;
let workspace, authoring, container;
Function link
has 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
link: function(scope, element, attrs, ctrl) {
var VIEW_DATE_FORMAT = appConfig.view.dateformat;
var MODEL_DATE_FORMAT = scope.dtFormat || appConfig.model.dateformat;
var ESC = 27;
var DOWN_ARROW = 40;
Function link
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
link: function(scope, elem, attrs, dropdown) {
scope.$watch(dropdown.isOpen, (isOpen) => {
var inputField = elem.find('input[type="text"]');
if (isOpen) {
Function link
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
link: function(scope, element, attrs, ctrl) {
var MODEL_TIME_FORMAT = appConfig.model.timeformat;
var VIEW_TIME_FORMAT = appConfig.view.timeformat || MODEL_TIME_FORMAT;
var ESC = 27;
var DOWN_ARROW = 40;
Function DatepickerInnerDirective
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
function DatepickerInnerDirective($compile, $document, popupService, datetimeHelper) {
var popupTpl = '<div sd-datepicker-wrapper ng-model="date">' +
'<div datepicker format-day="d" starting-day="' + appConfig.startingDay + '" show-weeks="false"></div>' +
'</div>';
- Read upRead up
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 TimepickerInnerDirective
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
function TimepickerInnerDirective($compile, $document, popupService, datetimeHelper) {
var popupTpl = '<div sd-timepicker-popup ' +
'data-open="open" data-time="time" data-select="timeSelection({time: time})" data-keydown="keydown(e)">' +
'</div>';
- Read upRead up
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 TimepickerPopupDirective
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
function TimepickerPopupDirective($timeout) {
return {
templateUrl: 'scripts/core/ui/views/sd-timepicker-popup.html',
scope: {
open: '=',
Function multiSelectDirective
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
function multiSelectDirective() {
return {
scope: {
item: '=',
list: '=',
Function splitterWidget
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
function splitterWidget(superdesk, $timeout, $rootScope) {
return {
link: function(scope, element) {
const MONITORING_MIN_WIDTH = 532;
const AUTHORING_MIN_WIDTH = 730;
- Read upRead up
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 TimezoneDirective
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
function TimezoneDirective(tzdata, $timeout) {
return {
templateUrl: 'scripts/core/ui/views/sd-timezone.html',
scope: {
timezone: '=',
Function link
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
link: function(scope, element) {
const MODEL_TIME_FORMAT = appConfig.model.timeformat;
const VIEW_TIME_FORMAT = appConfig.view.timeformat;
const POPUP = '.timepicker-popup';
Function link
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
link: function(scope) {
scope.selectedItems = [];
// use listCopy in order not to mutate the original list
// mutating the original list prevents passing expression as a list argument
Function validationDirective
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function validationDirective() {
const isValid = (errors: ServerErrorsType) => errors == null || (Array.isArray(errors) && errors.length === 0);
return {
restrict: 'A',
Function link
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
link: function(scope, el) {
scope.timeZones = []; // all time zones to choose from
scope.tzSearchTerm = ''; // the current time zone search term
scope.getTimezoneLabel = getTimezoneLabel;
Function DatepickerDirective
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function DatepickerDirective($document) {
return {
scope: {
dt: '=ngModel',
disabled: '=ngDisabled',
Function mediaQuery
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function mediaQuery($window, authoringWorkspace: AuthoringWorkspaceService) {
return {
scope: {
minWidth: '=',
maxWidth: '=',
Function link
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
link: function(scope, elem, attrs, ctrl) {
var invalidText = '<span id="required_span" class="sd-invalid-text">' +
gettext('This field is required') + '</span>';
scope.$watch(attrs.required, (required) => {
Function AutoexpandDirective
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function AutoexpandDirective() {
return {
link: function(scope, element) {
var _minHeight = element.outerHeight();
- Read upRead up
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 TimepickerDirective
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function TimepickerDirective($document) {
return {
scope: {
tt: '=ngModel',
style: '@',
Function link
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
link: function(scope, elem) {
var window = angular.element($window);
var resize = _.debounce(calcSize, 300);
var elementClass = scope.elementClass ? scope.elementClass : 'elementState';
Function handleDown
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
handlers[Keys.down] = function handleDown() {
var nextElem = elem.find('button:focus')
.parent('li')
.next()
.children('button'),
Function DatepickerDirective
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function DatepickerDirective($document) {
return {
scope: {
dt: '=ngModel',
disabled: '=ngDisabled',
- Read upRead up
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 mediaQuery
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function mediaQuery($window, authoringWorkspace: AuthoringWorkspaceService) {
return {
scope: {
minWidth: '=',
maxWidth: '=',
- Read upRead up
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 PopupService
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function PopupService($document) {
var service: any = {};
service.position = function(width, height, target) {
// taking care of screen size and responsiveness
- Read upRead up
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 WeekdayPickerDirective
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function WeekdayPickerDirective(weekdays) {
return {
templateUrl: 'scripts/core/ui/views/weekday-picker.html',
scope: {
model: '=',
- Read upRead up
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 multiSelectDirective
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function multiSelectDirective() {
return {
scope: {
item: '=',
list: '=',
- Read upRead up
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 TimepickerPopupDirective
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function TimepickerPopupDirective($timeout) {
return {
templateUrl: 'scripts/core/ui/views/sd-timepicker-popup.html',
scope: {
open: '=',
- Read upRead up
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
scope.keydown = function(evt) {
if (evt.which === ESC) {
evt.preventDefault();
scope.close();
} else if (evt.which === DOWN_ARROW && !scope.open) {
- 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 105.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
scope.keydown = function(evt) {
if (evt.which === ESC) {
evt.preventDefault();
scope.close();
} else if (evt.which === DOWN_ARROW && !scope.open) {
- 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 105.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (width < scope.minWidth) {
scope.$parent.$applyAsync(() => {
scope.$parent[elementClass] = 'compact';
});
elem.removeClass('comfort').addClass('compact');
- 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 58.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
} else if (width > scope.maxWidth) {
scope.$parent.$applyAsync(() => {
scope.$parent[elementClass] = 'comfort';
});
elem.removeClass('compact').addClass('comfort');
- 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 58.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
scope.$watch('open', (value) => {
if (value) {
$popupWrapper.offset(popupService.position(260, 270, element));
scope.$broadcast('datepicker.focus');
}
- 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 57.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
scope.$watch('open', (value) => {
if (value) {
$popupWrapper.offset(popupService.position(200, 310, element));
scope.$broadcast('timepicker.focus');
}
- 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 57.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
var prevElem = elem.find('button:focus')
.parent('li')
.prev()
.children('button'),
categoryButton = elem.find('.levelup button');
- 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 50.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
var nextElem = elem.find('button:focus')
.parent('li')
.next()
.children('button'),
categoryButton = elem.find('.levelup button');
- 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 50.
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