wikimedia/mediawiki-extensions-WikiLove

View on GitHub

Showing 30 of 81 total issues

File wikiLove.js has 565 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable no-jquery/no-global-selector */
const overlayContainer = document.createElement( 'div' );
const WikiLoveDialog = require( './WikiLoveDialog.vue' );
const Vue = require( 'vue' );
let options = {}, // options modifiable by the user
Severity: Major
Found in resources/ext.wikiLove.startup/wikiLove.js - About 1 day to fix

    File defaultOptions.js has 412 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // See https://www.mediawiki.org/wiki/Extension:WikiLove for basic documentation on configuration.
    
    module.exports = {
        defaultText:
            '{| style="background-color: $5; border: 1px solid $6;"\n' +
    Severity: Minor
    Found in resources/ext.wikiLove.startup/defaultOptions.js - About 5 hrs to fix

      Function showGallery has 73 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          showGallery: function () {
              let i, id, index, loadingIndex, galleryNumber, $img;
              const titles = [];
              const imageList = currentTypeOrSubtype.gallery.imageList.slice();
      
      
      Severity: Major
      Found in resources/ext.wikiLove.startup/wikiLove.js - About 2 hrs to fix

        Method execute has 70 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function execute() {
                $params = $this->extractRequestParams();
        
                // In some cases we need the wiki mark-up stripped from the subject
                $strippedSubject = $this->parserFactory->getInstance()->stripSectionName( $params['subject'] );
        Severity: Major
        Found in includes/ApiWikiLove.php - About 2 hrs to fix

          Function openDialog has 68 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              openDialog: function ( recipients, extraTags ) {
                  let type, typeId, $button;
                  // If a list of recipients are specified, this will override the normal
                  // behavior of WikiLove, which is to post on the Talk page of the
                  // current page. It will also disable redirecting the user after submitting.
          Severity: Major
          Found in resources/ext.wikiLove.startup/wikiLove.js - About 2 hrs to fix

            Function doSend has 66 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                doSend: function ( subject, wikitext, message, type, email, extraTags ) {
                    let targetBaseUrl, currentBaseUrl,
                        wikiLoveNumberAttempted = 0,
                        wikiLoveNumberPosted = 0;
            
            
            Severity: Major
            Found in resources/ext.wikiLove.startup/wikiLove.js - About 2 hrs to fix

              Function validatePreviewForm has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  validatePreviewForm: function ( e ) {
                      let imageTitle;
              
                      e.preventDefault();
                      $( '#mw-wikilove-success' ).hide();
              Severity: Minor
              Found in resources/ext.wikiLove.startup/wikiLove.js - About 2 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

              Function validatePreviewForm has 62 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  validatePreviewForm: function ( e ) {
                      let imageTitle;
              
                      e.preventDefault();
                      $( '#mw-wikilove-success' ).hide();
              Severity: Major
              Found in resources/ext.wikiLove.startup/wikiLove.js - About 2 hrs to fix

                Function rememberInputData has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    rememberInputData: function () {
                        if ( rememberData === null ) {
                            rememberData = {
                                header: '',
                                title: '',
                Severity: Minor
                Found in resources/ext.wikiLove.startup/wikiLove.js - About 2 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

                Function openDialog has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    openDialog: function ( recipients, extraTags ) {
                        let type, typeId, $button;
                        // If a list of recipients are specified, this will override the normal
                        // behavior of WikiLove, which is to post on the Talk page of the
                        // current page. It will also disable redirecting the user after submitting.
                Severity: Minor
                Found in resources/ext.wikiLove.startup/wikiLove.js - 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 updateAllDetails has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    updateAllDetails: function () {
                        // use remembered data for fields that can be set by the user
                        const currentRememberData = {
                            header: ( currentTypeOrSubtype.fields.indexOf( 'header' ) !== -1 ? rememberData.header : '' ),
                            title: ( currentTypeOrSubtype.fields.indexOf( 'title' ) !== -1 ? rememberData.title : '' ),
                Severity: Minor
                Found in resources/ext.wikiLove.startup/wikiLove.js - About 1 hr to fix

                  Function updateAllDetails has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      updateAllDetails: function () {
                          // use remembered data for fields that can be set by the user
                          const currentRememberData = {
                              header: ( currentTypeOrSubtype.fields.indexOf( 'header' ) !== -1 ? rememberData.header : '' ),
                              title: ( currentTypeOrSubtype.fields.indexOf( 'title' ) !== -1 ? rememberData.title : '' ),
                  Severity: Minor
                  Found in resources/ext.wikiLove.startup/wikiLove.js - 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 showImagePreview has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      showImagePreview: function () {
                          let $img;
                          const title = $.wikiLove.normalizeFilename( currentTypeOrSubtype.image );
                          const loadingType = currentTypeOrSubtype;
                          $( '#mw-wikilove-image-preview' ).show();
                  Severity: Minor
                  Found in resources/ext.wikiLove.startup/wikiLove.js - About 1 hr to fix

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

                        clickType: function ( e ) {
                            let subtypeId, subtype;
                            const newTypeId = $( this ).data( 'typeId' );
                    
                            e.preventDefault();
                    Severity: Minor
                    Found in resources/ext.wikiLove.startup/wikiLove.js - About 1 hr to fix

                      Function exports has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      module.exports = function ( grunt ) {
                          grunt.loadNpmTasks( 'grunt-eslint' );
                          grunt.loadNpmTasks( 'grunt-banana-checker' );
                          grunt.loadNpmTasks( 'grunt-stylelint' );
                      
                      
                      Severity: Minor
                      Found in Gruntfile.js - About 1 hr to fix

                        Function clickType has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                            clickType: function ( e ) {
                                let subtypeId, subtype;
                                const newTypeId = $( this ).data( 'typeId' );
                        
                                e.preventDefault();
                        Severity: Minor
                        Found in resources/ext.wikiLove.startup/wikiLove.js - 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

                        Method getAllowedParams has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function getAllowedParams() {
                                return [
                                    'title' => [
                                        ParamValidator::PARAM_TYPE => 'string',
                                        ParamValidator::PARAM_REQUIRED => true,
                        Severity: Minor
                        Found in includes/ApiWikiLove.php - About 1 hr to fix

                          Function rememberInputData has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              rememberInputData: function () {
                                  if ( rememberData === null ) {
                                      rememberData = {
                                          header: '',
                                          title: '',
                          Severity: Minor
                          Found in resources/ext.wikiLove.startup/wikiLove.js - About 1 hr to fix

                            Method onLoadExtensionSchemaUpdates has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function onLoadExtensionSchemaUpdates( $updater ) {
                                    $dbType = $updater->getDB()->getType();
                                    $path = dirname( __DIR__ ) . '/patches';
                                    if ( $dbType === 'mysql' ) {
                                        $updater->addExtensionTable( 'wikilove_log',
                            Severity: Minor
                            Found in includes/SchemaHooks.php - About 1 hr to fix

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

                                  submitSend: function ( e ) {
                                      e.preventDefault();
                                      $( '#mw-wikilove-success' ).hide();
                                      $( '#mw-wikilove-dialog' ).find( '.mw-wikilove-error' ).remove();
                              
                              
                              Severity: Minor
                              Found in resources/ext.wikiLove.startup/wikiLove.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language