wikimedia/mediawiki-core

View on GitHub
resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js

Summary

Maintainability
D
2 days
Test Coverage

File DateTimeFormatter.js has 312 lines of code (exceeds 250 allowed). Consider refactoring.
Open

( function () {

    /**
     * Abstract class for datetime formatters.
     *
Severity: Minor
Found in resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js - About 3 hrs to fix

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

        mw.widgets.datetime.DateTimeFormatter.prototype.getFieldForTag = function ( tag, params ) {
            var c, spec = null;
    
            switch ( tag ) {
                case 'intercalary':
    Severity: Major
    Found in resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js - About 3 hrs to fix

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

          mw.widgets.datetime.DateTimeFormatter.prototype.parseSpecValue = function ( v ) {
              var k, re;
      
              if ( v === '' ) {
                  return null;
      Severity: Minor
      Found in resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js - About 1 hr to fix

        Function MwWidgetsDatetimeDateTimeFormatter has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            mw.widgets.datetime.DateTimeFormatter = function MwWidgetsDatetimeDateTimeFormatter( config ) {
                this.constructor.static.setupDefaults();
        
                config = $.extend( {
                    format: '@default',
        Severity: Minor
        Found in resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                  if ( this.local ) {
                      return (
                          date1.getHours() === date2.getHours() &&
                          date1.getMinutes() === date2.getMinutes() &&
                          date1.getSeconds() === date2.getSeconds() &&
          Severity: Major
          Found in resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js - About 1 hr to fix

            Avoid too many return statements within this function.
            Open

                                return k;
            Severity: Major
            Found in resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return undefined;
              Severity: Major
              Found in resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                                return null;
                Severity: Major
                Found in resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js - About 30 mins to fix

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

                          if ( this.local ) {
                              return (
                                  date1.getHours() === date2.getHours() &&
                                  date1.getMinutes() === date2.getMinutes() &&
                                  date1.getSeconds() === date2.getSeconds() &&
                  resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js on lines 554..561

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

                  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

                          } else {
                              return (
                                  date1.getUTCHours() === date2.getUTCHours() &&
                                  date1.getUTCMinutes() === date2.getUTCMinutes() &&
                                  date1.getUTCSeconds() === date2.getUTCSeconds() &&
                  resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js on lines 547..554

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

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

                      mw.widgets.datetime.DateTimeFormatter.prototype.localChangesDatePart = function ( date ) {
                          return (
                              date.getUTCFullYear() !== date.getFullYear() ||
                              date.getUTCMonth() !== date.getMonth() ||
                              date.getUTCDate() !== date.getDate()
                  resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js on lines 524..530
                  resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js on lines 530..536

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

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

                          } else {
                              return (
                                  date1.getUTCFullYear() === date2.getUTCFullYear() &&
                                  date1.getUTCMonth() === date2.getUTCMonth() &&
                                  date1.getUTCDate() === date2.getUTCDate()
                  resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js on lines 524..530
                  resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js on lines 570..576

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

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

                          if ( this.local ) {
                              return (
                                  date1.getFullYear() === date2.getFullYear() &&
                                  date1.getMonth() === date2.getMonth() &&
                                  date1.getDate() === date2.getDate()
                  resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js on lines 530..536
                  resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js on lines 570..576

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

                  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 ( this.local ) {
                              ret.setHours(
                                  timepart.getHours(),
                                  timepart.getMinutes(),
                                  timepart.getSeconds(),
                  Severity: Minor
                  Found in resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js and 1 other location - About 30 mins to fix
                  resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js on lines 596..603

                  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

                          } else {
                              ret.setUTCHours(
                                  timepart.getUTCHours(),
                                  timepart.getUTCMinutes(),
                                  timepart.getUTCSeconds(),
                  Severity: Minor
                  Found in resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js and 1 other location - About 30 mins to fix
                  resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js on lines 589..596

                  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