appbaseio/reactivesearch

View on GitHub
packages/native/src/components/search/DataSearch.js

Summary

Maintainability
F
1 wk
Test Coverage

File DataSearch.js has 613 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React, { Component } from 'react';
import { Platform, View, Modal, TouchableWithoutFeedback } from 'react-native';
import { Input, Item, List, ListItem, Text, Button, Header, Left, Right, Icon } from 'native-base';

import {
Severity: Major
Found in packages/native/src/components/search/DataSearch.js - About 1 day to fix

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

        render() {
            let style = {};
    
            if (this.props.showIcon) {
                if (this.props.iconPosition === 'left') {
    Severity: Major
    Found in packages/native/src/components/search/DataSearch.js - About 3 hrs to fix

      Function render has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          render() {
              let style = {};
      
              if (this.props.showIcon) {
                  if (this.props.iconPosition === 'left') {
      Severity: Minor
      Found in packages/native/src/components/search/DataSearch.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 componentWillReceiveProps has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          componentWillReceiveProps(nextProps) {
              checkSomePropChange(
                  this.props,
                  nextProps,
                  ['highlight', 'dataField', 'highlightField'],
      Severity: Minor
      Found in packages/native/src/components/search/DataSearch.js - About 1 hr to fix

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

            renderSuggestions() {
                let suggestionsList = [];
        
                if (
                    !this.state.currentValue
        Severity: Minor
        Found in packages/native/src/components/search/DataSearch.js - About 1 hr to fix

          Function componentWillReceiveProps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              componentWillReceiveProps(nextProps) {
                  checkSomePropChange(
                      this.props,
                      nextProps,
                      ['highlight', 'dataField', 'highlightField'],
          Severity: Minor
          Found in packages/native/src/components/search/DataSearch.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

                              <Item
                                  regular
                                  style={{ marginLeft: 0 }}
                                  {...getInnerKey(this.props.innerProps, 'item')}
                              >
          Severity: Major
          Found in packages/native/src/components/search/DataSearch.js and 1 other location - About 3 days to fix
          packages/native/src/components/basic/TextField.js on lines 132..195

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

          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

              shouldQuery = (value, dataFields, props) => {
                  const fields = dataFields.map(
                      (field, index) =>
                          `${field}${
                              Array.isArray(props.fieldWeights) && props.fieldWeights[index]
          Severity: Major
          Found in packages/native/src/components/search/DataSearch.js and 2 other locations - About 1 day to fix
          packages/web/src/components/search/CategorySearch.js on lines 230..280
          packages/web/src/components/search/DataSearch.js on lines 196..244

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

          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)),
              watchComponent: (component, react) => dispatch(watchComponent(component, react)),
              updateQuery: updateQueryObject => dispatch(updateQuery(updateQueryObject)),
          Severity: Major
          Found in packages/native/src/components/search/DataSearch.js and 2 other locations - About 4 hrs to fix
          packages/native/src/components/list/MultiDropdownList.js on lines 413..421
          packages/native/src/components/list/SingleDropdownList.js on lines 266..274

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

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

                  if (Array.isArray(nextProps.suggestions) && this.state.currentValue.trim().length) {
                      // shallow check allows us to set suggestions even if the next set
                      // of suggestions are same as the current one
                      if (this.props.suggestions !== nextProps.suggestions) {
                          this.setState({
          Severity: Major
          Found in packages/native/src/components/search/DataSearch.js and 2 other locations - About 3 hrs to fix
          packages/web/src/components/search/CategorySearch.js on lines 96..104
          packages/web/src/components/search/DataSearch.js on lines 83..91

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

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

              setReact = (props) => {
                  const { react } = props;
                  if (react) {
                      const newReact = pushToAndClause(react, this.internalComponent);
                      props.watchComponent(props.componentId, newReact);
          Severity: Major
          Found in packages/native/src/components/search/DataSearch.js and 14 other locations - About 2 hrs to fix
          packages/maps-native/src/components/maps/ReactiveMap.js on lines 215..223
          packages/maps/src/components/result/ReactiveMap.js on lines 350..358
          packages/native/src/components/list/MultiDropdownList.js on lines 99..107
          packages/native/src/components/list/SingleDropdownList.js on lines 83..91
          packages/native/src/components/range/RangeSlider.js on lines 110..118
          packages/native/src/components/result/ReactiveList.js on lines 241..249
          packages/web/src/components/basic/TagCloud.js on lines 97..107
          packages/web/src/components/list/MultiDropdownList.js on lines 123..133
          packages/web/src/components/list/MultiList.js on lines 117..127
          packages/web/src/components/list/SingleDropdownList.js on lines 112..122
          packages/web/src/components/list/SingleList.js on lines 108..118
          packages/web/src/components/range/RangeSlider.js on lines 115..125
          packages/web/src/components/search/CategorySearch.js on lines 144..154
          packages/web/src/components/search/DataSearch.js on lines 121..131

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

          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

                  if (
                      !this.state.currentValue
                      && this.props.defaultSuggestions
                      && this.props.defaultSuggestions.length
                  ) {
          Severity: Major
          Found in packages/native/src/components/search/DataSearch.js and 2 other locations - About 2 hrs to fix
          packages/web/src/components/search/CategorySearch.js on lines 525..533
          packages/web/src/components/search/DataSearch.js on lines 469..477

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

              handleTextChange = debounce((value) => {
                  if (this.props.autosuggest) {
                      this.updateQuery(this.internalComponent, value, this.props);
                  } else {
                      this.updateQuery(this.props.componentId, value, this.props);
          Severity: Major
          Found in packages/native/src/components/search/DataSearch.js and 2 other locations - About 2 hrs to fix
          packages/web/src/components/search/CategorySearch.js on lines 338..344
          packages/web/src/components/search/DataSearch.js on lines 302..308

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

          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 (this.props.defaultSelected !== nextProps.defaultSelected) {
                      this.setValue(nextProps.defaultSelected, true, nextProps);
                  } else if (this.props.selectedValue !== nextProps.selectedValue) {
                      this.setValue(nextProps.selectedValue || '', true, nextProps);
                  }
          Severity: Major
          Found in packages/native/src/components/search/DataSearch.js and 1 other location - About 2 hrs to fix
          packages/native/src/components/basic/TextField.js on lines 46..50

          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

                          {this.props.showIcon && this.props.iconPosition === 'left' ? (
                              <Icon
                                  name="search"
                                  style={{
                                      fontSize: 22,
          Severity: Major
          Found in packages/native/src/components/search/DataSearch.js and 1 other location - About 2 hrs to fix
          packages/native/src/components/search/DataSearch.js on lines 403..412

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

          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

                                  {this.props.showIcon && this.props.iconPosition === 'left' ? (
                                      <Icon
                                          name="search"
                                          style={{
                                              fontSize: 22,
          Severity: Major
          Found in packages/native/src/components/search/DataSearch.js and 1 other location - About 2 hrs to fix
          packages/native/src/components/search/DataSearch.js on lines 447..456

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

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

                          <Modal
                              supportedOrientations={this.props.supportedOrientations || null}
                              transparent={false}
                              visible={this.state.showModal}
                              onRequestClose={this.toggleModal}
          Severity: Major
          Found in packages/native/src/components/search/DataSearch.js and 4 other locations - About 1 hr to fix
          packages/native/src/components/date/DatePicker.js on lines 207..298
          packages/native/src/components/date/DateRange.js on lines 368..459
          packages/native/src/components/list/MultiDropdownList.js on lines 263..325
          packages/native/src/components/range/MultiDropdownRange.js on lines 181..252

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

          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 (this.props.showIcon) {
                      if (this.props.iconPosition === 'left') {
                          style = {
                              paddingLeft: 0,
                          };
          Severity: Major
          Found in packages/native/src/components/search/DataSearch.js and 1 other location - About 1 hr to fix
          packages/native/src/components/basic/TextField.js on lines 119..129

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

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

              componentWillUnmount() {
                  this.props.removeComponent(this.props.componentId);
                  this.props.removeComponent(this.internalComponent);
              }
          Severity: Major
          Found in packages/native/src/components/search/DataSearch.js and 15 other locations - About 45 mins to fix
          packages/maps-native/src/components/maps/ReactiveMap.js on lines 210..213
          packages/maps/src/components/result/ReactiveMap.js on lines 345..348
          packages/native/src/components/list/MultiDropdownList.js on lines 94..97
          packages/native/src/components/list/SingleDropdownList.js on lines 78..81
          packages/native/src/components/range/RangeSlider.js on lines 105..108
          packages/web/src/components/basic/TagCloud.js on lines 92..95
          packages/web/src/components/list/MultiDataList.js on lines 100..103
          packages/web/src/components/list/MultiDropdownList.js on lines 118..121
          packages/web/src/components/list/MultiList.js on lines 112..115
          packages/web/src/components/list/SingleDataList.js on lines 88..91
          packages/web/src/components/list/SingleDropdownList.js on lines 107..110
          packages/web/src/components/list/SingleList.js on lines 103..106
          packages/web/src/components/range/RangeSlider.js on lines 110..113
          packages/web/src/components/search/CategorySearch.js on lines 129..132
          packages/web/src/components/search/DataSearch.js on lines 116..119

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

          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