FanaHOVA/blazer

View on GitHub
app/assets/javascripts/blazer/moment.js

Summary

Maintainability
F
1 wk
Test Coverage

File moment.js has 2351 lines of code (exceeds 250 allowed). Consider refactoring.
Open

//! moment.js
//! version : 2.9.0
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
//! license : MIT
//! momentjs.com
Severity: Major
Found in app/assets/javascripts/blazer/moment.js - About 6 days to fix

    Function addTimeToArrayFromToken has 117 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function addTimeToArrayFromToken(token, input, config) {
            var a, datePartArray = config._a;
    
            switch (token) {
            // QUARTER
    Severity: Major
    Found in app/assets/javascripts/blazer/moment.js - About 4 hrs to fix

      Function getParseRegexForToken has 83 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function getParseRegexForToken(token, config) {
              var a, strict = config._strict;
              switch (token) {
              case 'Q':
                  return parseTokenOneDigit;
      Severity: Major
      Found in app/assets/javascripts/blazer/moment.js - About 3 hrs to fix

        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] > 24 ||
        Severity: Critical
        Found in app/assets/javascripts/blazer/moment.js - About 2 hrs to fix

          Function duration has 58 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,
          Severity: Major
          Found in app/assets/javascripts/blazer/moment.js - About 2 hrs to fix

            Function makeDateFromStringAndFormat has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function makeDateFromStringAndFormat(config) {
                    if (config._f === moment.ISO_8601) {
                        parseISO(config);
                        return;
                    }
            Severity: Minor
            Found in app/assets/javascripts/blazer/moment.js - About 1 hr to fix

              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;
              Severity: Minor
              Found in app/assets/javascripts/blazer/moment.js - About 1 hr to fix

                Function dateFromConfig has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function dateFromConfig(config) {
                        var i, date, input = [], currentDate, yearToUse;
                
                        if (config._d) {
                            return;
                Severity: Minor
                Found in app/assets/javascripts/blazer/moment.js - About 1 hr to fix

                  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;
                  Severity: Minor
                  Found in app/assets/javascripts/blazer/moment.js - About 1 hr to fix

                    Function utcOffset has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            utcOffset : function (input, keepLocalTime) {
                                var offset = this._offset || 0,
                                    localAdjust;
                                if (input != null) {
                                    if (typeof input === 'string') {
                    Severity: Minor
                    Found in app/assets/javascripts/blazer/moment.js - About 1 hr to fix

                      Function makeDateFromStringAndArray has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function makeDateFromStringAndArray(config) {
                              var tempConfig,
                                  bestMoment,
                      
                                  scoreToBeat,
                      Severity: Minor
                      Found in app/assets/javascripts/blazer/moment.js - About 1 hr to fix

                        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) {
                        Severity: Minor
                        Found in app/assets/javascripts/blazer/moment.js - About 1 hr to fix

                          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) {
                          Severity: Minor
                          Found in app/assets/javascripts/blazer/moment.js - About 1 hr to fix

                            Function makeMoment has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                function makeMoment(config) {
                                    var input = config._i,
                                        format = config._f,
                                        res;
                            
                            
                            Severity: Minor
                            Found in app/assets/javascripts/blazer/moment.js - About 1 hr to fix

                              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 &&
                              Severity: Major
                              Found in app/assets/javascripts/blazer/moment.js - About 1 hr to fix

                                Function makeDate has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    function makeDate(y, m, d, h, M, s, ms) {
                                Severity: Major
                                Found in app/assets/javascripts/blazer/moment.js - About 50 mins to fix

                                  Function substituteTimeAgo has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
                                  Severity: Minor
                                  Found in app/assets/javascripts/blazer/moment.js - About 35 mins to fix

                                    Function dayOfYearFromWeeks has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                        function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {
                                    Severity: Minor
                                    Found in app/assets/javascripts/blazer/moment.js - About 35 mins to fix

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

                                              } else {
                                                  anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
                                                  // linear across the month
                                                  adjust = (b - anchor) / (anchor2 - anchor);
                                              }
                                      Severity: Minor
                                      Found in app/assets/javascripts/blazer/moment.js and 1 other location - About 55 mins to fix
                                      app/assets/javascripts/blazer/moment.js on lines 366..370

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

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

                                              if (b - anchor < 0) {
                                                  anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
                                                  // linear across the month
                                                  adjust = (b - anchor) / (anchor - anchor2);
                                              } else {
                                      Severity: Minor
                                      Found in app/assets/javascripts/blazer/moment.js and 1 other location - About 55 mins to fix
                                      app/assets/javascripts/blazer/moment.js on lines 370..374

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

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

                                                          this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
                                      Severity: Minor
                                      Found in app/assets/javascripts/blazer/moment.js and 1 other location - About 35 mins to fix
                                      app/assets/javascripts/blazer/moment.js on lines 902..902

                                      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

                                      Further Reading

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

                                                          this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
                                      Severity: Minor
                                      Found in app/assets/javascripts/blazer/moment.js and 1 other location - About 35 mins to fix
                                      app/assets/javascripts/blazer/moment.js on lines 901..901

                                      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

                                      Further Reading

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

                                              max: deprecate(
                                                      'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
                                                      function (other) {
                                                          other = moment.apply(null, arguments);
                                                          return other > this ? this : other;
                                      Severity: Minor
                                      Found in app/assets/javascripts/blazer/moment.js and 1 other location - About 30 mins to fix
                                      app/assets/javascripts/blazer/moment.js on lines 2450..2456

                                      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

                                      Further Reading

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

                                              if (config._a[HOUR] === 24 &&
                                                      config._a[MINUTE] === 0 &&
                                                      config._a[SECOND] === 0 &&
                                      Severity: Minor
                                      Found in app/assets/javascripts/blazer/moment.js and 1 other location - About 30 mins to fix
                                      app/assets/javascripts/blazer/moment.js on lines 759..761

                                      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

                                      Further Reading

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

                                                          (m._a[HOUR] === 24 && (m._a[MINUTE] !== 0 ||
                                                                                 m._a[SECOND] !== 0 ||
                                                                                 m._a[MILLISECOND] !== 0)) ? HOUR :
                                      Severity: Minor
                                      Found in app/assets/javascripts/blazer/moment.js and 1 other location - About 30 mins to fix
                                      app/assets/javascripts/blazer/moment.js on lines 1469..1471

                                      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

                                      Further Reading

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

                                              min: deprecate(
                                                       'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
                                                       function (other) {
                                                           other = moment.apply(null, arguments);
                                                           return other < this ? this : other;
                                      Severity: Minor
                                      Found in app/assets/javascripts/blazer/moment.js and 1 other location - About 30 mins to fix
                                      app/assets/javascripts/blazer/moment.js on lines 2458..2464

                                      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

                                      Further Reading

                                      There are no issues that match your filters.

                                      Category
                                      Status