wikimedia/mediawiki-core

View on GitHub
resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js

Summary

Maintainability
F
5 days
Test Coverage

File FiltersViewModel.js has 639 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var FilterGroup = require( './FilterGroup.js' ),
    FilterItem = require( './FilterItem.js' ),
    utils = require( '../utils.js' ),
    FiltersViewModel;

Severity: Major
Found in resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js - About 1 day to fix

    Function initializeFilters has 121 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    FiltersViewModel.prototype.initializeFilters = function ( filterGroups, views ) {
        var filterConflictResult, groupConflictResult,
            allViews,
            model = this,
            items = [],
    Severity: Major
    Found in resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js - About 4 hrs to fix

      Function findMatches has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      FiltersViewModel.prototype.findMatches = function ( query, returnFlat ) {
          var i, searchIsEmpty,
              groupTitle,
              result = {},
              flatResult = [],
      Severity: Minor
      Found in resources/src/mediawiki.rcfilters/dm/FiltersViewModel.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 findMatches has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      FiltersViewModel.prototype.findMatches = function ( query, returnFlat ) {
          var i, searchIsEmpty,
              groupTitle,
              result = {},
              flatResult = [],
      Severity: Minor
      Found in resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js - About 1 hr to fix

        Function reassessFilterInteractions has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        FiltersViewModel.prototype.reassessFilterInteractions = function ( item ) {
            var allSelected,
                model = this,
                iterationItems = item !== undefined ? [ item ] : this.getItems();
        
        
        Severity: Minor
        Found in resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js - About 1 hr to fix

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

                  expandConflictDefinitions = function ( obj ) {
                      var result = {};
          
                      // eslint-disable-next-line no-jquery/no-each-util
                      $.each( obj, function ( key, conflicts ) {
          Severity: Minor
          Found in resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                        if (
                            searchIsEmpty ||
                            items[ i ].getLabel().toLowerCase().indexOf( query ) > -1 ||
                            items[ i ].getDescription().toLowerCase().indexOf( query ) > -1 ||
                            groupTitle.toLowerCase().indexOf( query ) > -1 ||
            Severity: Major
            Found in resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js - About 1 hr to fix

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

                          if (
                              searchIsEmpty ||
                              items[ i ].getLabel().toLowerCase().indexOf( query ) > -1 ||
                              items[ i ].getDescription().toLowerCase().indexOf( query ) > -1 ||
                              groupTitle.toLowerCase().indexOf( query ) > -1 ||
              Severity: Major
              Found in resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js and 1 other location - About 2 hrs to fix
              resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js on lines 1067..1079

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

              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

                      if (
                          searchIsEmpty ||
                          items[ i ].getLabel().toLowerCase().indexOf( query ) === 0 ||
                          (
                              // For tags, we want the parameter name to be included in the search
              Severity: Major
              Found in resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js and 1 other location - About 2 hrs to fix
              resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js on lines 1086..1100

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

              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

              FiltersViewModel.prototype.areTagsEffectivelyInverted = function () {
                  return this.getTagsInvertModel().isSelected() &&
                      this.findSelectedItems().some( function ( itemModel ) {
                          return itemModel.getGroupModel().getName() === 'tagfilter';
                      } );
              Severity: Major
              Found in resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js and 1 other location - About 2 hrs to fix
              resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js on lines 937..942

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

              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

              FiltersViewModel.prototype.areNamespacesEffectivelyInverted = function () {
                  return this.getNamespacesInvertModel().isSelected() &&
                      this.findSelectedItems().some( function ( itemModel ) {
                          return itemModel.getGroupModel().getName() === 'namespace';
                      } );
              Severity: Major
              Found in resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js and 1 other location - About 2 hrs to fix
              resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js on lines 954..959

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

              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

              FiltersViewModel.prototype.getHighlightedItems = function () {
                  return this.getItems().filter( function ( filterItem ) {
                      return filterItem.isHighlightSupported() &&
                          filterItem.getHighlightColor();
                  } );
              Severity: Major
              Found in resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js and 1 other location - About 1 hr to fix
              resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js on lines 183..187

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

              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

              FiltersViewModel.prototype.hasConflict = function () {
                  return this.getItems().some( function ( filterItem ) {
                      return filterItem.isSelected() && filterItem.isConflicted();
                  } );
              };
              Severity: Major
              Found in resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js and 1 other location - About 1 hr to fix
              resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js on lines 1113..1118

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

              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

              FiltersViewModel.prototype.getItemsSupportingHighlights = function () {
                  return this.getItems().filter( function ( filterItem ) {
                      return filterItem.isHighlightSupported();
                  } );
              };
              Severity: Major
              Found in resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js and 1 other location - About 1 hr to fix
              resources/src/mediawiki.rcfilters/dm/FilterGroup.js on lines 446..450

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

              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

              FiltersViewModel.prototype.toggleInvertedNamespaces = function ( enable ) {
                  this.toggleFilterSelected( this.getNamespacesInvertModel().getName(), enable );
              };
              Severity: Minor
              Found in resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js and 1 other location - About 50 mins to fix
              resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js on lines 1297..1299

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

              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

              FiltersViewModel.prototype.toggleInvertedTags = function ( enable ) {
                  this.toggleFilterSelected( this.getTagsInvertModel().getName(), enable );
              };
              Severity: Minor
              Found in resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js and 1 other location - About 50 mins to fix
              resources/src/mediawiki.rcfilters/dm/FiltersViewModel.js on lines 1307..1309

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

              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