appbaseio/reactivesearch

View on GitHub
packages/web/src/components/range/DynamicRangeSlider.js

Summary

Maintainability
F
6 days
Test Coverage

File DynamicRangeSlider.js has 498 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, { Component } from 'react';
import {
    addComponent,
    removeComponent,
    watchComponent,
Severity: Minor
Found in packages/web/src/components/range/DynamicRangeSlider.js - About 7 hrs to fix

    DynamicRangeSlider has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class DynamicRangeSlider extends Component {
        constructor(props) {
            super(props);
    
            this.state = {
    Severity: Minor
    Found in packages/web/src/components/range/DynamicRangeSlider.js - About 2 hrs to fix

      Function componentWillReceiveProps has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          componentWillReceiveProps(nextProps) {
              if (!isEqual(this.props.range, nextProps.range) && nextProps.range) {
                  this.updateQueryOptions(nextProps, nextProps.range);
                  // floor and ceil to take edge cases into account
                  this.updateRange({
      Severity: Major
      Found in packages/web/src/components/range/DynamicRangeSlider.js - About 2 hrs to fix

        Function render has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            render() {
                if (!this.state.currentValue || !this.state.range) {
                    return null;
                }
        
        
        Severity: Minor
        Found in packages/web/src/components/range/DynamicRangeSlider.js - About 1 hr to fix

          Function mapStateToProps has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const mapStateToProps = (state, props) => {
              let options
                  = state.aggregations[props.componentId]
                  && state.aggregations[props.componentId][props.dataField];
              let range = state.aggregations[`${props.componentId}__range__internal`];
          Severity: Minor
          Found in packages/web/src/components/range/DynamicRangeSlider.js - About 1 hr to fix

            Function mapStateToProps has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            const mapStateToProps = (state, props) => {
                let options
                    = state.aggregations[props.componentId]
                    && state.aggregations[props.componentId][props.dataField];
                let range = state.aggregations[`${props.componentId}__range__internal`];
            Severity: Minor
            Found in packages/web/src/components/range/DynamicRangeSlider.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 componentWillReceiveProps has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                componentWillReceiveProps(nextProps) {
                    if (!isEqual(this.props.range, nextProps.range) && nextProps.range) {
                        this.updateQueryOptions(nextProps, nextProps.range);
                        // floor and ceil to take edge cases into account
                        this.updateRange({
            Severity: Minor
            Found in packages/web/src/components/range/DynamicRangeSlider.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

            Consider simplifying this complex logical expression.
            Open

                if (props.nestedField) {
                    options
                        = options
                        && state.aggregations[props.componentId][props.dataField][props.nestedField]
                        && state.aggregations[props.componentId][props.dataField][props.nestedField].buckets
            Severity: Major
            Found in packages/web/src/components/range/DynamicRangeSlider.js - About 40 mins to fix

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

                              <Rheostat
                                  min={this.state.range.start}
                                  max={this.state.range.end}
                                  values={this.state.currentValue}
                                  onChange={this.handleSlider}
              Severity: Major
              Found in packages/web/src/components/range/DynamicRangeSlider.js and 1 other location - About 1 day to fix
              packages/web/src/components/range/RangeSlider.js on lines 302..320

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

              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

                  updateQuery = (value, props) => {
                      const query = props.customQuery || DynamicRangeSlider.defaultQuery;
                      const {
                          showFilter,
                          range: { start, end },
              Severity: Major
              Found in packages/web/src/components/range/DynamicRangeSlider.js and 1 other location - About 6 hrs to fix
              packages/web/src/components/range/RangeSlider.js on lines 248..266

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

              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

                  static defaultQuery = (value, props) => {
                      let query = null;
                      if (Array.isArray(value) && value.length) {
                          query = {
                              range: {
              Severity: Major
              Found in packages/web/src/components/range/DynamicRangeSlider.js and 1 other location - About 5 hrs to fix
              packages/web/src/components/range/RangeSlider.js on lines 130..155

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

              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

              const mapDispatchtoProps = dispatch => ({
                  addComponent: component => dispatch(addComponent(component)),
                  removeComponent: component => dispatch(removeComponent(component)),
                  setQueryOptions: (component, props, execute) =>
                      dispatch(setQueryOptions(component, props, execute)),
              Severity: Major
              Found in packages/web/src/components/range/DynamicRangeSlider.js and 2 other locations - About 4 hrs to fix
              packages/web/src/components/basic/ReactiveComponent.js on lines 181..190
              packages/web/src/components/range/RangeSlider.js on lines 408..417

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

              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

                  handleDrag = (values) => {
                      if (this.props.onDrag) {
                          const { min, max, values: currentValue } = values;
                          this.props.onDrag(currentValue, [min, max]);
                      }
              Severity: Major
              Found in packages/web/src/components/range/DynamicRangeSlider.js and 1 other location - About 1 hr to fix
              packages/web/src/components/range/RangeSlider.js on lines 241..246

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

              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 23 locations. Consider refactoring.
              Open

                              {this.props.title && (
                                  <Title className={getClassName(this.props.innerClass, 'title') || null}>
                                      {this.props.title}
                                  </Title>
                              )}
              Severity: Major
              Found in packages/web/src/components/range/DynamicRangeSlider.js and 22 other locations - About 1 hr to fix
              packages/maps/src/components/basic/GeoDistanceDropdown.js on lines 447..451
              packages/maps/src/components/basic/GeoDistanceSlider.js on lines 455..459
              packages/web/src/components/basic/NumberBox.js on lines 170..174
              packages/web/src/components/basic/TagCloud.js on lines 247..251
              packages/web/src/components/basic/TextField.js on lines 175..179
              packages/web/src/components/basic/ToggleButton.js on lines 191..195
              packages/web/src/components/date/DatePicker.js on lines 173..177
              packages/web/src/components/date/DateRange.js on lines 305..309
              packages/web/src/components/list/MultiDataList.js on lines 341..345
              packages/web/src/components/list/MultiDropdownList.js on lines 346..350
              packages/web/src/components/list/MultiList.js on lines 384..388
              packages/web/src/components/list/SingleDataList.js on lines 259..263
              packages/web/src/components/list/SingleDropdownList.js on lines 252..256
              packages/web/src/components/list/SingleList.js on lines 291..295
              packages/web/src/components/range/MultiDropdownRange.js on lines 187..191
              packages/web/src/components/range/MultiRange.js on lines 194..198
              packages/web/src/components/range/RangeSlider.js on lines 289..293
              packages/web/src/components/range/RatingsFilter.js on lines 155..159
              packages/web/src/components/range/SingleDropdownRange.js on lines 148..152
              packages/web/src/components/range/SingleRange.js on lines 148..152
              packages/web/src/components/search/CategorySearch.js on lines 568..572
              packages/web/src/components/search/DataSearch.js on lines 482..486

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

              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

                          } else if (nextProps.defaultSelected) {
                              const { start, end } = nextProps.defaultSelected(
                                  nextProps.range.start,
                                  nextProps.range.end,
                              );
              Severity: Major
              Found in packages/web/src/components/range/DynamicRangeSlider.js and 1 other location - About 1 hr to fix
              packages/web/src/components/range/DynamicRangeSlider.js on lines 80..97

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

              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

                      } else if (
                          nextProps.range
                          && !isEqual(
                              this.props.defaultSelected
                                  && this.props.defaultSelected(nextProps.range.start, nextProps.range.end),
              Severity: Major
              Found in packages/web/src/components/range/DynamicRangeSlider.js and 1 other location - About 1 hr to fix
              packages/web/src/components/range/DynamicRangeSlider.js on lines 68..79

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

              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

                                  <RangeLabel
                                      align="right"
                                      className={getClassName(this.props.innerClass, 'label') || null}
                                  >
                                      {endLabel}
              Severity: Minor
              Found in packages/web/src/components/range/DynamicRangeSlider.js and 1 other location - About 30 mins to fix
              packages/web/src/components/range/DynamicRangeSlider.js on lines 430..435

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

              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

                                  <RangeLabel
                                      align="left"
                                      className={getClassName(this.props.innerClass, 'label') || null}
                                  >
                                      {startLabel}
              Severity: Minor
              Found in packages/web/src/components/range/DynamicRangeSlider.js and 1 other location - About 30 mins to fix
              packages/web/src/components/range/DynamicRangeSlider.js on lines 436..441

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

              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