File jquery.countdown.js
has 617 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* http://keith-wood.name/countdown.html
Countdown for jQuery v1.5.10.
Written by Keith Wood (kbwood{at}iinet.com.au) January 2008.
Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and
MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses.
Function _calculatePeriods
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
_calculatePeriods: function (inst, show, significant, now) {
// Find endpoints
inst._now = now;
inst._now.setMilliseconds(0);
var until = new Date(inst._now.getTime());
Function _buildLayout
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
_buildLayout: function (inst, show, layout, compact, significant, showSignificant) {
var labels = inst.options[compact ? 'compactLabels' : 'labels'];
var whichLabels = inst.options.whichLabels || this._normalLabels;
var labelFor = function (index) {
return (inst.options[(compact ? 'compactLabels' : 'labels') +
Function _generateHTML
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
_generateHTML: function (inst) {
var self = this;
// Determine what to show
inst._periods = (inst._hold ? inst._periods :
this._calculatePeriods(inst, inst._show, inst.options.significant, new Date()));
Function Countdown
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
function Countdown() {
this.regional = []; // Available regional settings, indexed by language code
this.regional[''] = { // Default regional settings
// The display texts for the counters
labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'],
Function _determineTime
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
_determineTime: function (setting, defaultTime) {
var offsetNumeric = function (offset) { // e.g. +300, -2
var time = new Date();
time.setTime(time.getTime() + offset * 1000);
return time;
Function _updateCountdown
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
_updateCountdown: function (target, inst) {
var $target = $(target);
inst = inst || $target.data(this.propertyName);
if (!inst) {
return;
Function offsetString
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
var offsetString = function (offset) { // e.g. '+2d', '-4w', '+3h +30m'
offset = offset.toLowerCase();
var time = new Date();
var year = time.getFullYear();
var month = time.getMonth();
Function _adjustSettings
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
_adjustSettings: function (target, inst) {
var now;
var serverOffset = 0;
var serverEntry = null;
for (var i = 0; i < this._serverSyncs.length; i++) {
Function UTCDate
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
UTCDate: function (tz, year, month, day, hours, mins, secs, ms) {
Consider simplifying this complex logical expression. Open
if (!requestAnimationFrame || $.noRequestAnimationFrame) {
$.noRequestAnimationFrame = null;
setInterval(function () {
plugin._updateTargets();
}, 980); // Fall back to good old setInterval
Consider simplifying this complex logical expression. Open
if (show[Y] || show[O]) {
// Treat end of months as the same
var lastNow = plugin._getDaysInMonth(now.getFullYear(), now.getMonth());
var lastUntil = plugin._getDaysInMonth(until.getFullYear(), until.getMonth());
var sameDay = (until.getDate() == now.getDate() ||
Function _buildLayout
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
_buildLayout: function (inst, show, layout, compact, significant, showSignificant) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
case 'o':
month += parseInt(matches[1], 10);
day = Math.min(day, plugin._getDaysInMonth(year, month));
break;
- 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 46.
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
case 'y':
year += parseInt(matches[1], 10);
day = Math.min(day, plugin._getDaysInMonth(year, month));
break;
- 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 46.
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 5 locations. Consider refactoring. Open
this._timerTargets = $.map(this._timerTargets,
function (value) {
return (value == target ? null : value);
}); // delete entry
- 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 45.
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