wikimedia/mediawiki-extensions-UploadWizard

View on GitHub

Showing 260 of 260 total issues

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

        if ( this.aborted ) {
            return $.Deferred().reject( 'aborted', {
                errors: [ {
                    code: 'aborted',
                    html: mw.message( 'api-error-aborted' ).parse()
Severity: Major
Found in resources/transports/mw.FormDataTransport.js and 2 other locations - About 1 hr to fix
resources/transports/mw.FormDataTransport.js on lines 199..206
resources/transports/mw.FormDataTransport.js on lines 372..392

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

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

Function generateReadHtml has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function generateReadHtml() {
        $config = $this->campaign->getParsedConfig();

        $campaignTitle = $config['title'] ?? $this->campaign->getName();
        $campaignDescription = $config['description'] ?? '';
Severity: Minor
Found in includes/CampaignPageFormatter.php - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function arrayReplaceSanely has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public static function arrayReplaceSanely( $array, $array1 ) {
        $newArray = [];

        foreach ( $array as $key => $value ) {
            if ( array_key_exists( $key, $array1 ) ) {
Severity: Minor
Found in includes/Config.php - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

    $.fn.morphCrossfade = function ( newPanelSelector, speed ) {
        var $this = $( this );

        if ( typeof speed === 'undefined' ) {
            speed = 400;
Severity: Minor
Found in resources/jquery/jquery.morphCrossfade.js - About 1 hr to fix

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

        uw.ConcurrentQueue.prototype.removeItem = function ( item ) {
            var index, found;
    
            found = false;
    
    
    Severity: Minor
    Found in resources/uw.ConcurrentQueue.js - About 1 hr to fix

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

          uw.ui.Upload.prototype.load = function ( uploads ) {
              uw.ui.Step.prototype.load.call( this, uploads );
      
              if ( uploads.length === 0 ) {
                  this.$fileList.removeClass( 'mwe-upwiz-filled-filelist' );
      Severity: Minor
      Found in resources/ui/steps/uw.ui.Upload.js - About 1 hr to fix

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

            uw.MultipleLanguageInputWidget = function UWMultipleLanguageInputWidget( config ) {
                this.config = Object.assign( {
                    required: true,
                    label: mw.message( '' ),
                    errorBlank: mw.message( 'mwe-upwiz-error-blank' ),
        Severity: Minor
        Found in resources/details/uw.MultipleLanguageInputWidget.js - About 1 hr to fix

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

              uw.ui.Upload.prototype.updateFileCounts = function ( haveUploads, fewerThanMax ) {
                  this.$fileList.toggleClass( 'mwe-upwiz-filled-filelist', haveUploads );
                  this.$addFileContainer.toggleClass( 'mwe-upwiz-add-files-0', !haveUploads );
          
                  this.setAddButtonText( haveUploads );
          Severity: Minor
          Found in resources/ui/steps/uw.ui.Upload.js - About 1 hr to fix

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

                    return $.when( flickrPromise, this.getBlacklist() ).then( ( photoset, blacklist ) => {
                        var sourceURL;
                        var checkboxes = [];
                        var checkboxesWidget = new OO.ui.CheckboxMultiselectWidget();
                        var x = 0;
            Severity: Major
            Found in resources/mw.FlickrChecker.js and 1 other location - About 1 hr to fix
            resources/mw.FlickrChecker.js on lines 518..593

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

            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

                    return this.flickrRequest( {
                        method: 'flickr.photos.getInfo',
                        photo_id: photoId
                    } ).then( ( data ) => {
                        if ( !data.photo ) {
            Severity: Major
            Found in resources/mw.FlickrChecker.js and 1 other location - About 1 hr to fix
            resources/mw.FlickrChecker.js on lines 373..504

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

            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

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

                uw.UlsWidget = function UWUlsWidget( config ) {
                    uw.UlsWidget.super.call( this );
            
                    this.$element = $( '<div>' )
                        .append(
            Severity: Minor
            Found in resources/details/uw.UlsWidget.js - About 1 hr to fix

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

                  uw.controller.Upload = function UWControllerUpload( api, config ) {
                      var step = this;
              
                      uw.controller.Step.call(
                          this,
              Severity: Minor
              Found in resources/controller/uw.controller.Upload.js - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                    if ( config.licenseGroups === undefined ) {
                        var group = new mw.uploadWizard.LicenseGroup( config, this.type, this.api, this.count );
                        groups.push( group );
                        this.$element.append( this.$group );
                    } else {
                Severity: Major
                Found in resources/mw.UploadWizardLicenseInput.js - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                          if ( albumIdMatches || photoIdMatches || userCollectionMatches || userPhotostreamMatches ||
                              groupPoolMatches || userGalleryMatches || userFavoritesMatches ) {
                              // eslint-disable-next-line no-jquery/no-global-selector
                              $( '#mwe-upwiz-upload-add-flickr-container' ).hide();
                              this.imageUploads = [];
                  Severity: Major
                  Found in resources/mw.FlickrChecker.js - About 1 hr to fix

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

                        uw.StatementWidget.prototype.getErrors = function () {
                            return $.Deferred().resolve( [] ).promise();
                        };
                    Severity: Major
                    Found in resources/details/uw.StatementWidget.js and 3 other locations - About 55 mins to fix
                    resources/details/uw.CategoriesDetailsWidget.js on lines 46..48
                    resources/uw.DetailsWidget.js on lines 44..46
                    resources/uw.DetailsWidget.js on lines 54..56

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

                    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.authorInput.$element.after(
                                        $( '<div>' ).addClass( 'mwe-upwiz-thirdparty-checkbox' )
                                            .append( this.templateOptions.authorUnknown.field.$element )
                                    );
                    Severity: Minor
                    Found in resources/deed/uw.deed.ThirdParty.js and 1 other location - About 55 mins to fix
                    resources/deed/uw.deed.ThirdParty.js on lines 238..241

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

                    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.sourceInput.$element.after(
                                    $( '<div>' ).addClass( 'mwe-upwiz-thirdparty-checkbox' )
                                        .append( this.templateOptions.aiGenerated.field.$element )
                                );
                    Severity: Minor
                    Found in resources/deed/uw.deed.ThirdParty.js and 1 other location - About 55 mins to fix
                    resources/deed/uw.deed.ThirdParty.js on lines 265..268

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

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

                        uw.CategoriesDetailsWidget.prototype.getErrors = function () {
                            return $.Deferred().resolve( [] ).promise();
                        };
                    Severity: Major
                    Found in resources/details/uw.CategoriesDetailsWidget.js and 3 other locations - About 55 mins to fix
                    resources/details/uw.StatementWidget.js on lines 103..105
                    resources/uw.DetailsWidget.js on lines 44..46
                    resources/uw.DetailsWidget.js on lines 54..56

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

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

                        uw.DetailsWidget.prototype.getErrors = function () {
                            return $.Deferred().resolve( [] ).promise();
                        };
                    Severity: Major
                    Found in resources/uw.DetailsWidget.js and 3 other locations - About 55 mins to fix
                    resources/details/uw.CategoriesDetailsWidget.js on lines 46..48
                    resources/details/uw.StatementWidget.js on lines 103..105
                    resources/uw.DetailsWidget.js on lines 54..56

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

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

                        uw.DetailsWidget.prototype.getWarnings = function () {
                            return $.Deferred().resolve( [] ).promise();
                        };
                    Severity: Major
                    Found in resources/uw.DetailsWidget.js and 3 other locations - About 55 mins to fix
                    resources/details/uw.CategoriesDetailsWidget.js on lines 46..48
                    resources/details/uw.StatementWidget.js on lines 103..105
                    resources/uw.DetailsWidget.js on lines 44..46

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

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language