wikimedia/mediawiki-core

View on GitHub
resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js

Summary

Maintainability
F
3 days
Test Coverage

File FilterTagMultiselectWidget.js has 523 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var ViewSwitchWidget = require( './ViewSwitchWidget.js' ),
    SaveFiltersPopupButtonWidget = require( './SaveFiltersPopupButtonWidget.js' ),
    MenuSelectWidget = require( './MenuSelectWidget.js' ),
    FilterTagItemWidget = require( './FilterTagItemWidget.js' ),
    FilterTagMultiselectWidget;
Severity: Major
Found in resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js - About 1 day to fix

    Function MwRcfiltersUiFilterTagMultiselectWidget has 163 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    FilterTagMultiselectWidget = function MwRcfiltersUiFilterTagMultiselectWidget( controller, model, savedQueriesModel, config ) {
        var $rcFiltersRow,
            title = new OO.ui.LabelWidget( {
                label: mw.msg( 'rcfilters-activefilters' ),
                classes: [ 'mw-rcfilters-ui-filterTagMultiselectWidget-wrapper-content-title' ]
    Severity: Major
    Found in resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js - About 6 hrs to fix

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

      FilterTagMultiselectWidget.prototype.onMenuToggle = function ( isVisible ) {
      
          var scrollToElement = this.isMobile ? this.input.$input : this.$element;
      
          // Parent
      Severity: Minor
      Found in resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.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 createViewsSelectWidget has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      FilterTagMultiselectWidget.prototype.createViewsSelectWidget = function () {
          var viewsSelectWidget = new OO.ui.ButtonGroupWidget( {
              classes: this.isMobile ?
                  [
                      'mw-rcfilters-ui-table',
      Severity: Minor
      Found in resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js - About 1 hr to fix

        Function restructureViewsSelectWidget has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        FilterTagMultiselectWidget.prototype.restructureViewsSelectWidget = function () {
            if ( this.isMobile ) {
                // On mobile, append the search input and the extra buttons below the search input.
                this.$element.append(
                    $( '<div>' )
        Severity: Minor
        Found in resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js - About 1 hr to fix

          Function MwRcfiltersUiFilterTagMultiselectWidget has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          FilterTagMultiselectWidget = function MwRcfiltersUiFilterTagMultiselectWidget( controller, model, savedQueriesModel, config ) {
              var $rcFiltersRow,
                  title = new OO.ui.LabelWidget( {
                      label: mw.msg( 'rcfilters-activefilters' ),
                      classes: [ 'mw-rcfilters-ui-filterTagMultiselectWidget-wrapper-content-title' ]
          Severity: Minor
          Found in resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js - About 55 mins 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 onModelItemUpdate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          FilterTagMultiselectWidget.prototype.onModelItemUpdate = function ( item ) {
              if ( !item.getGroupModel().isHidden() ) {
                  if (
                      item.isSelected() ||
                      (
          Severity: Minor
          Found in resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js - About 55 mins 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

                      new OO.ui.ButtonWidget( {
                          framed: !!this.isMobile,
                          data: 'namespaces',
                          icon: 'article',
                          label: mw.msg( 'namespaces' ),
          resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js on lines 272..279

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

          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

                      new OO.ui.ButtonWidget( {
                          framed: !!this.isMobile,
                          data: 'tags',
                          icon: 'tag',
                          label: mw.msg( 'tags-title' ),
          resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js on lines 264..271

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

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                  } else {
                      // Only attempt to remove the tag if we can find an item for it (T198140, T198231)
                      if ( this.findItemFromData( item.getName() ) !== null ) {
                          this.removeTagByData( item.getName() );
                      }
          resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js on lines 626..631

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

          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 ( !filterItem.isSelected() ) {
                          // Only attempt to remove the tag if we can find an item for it (T198140, T198231)
                          if ( this.findItemFromData( filterItem.getName() ) !== null ) {
                              this.removeTagByData( filterItem.getName() );
                          }
          resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js on lines 571..576

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 49.

          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

              $rcFiltersRow.append(
                  $( '<div>' )
                      .addClass( 'mw-rcfilters-ui-cell' )
                      .addClass( 'mw-rcfilters-ui-filterTagMultiselectWidget-cell-reset' )
                      .append( this.resetButton.$element )
          resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js on lines 177..182

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

          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

                  $rcFiltersRow.append(
                      $( '<div>' )
                          .addClass( 'mw-rcfilters-ui-cell' )
                          .addClass( 'mw-rcfilters-ui-filterTagMultiselectWidget-cell-save' )
                          .append( this.saveQueryButton.$element )
          resources/src/mediawiki.rcfilters/ui/FilterTagMultiselectWidget.js on lines 195..200

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

          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