wikimedia/mediawiki-extensions-UploadWizard

View on GitHub
resources/mw.UploadWizardDetails.js

Summary

Maintainability
F
1 wk
Test Coverage

File mw.UploadWizardDetails.js has 1005 lines of code (exceeds 250 allowed). Consider refactoring.
Open

( function ( uw ) {

    var NS_FILE = mw.config.get( 'wgNamespaceIds' ).file;

    /**
Severity: Major
Found in resources/mw.UploadWizardDetails.js - About 2 days to fix

    Function buildInterface has 282 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            buildInterface: function () {
                var descriptionRequired, uri,
                    details = this,
                    config = mw.UploadWizard.config,
                    captionsAvailable = config.wikibase.enabled && config.wikibase.captions,
    Severity: Major
    Found in resources/mw.UploadWizardDetails.js - About 1 day to fix

      Function validateWikiTextSubmitResult has 96 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              validateWikiTextSubmitResult: function ( params, result ) {
                  var wx, warningsKeys, existingFile, existingFileUrl, existingFileExt, ourFileExt, code, message,
                      details = this,
                      warnings = null,
                      ignoreTheseWarnings = false,
      Severity: Major
      Found in resources/mw.UploadWizardDetails.js - About 3 hrs to fix

        Function prefillDate has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                prefillDate: function () {
                    var dateObj, metadata, dateTimeRegex, matches, dateStr, saneTime,
                        dateMode = 'calendar',
                        yyyyMmDdRegex = /^(\d\d\d\d)[:/-](\d\d)[:/-](\d\d)\D.*/,
                        timeRegex = /\D(\d\d):(\d\d):(\d\d)/;
        Severity: Major
        Found in resources/mw.UploadWizardDetails.js - About 2 hrs to fix

          Function getWikiText has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  getWikiText: function () {
                      var deed, info, key,
                          information,
                          wikiText = '';
          
          
          Severity: Major
          Found in resources/mw.UploadWizardDetails.js - About 2 hrs to fix

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

                    submit: function () {
                        var details = this,
                            wikitext, promise, errorString;
            
                        this.$containerDiv.find( 'form' ).trigger( 'submit' );
            Severity: Minor
            Found in resources/mw.UploadWizardDetails.js - About 1 hr to fix

              Function setSerialized has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      setSerialized: function ( serialized ) {
                          var i;
              
                          if ( !this.interfaceBuilt ) {
                              // There's no interface yet! Don't load the data, just keep it
              Severity: Minor
              Found in resources/mw.UploadWizardDetails.js - About 1 hr to fix

                Function prefillLocation has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        prefillLocation: function () {
                            var dir,
                                m = this.upload.imageinfo.metadata,
                                values = {};
                
                
                Severity: Minor
                Found in resources/mw.UploadWizardDetails.js - About 1 hr to fix

                  Function submitWikiText has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          submitWikiText: function ( wikiText ) {
                              var params,
                                  tags = [ 'uploadwizard' ],
                                  deed = this.upload.deedChooser.deed,
                                  comment = '',
                  Severity: Minor
                  Found in resources/mw.UploadWizardDetails.js - About 1 hr to fix

                    Function processError has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            processError: function ( code, result ) {
                                var recoverable = [
                                    'abusefilter-disallowed',
                                    'abusefilter-warning',
                                    'spamblacklist',
                    Severity: Minor
                    Found in resources/mw.UploadWizardDetails.js - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                                  if (
                                      this.descriptionsDetails.getWikiText() === '' &&
                                      this.upload.file !== undefined
                                  ) {
                                      m = this.upload.imageinfo.metadata;
                      Severity: Major
                      Found in resources/mw.UploadWizardDetails.js - About 40 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                        return $.Deferred().reject( code, { errors: [ { html: message } ] } );
                        Severity: Major
                        Found in resources/mw.UploadWizardDetails.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                          return this.submitWikiTextInternal( params );
                          Severity: Major
                          Found in resources/mw.UploadWizardDetails.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                                    return this.submitWikiTextInternal( params );
                            Severity: Major
                            Found in resources/mw.UploadWizardDetails.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                              return $.Deferred().reject( 'this-info-missing', result );
                              Severity: Major
                              Found in resources/mw.UploadWizardDetails.js - About 30 mins to fix

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

                                            if ( config.defaults.description || uri.query.descriptionlang ) {
                                                this.descriptionsDetails.setSerialized( {
                                                    inputs: [
                                                        {
                                                            text: config.defaults.description || ''
                                Severity: Major
                                Found in resources/mw.UploadWizardDetails.js and 1 other location - About 6 hrs to fix
                                resources/mw.UploadWizardDetails.js on lines 392..405

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

                                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.defaults.caption || uri.query.captionlang ) {
                                                this.captionsDetails.setSerialized( {
                                                    inputs: [
                                                        {
                                                            text: config.defaults.caption || ''
                                Severity: Major
                                Found in resources/mw.UploadWizardDetails.js and 1 other location - About 6 hrs to fix
                                resources/mw.UploadWizardDetails.js on lines 407..420

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

                                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

                                        getErrors: function () {
                                            return $.when.apply( $, this.getAllFields().map( ( fieldLayout ) => {
                                                // return errors if field has them, empty array (no errors) otherwise
                                                if ( fieldLayout.fieldWidget.getErrors ) {
                                                    return fieldLayout.fieldWidget.getErrors();
                                Severity: Major
                                Found in resources/mw.UploadWizardDetails.js and 1 other location - About 2 hrs to fix
                                resources/mw.UploadWizardDetails.js on lines 562..570

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

                                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

                                        getWarnings: function () {
                                            return $.when.apply( $, this.getAllFields().map( ( fieldLayout ) => {
                                                // return warnings if field has them, empty array (no warnings) otherwise
                                                if ( fieldLayout.fieldWidget.getWarnings ) {
                                                    return fieldLayout.fieldWidget.getWarnings();
                                Severity: Major
                                Found in resources/mw.UploadWizardDetails.js and 1 other location - About 2 hrs to fix
                                resources/mw.UploadWizardDetails.js on lines 547..555

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

                                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

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

                                        showIndicator: function ( status ) {
                                            var progress = status === 'progress';
                                            this.$spinner.toggle( progress );
                                            this.statusMessage.toggle( status && !progress ).setType( status );
                                            this.$indicator.toggleClass( 'mwe-upwiz-file-indicator-visible', !!status );
                                Severity: Major
                                Found in resources/mw.UploadWizardDetails.js and 1 other location - About 2 hrs to fix
                                resources/mw.UploadWizardUploadInterface.js on lines 89..94

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

                                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 ( mw.UploadWizard.config.defaults.lon ) {
                                                values.longitude = mw.UploadWizard.config.defaults.lon;
                                            }
                                Severity: Major
                                Found in resources/mw.UploadWizardDetails.js and 2 other locations - About 45 mins to fix
                                resources/mw.UploadWizardDetails.js on lines 765..767
                                resources/mw.UploadWizardDetails.js on lines 771..773

                                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

                                Further Reading

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

                                            if ( mw.UploadWizard.config.defaults.heading ) {
                                                values.heading = mw.UploadWizard.config.defaults.heading;
                                            }
                                Severity: Major
                                Found in resources/mw.UploadWizardDetails.js and 2 other locations - About 45 mins to fix
                                resources/mw.UploadWizardDetails.js on lines 765..767
                                resources/mw.UploadWizardDetails.js on lines 768..770

                                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

                                Further Reading

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

                                            if ( mw.UploadWizard.config.defaults.lat ) {
                                                values.latitude = mw.UploadWizard.config.defaults.lat;
                                            }
                                Severity: Major
                                Found in resources/mw.UploadWizardDetails.js and 2 other locations - About 45 mins to fix
                                resources/mw.UploadWizardDetails.js on lines 768..770
                                resources/mw.UploadWizardDetails.js on lines 771..773

                                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

                                Further Reading

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

                                            this.otherDetails.$element.makeCollapsible( {
                                                collapsed: true,
                                                $customTogglers: this.otherDetailsField.$element.find( '.oo-ui-fieldLayout-header' )
                                            } );
                                Severity: Minor
                                Found in resources/mw.UploadWizardDetails.js and 1 other location - About 40 mins to fix
                                resources/controller/uw.controller.Details.js on lines 137..140

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

                                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.upload.file &&
                                                    this.upload.file.location &&
                                                    this.upload.file.location.latitude &&
                                Severity: Minor
                                Found in resources/mw.UploadWizardDetails.js and 1 other location - About 30 mins to fix
                                resources/details/uw.DateDetailsWidget.js on lines 106..106

                                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