wikimedia/mediawiki-extensions-UploadWizard

View on GitHub

Showing 272 of 272 total issues

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

        layout.$element.append(
            $( '<strong>' ).text( mw.msg( 'mwe-upwiz-patent-dialog-title-warranty' ) ),
            $( '<p>' ).text( mw.msg( 'mwe-upwiz-patent-dialog-text-warranty', this.uploads.length ) ),
            $( '<a>' )
                .text( mw.msg( 'mwe-upwiz-patent-dialog-link-warranty' ) )
Severity: Major
Found in resources/deed/dialog/uw.deed.dialog.PatentDialog.js and 1 other location - About 4 hrs to fix
resources/deed/dialog/uw.deed.dialog.PatentDialog.js on lines 124..130

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

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

Method generateReadHtml has 103 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

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

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

        mw.UploadWizardUploadInterface.prototype.getExistingImageNotice = function () {
            if ( mw.UploadWizard.config && mw.UploadWizard.config.display && mw.UploadWizard.config.display.noticeExistingImage ) {
                return mw.UploadWizard.config.display.noticeExistingImage;
            } else {
                return mw.message( 'mwe-upwiz-objref-notice-existing-image' ).text();
    Severity: Major
    Found in resources/mw.UploadWizardUploadInterface.js and 1 other location - About 4 hrs to fix
    resources/mw.UploadWizardUploadInterface.js on lines 302..308

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

    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

        mw.UploadWizardUploadInterface.prototype.getPickImageLabel = function () {
            if ( mw.UploadWizard.config && mw.UploadWizard.config.display && mw.UploadWizard.config.display.labelPickImage ) {
                return mw.UploadWizard.config.display.labelPickImage;
            } else {
                return mw.message( 'mwe-upwiz-objref-pick-image' ).text();
    Severity: Major
    Found in resources/mw.UploadWizardUploadInterface.js and 1 other location - About 4 hrs to fix
    resources/mw.UploadWizardUploadInterface.js on lines 294..300

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

    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 getParsedConfig has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getParsedConfig( Language $lang = null ) {
            if ( $lang === null ) {
                $lang = $this->context->getLanguage();
            }
    
    
    Severity: Minor
    Found in includes/Campaign.php - About 3 hrs 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

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

                this.$div.prepend(
                    $( '<div>' )
                        .addClass( 'mwe-upwiz-license-metadata ui-corner-all' )
                        .append(
                            $( '<h4>' ).text( mw.msg( 'mwe-upwiz-license-metadata-title' ) ),
    Severity: Major
    Found in resources/ui/steps/uw.ui.Details.js and 1 other location - About 3 hrs to fix
    resources/ui/steps/uw.ui.Metadata.js on lines 79..89

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

    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.$content.after(
                $( '<div>' )
                    .addClass( 'mwe-upwiz-license-metadata ui-corner-all' )
                    .append(
                        $( '<h4>' ).text( mw.msg( 'mwe-upwiz-license-metadata-statements-title' ) ),
    Severity: Major
    Found in resources/ui/steps/uw.ui.Metadata.js and 1 other location - About 3 hrs to fix
    resources/ui/steps/uw.ui.Details.js on lines 75..85

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

    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 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 checkUnique has 93 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              checkUnique: function ( title ) {
                  var checker = this,
                      NS_FILE = mw.config.get( 'wgNamespaceIds' ).file,
                      titleObj, prefix, ext;
      
      
      Severity: Major
      Found in resources/mw.DestinationChecker.js - About 3 hrs to fix

        Function addJsVars has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            public function addJsVars( $subPage ) {
                $config = Config::getConfig( $this->campaign );
        
                if ( array_key_exists( 'trackingCategory', $config ) ) {
                    if ( array_key_exists( 'campaign', $config['trackingCategory'] ) ) {
        Severity: Minor
        Found in includes/Specials/SpecialUploadWizard.php - About 3 hrs 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

        File Campaign.php has 309 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        namespace MediaWiki\Extension\UploadWizard;
        
        use InvalidArgumentException;
        Severity: Minor
        Found in includes/Campaign.php - About 3 hrs to fix

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

                  if ( text === '' ) {
                      errors.push( mw.message( 'mwe-upwiz-error-signature-blank' ) );
                  } else if ( text.length < minLength ) {
                      errors.push( mw.message( 'mwe-upwiz-error-signature-too-short', minLength ) );
                  } else if ( text.length > maxLength ) {
          Severity: Major
          Found in resources/deed/uw.deed.OwnWork.js and 2 other locations - About 3 hrs to fix
          resources/deed/uw.deed.ThirdParty.js on lines 55..61
          resources/deed/uw.deed.ThirdParty.js on lines 99..105

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

          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 ( text === '' ) {
                          errors.push( mw.message( 'mwe-upwiz-error-question-blank' ) );
                      } else if ( text.length < minLength ) {
                          errors.push( mw.message( 'mwe-upwiz-error-too-short', minLength ) );
                      } else if ( text.length > maxLength ) {
          Severity: Major
          Found in resources/deed/uw.deed.ThirdParty.js and 2 other locations - About 3 hrs to fix
          resources/deed/uw.deed.OwnWork.js on lines 585..591
          resources/deed/uw.deed.ThirdParty.js on lines 55..61

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

          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 ( text === '' ) {
                          errors.push( mw.message( 'mwe-upwiz-error-question-blank' ) );
                      } else if ( text.length < minLength ) {
                          errors.push( mw.message( 'mwe-upwiz-error-too-short', minLength ) );
                      } else if ( text.length > maxLength ) {
          Severity: Major
          Found in resources/deed/uw.deed.ThirdParty.js and 2 other locations - About 3 hrs to fix
          resources/deed/uw.deed.OwnWork.js on lines 585..591
          resources/deed/uw.deed.ThirdParty.js on lines 99..105

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

          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

                      ui.$buttons.append(
                          $( '<div>' )
                              .addClass( 'mwe-upwiz-file-next-some-failed mwe-upwiz-file-endchoice' )
                              .append(
                                  new OO.ui.HorizontalLayout( {
          Severity: Major
          Found in resources/ui/steps/uw.ui.Details.js and 1 other location - About 3 hrs to fix
          resources/ui/steps/uw.ui.Upload.js on lines 363..377

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

          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

                      ui.$buttons.append(
                          $( '<div>' )
                              .addClass( 'mwe-upwiz-file-next-some-failed mwe-upwiz-file-endchoice' )
                              .append(
                                  new OO.ui.HorizontalLayout( {
          Severity: Major
          Found in resources/ui/steps/uw.ui.Upload.js and 1 other location - About 3 hrs to fix
          resources/ui/steps/uw.ui.Details.js on lines 124..138

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

          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 UploadWizardLicenseInput has 83 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          mw.UploadWizardLicenseInput = function ( config, count, api ) {
              mw.UploadWizardLicenseInput.super.call( this );
              OO.ui.mixin.GroupElement.call( this );
          
              this.count = count;
          Severity: Major
          Found in resources/mw.UploadWizardLicenseInput.js - About 3 hrs to fix

            Method onGetPreferences has 79 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function onGetPreferences( $user, &$preferences ) {
                    $config = Config::getConfig();
            
                    // User preference to skip the licensing tutorial, provided it's not globally disabled
                    if ( Config::getSetting( 'tutorial' ) != [] ) {
            Severity: Major
            Found in includes/Hooks.php - About 3 hrs to fix

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

                          ui.$buttons.append(
                              $( '<div>' )
                                  .addClass( 'mwe-upwiz-file-next-all-failed mwe-upwiz-file-endchoice' )
                                  .append(
                                      new OO.ui.HorizontalLayout( {
              Severity: Major
              Found in resources/ui/steps/uw.ui.Details.js and 2 other locations - About 3 hrs to fix
              resources/ui/steps/uw.ui.Upload.js on lines 348..361
              resources/ui/steps/uw.ui.Upload.js on lines 379..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 97.

              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

                          ui.$buttons.append(
                              $( '<div>' )
                                  .addClass( 'mwe-upwiz-file-next-all-failed mwe-upwiz-file-endchoice' )
                                  .append(
                                      new OO.ui.HorizontalLayout( {
              Severity: Major
              Found in resources/ui/steps/uw.ui.Upload.js and 2 other locations - About 3 hrs to fix
              resources/ui/steps/uw.ui.Details.js on lines 140..153
              resources/ui/steps/uw.ui.Upload.js on lines 348..361

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

              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