wikimedia/mediawiki-core

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

Summary

Maintainability
F
4 days
Test Coverage

File FilterGroup.js has 477 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

/**
Severity: Minor
Found in resources/src/mediawiki.rcfilters/dm/FilterGroup.js - About 7 hrs to fix

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

    FilterGroup.prototype.initializeFilters = function ( filterDefinition, groupDefault ) {
        var defaultParam,
            supersetMap = {},
            model = this,
            items = [];
    Severity: Major
    Found in resources/src/mediawiki.rcfilters/dm/FilterGroup.js - About 3 hrs to fix

      Function getFilterRepresentation has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      FilterGroup.prototype.getFilterRepresentation = function ( paramRepresentation ) {
          var areAnySelected, paramValues, item, currentValue,
              oneWasSelected = false,
              defaultParams = this.getDefaultParams(),
              expandedParams = $.extend( true, {}, paramRepresentation ),
      Severity: Major
      Found in resources/src/mediawiki.rcfilters/dm/FilterGroup.js - About 3 hrs to fix

        Function getParamRepresentation has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        FilterGroup.prototype.getParamRepresentation = function ( filterRepresentation ) {
            var values,
                areAnySelected = false,
                buildFromCurrentState = !filterRepresentation,
                defaultFilters = this.getDefaultFilters(),
        Severity: Major
        Found in resources/src/mediawiki.rcfilters/dm/FilterGroup.js - About 2 hrs to fix

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

          FilterGroup.prototype.initializeFilters = function ( filterDefinition, groupDefault ) {
              var defaultParam,
                  supersetMap = {},
                  model = this,
                  items = [];
          Severity: Minor
          Found in resources/src/mediawiki.rcfilters/dm/FilterGroup.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 onFilterItemUpdate has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          FilterGroup.prototype.onFilterItemUpdate = function ( item ) {
              // Update state
              var changed = false,
                  active = this.areAnySelected(),
                  model = this;
          Severity: Minor
          Found in resources/src/mediawiki.rcfilters/dm/FilterGroup.js - About 1 hr to fix

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

            FilterGroup.prototype.getParamRepresentation = function ( filterRepresentation ) {
                var values,
                    areAnySelected = false,
                    buildFromCurrentState = !filterRepresentation,
                    defaultFilters = this.getDefaultFilters(),
            Severity: Minor
            Found in resources/src/mediawiki.rcfilters/dm/FilterGroup.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 getFilterRepresentation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            FilterGroup.prototype.getFilterRepresentation = function ( paramRepresentation ) {
                var areAnySelected, paramValues, item, currentValue,
                    oneWasSelected = false,
                    defaultParams = this.getDefaultParams(),
                    expandedParams = $.extend( true, {}, paramRepresentation ),
            Severity: Minor
            Found in resources/src/mediawiki.rcfilters/dm/FilterGroup.js - About 45 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 onFilterItemUpdate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            FilterGroup.prototype.onFilterItemUpdate = function ( item ) {
                // Update state
                var changed = false,
                    active = this.areAnySelected(),
                    model = this;
            Severity: Minor
            Found in resources/src/mediawiki.rcfilters/dm/FilterGroup.js - About 35 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

            FilterGroup.prototype.areAnySelectedInConflictWith = function ( filterItem ) {
                var selectedItems = this.findSelectedItems( filterItem );
            
                return selectedItems.length > 0 && (
                    // The group as a whole is in conflict with this item
            Severity: Major
            Found in resources/src/mediawiki.rcfilters/dm/FilterGroup.js and 1 other location - About 3 hrs to fix
            resources/src/mediawiki.rcfilters/dm/FilterGroup.js on lines 502..514

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

            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

            FilterGroup.prototype.areAllSelectedInConflictWith = function ( filterItem ) {
                var selectedItems = this.findSelectedItems( filterItem );
            
                return selectedItems.length > 0 &&
                    (
            Severity: Major
            Found in resources/src/mediawiki.rcfilters/dm/FilterGroup.js and 1 other location - About 3 hrs to fix
            resources/src/mediawiki.rcfilters/dm/FilterGroup.js on lines 522..533

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

            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

            FilterGroup.prototype.toggleVisible = function ( isVisible ) {
                isVisible = isVisible === undefined ? !this.visible : isVisible;
            
                if ( this.visible !== isVisible ) {
                    this.visible = isVisible;
            Severity: Major
            Found in resources/src/mediawiki.rcfilters/dm/FilterGroup.js and 3 other locations - About 2 hrs to fix
            resources/src/mediawiki.rcfilters/dm/FilterItem.js on lines 344..351
            resources/src/mediawiki.rcfilters/dm/FilterItem.js on lines 360..367
            resources/src/mediawiki.rcfilters/dm/FilterItem.js on lines 375..382

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

            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

            FilterGroup.prototype.getItemByName = function ( filterName ) {
                return this.getItems().filter( function ( item ) {
                    return item.getName() === filterName;
                } )[ 0 ];
            };
            Severity: Major
            Found in resources/src/mediawiki.rcfilters/dm/FilterGroup.js and 1 other location - About 1 hr to fix
            resources/src/mediawiki.rcfilters/dm/SavedQueriesModel.js on lines 320..324

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

            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

            FilterGroup.prototype.getMaxValue = function () {
                return this.numericRange && this.numericRange.max !== undefined ?
                    this.numericRange.max : null;
            };
            Severity: Major
            Found in resources/src/mediawiki.rcfilters/dm/FilterGroup.js and 1 other location - About 1 hr to fix
            resources/src/mediawiki.rcfilters/dm/FilterGroup.js on lines 339..342

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

            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

            FilterGroup.prototype.getMinValue = function () {
                return this.numericRange && this.numericRange.min !== undefined ?
                    this.numericRange.min : null;
            };
            Severity: Major
            Found in resources/src/mediawiki.rcfilters/dm/FilterGroup.js and 1 other location - About 1 hr to fix
            resources/src/mediawiki.rcfilters/dm/FilterGroup.js on lines 329..332

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

            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

            FilterGroup.prototype.existsInConflicts = function ( filterItem ) {
                return Object.prototype.hasOwnProperty.call( this.getConflicts(), filterItem.getName() );
            };
            Severity: Major
            Found in resources/src/mediawiki.rcfilters/dm/FilterGroup.js and 1 other location - About 1 hr to fix
            resources/src/mediawiki.rcfilters/dm/FilterItem.js on lines 333..335

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

            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

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

            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

            There are no issues that match your filters.

            Category
            Status