File moment.js
has 2203 lines of code (exceeds 250 allowed). Consider refactoring. Open
//! moment.js
//! version : 2.8.3
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
//! license : MIT
//! momentjs.com
Function addTimeToArrayFromToken
has 112 lines of code (exceeds 25 allowed). Consider refactoring. Open
function addTimeToArrayFromToken(token, input, config) {
var a, datePartArray = config._a;
switch (token) {
// QUARTER
Function getParseRegexForToken
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getParseRegexForToken(token, config) {
var a, strict = config._strict;
switch (token) {
case 'Q':
return parseTokenOneDigit;
Function duration
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
moment.duration = function (input, key) {
var duration = input,
// matching against regexp is expensive, do it on demand
match = null,
sign,
Function makeDateFromStringAndFormat
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
function makeDateFromStringAndFormat(config) {
if (config._f === moment.ISO_8601) {
parseISO(config);
return;
}
Function copyConfig
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
function copyConfig(to, from) {
var i, prop, val;
if (typeof from._isAMomentObject !== 'undefined') {
to._isAMomentObject = from._isAMomentObject;
Function makeList
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function makeList(field) {
var count, setter;
if (field.indexOf('week') === 0) {
count = 7;
Consider simplifying this complex logical expression. Open
if (m._a && m._pf.overflow === -2) {
overflow =
m._a[MONTH] < 0 || m._a[MONTH] > 11 ? MONTH :
m._a[DATE] < 1 || m._a[DATE] > daysInMonth(m._a[YEAR], m._a[MONTH]) ? DATE :
m._a[HOUR] < 0 || m._a[HOUR] > 23 ? HOUR :
Function zone
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
zone : function (input, keepLocalTime) {
var offset = this._offset || 0,
localAdjust;
if (input != null) {
if (typeof input === 'string') {
Function makeDateFromStringAndArray
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function makeDateFromStringAndArray(config) {
var tempConfig,
bestMoment,
scoreToBeat,
Function dayOfYearFromWeekInfo
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function dayOfYearFromWeekInfo(config) {
var w, weekYear, week, weekday, dow, doy, temp;
w = config._w;
if (w.GG != null || w.W != null || w.E != null) {
Function startOf
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
startOf : function (units) {
units = normalizeUnits(units);
// the following switch intentionally omits break keywords
// to utilize falling through the cases.
switch (units) {
Function dateFromConfig
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function dateFromConfig(config) {
var i, date, input = [], currentDate, yearToUse;
if (config._d) {
return;
Consider simplifying this complex logical expression. Open
if (m._isValid == null) {
m._isValid = !isNaN(m._d.getTime()) &&
m._pf.overflow < 0 &&
!m._pf.empty &&
!m._pf.invalidMonth &&
Function makeDate
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
function makeDate(y, m, d, h, M, s, ms) {
Function substituteTimeAgo
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
Function dayOfYearFromWeeks
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {
Identical blocks of code found in 2 locations. Consider refactoring. Open
(function (undefined) {
/************************************
Constants
************************************/
- 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 22246.
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