appbaseio/reactivesearch

View on GitHub
packages/native/src/components/date/DatePicker.js

Summary

Maintainability
F
1 wk
Test Coverage

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

    render() {
        let markedDates = {};
        const current = this.state.currentDate
            ? this.state.currentDate.dateString
            : this.props.initialMonth || Date();
Severity: Major
Found in packages/native/src/components/date/DatePicker.js - About 6 hrs to fix

    File DatePicker.js has 322 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React, { Component } from 'react';
    import { View, Modal, TouchableWithoutFeedback, Platform } from 'react-native';
    import { Calendar } from 'react-native-calendars';
    import { Text, Body, Item, Header, Left, Button, Icon, Title, Right } from 'native-base';
    
    
    Severity: Minor
    Found in packages/native/src/components/date/DatePicker.js - About 3 hrs to fix

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

          render() {
              let markedDates = {};
              const current = this.state.currentDate
                  ? this.state.currentDate.dateString
                  : this.props.initialMonth || Date();
      Severity: Minor
      Found in packages/native/src/components/date/DatePicker.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

      Consider simplifying this complex logical expression.
      Open

              if (this.state.currentDate) {
                  markedDates = {
                      [this.state.currentDate.dateString]: {
                          startingDay: true,
                          endingDay: true,
      Severity: Major
      Found in packages/native/src/components/date/DatePicker.js - About 1 hr to fix

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

                            <Header {...getInnerKey(this.props.innerProps, 'header')}>
                                <Left style={getInnerKey(this.props.innerStyle, 'left')}>
                                    <Button
                                        transparent
                                        onPress={this.toggleModal}
        Severity: Major
        Found in packages/native/src/components/date/DatePicker.js and 1 other location - About 2 days to fix
        packages/native/src/components/date/DateRange.js on lines 375..423

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

        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.state.currentDate ? (
                                <Button
                                    onPress={this.toggleModal}
                                    style={{
                                        width: '100%',
        Severity: Major
        Found in packages/native/src/components/date/DatePicker.js and 1 other location - About 6 hrs to fix
        packages/native/src/components/date/DateRange.js on lines 435..458

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

        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

                                <Text
                                    style={{
                                        flex: 1,
                                        alignItems: 'center',
                                        color: this.state.currentDate
        Severity: Major
        Found in packages/native/src/components/date/DatePicker.js and 1 other location - About 4 hrs to fix
        packages/native/src/components/date/DateRange.js on lines 345..365

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

        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 5 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/date/DatePicker.js and 4 other locations - About 3 hrs to fix
        packages/native/src/components/basic/TextField.js on lines 246..253
        packages/native/src/components/date/DateRange.js on lines 501..508
        packages/native/src/components/range/MultiDropdownRange.js on lines 329..336
        packages/native/src/components/range/SingleDropdownRange.js on lines 191..198

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

        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

                            <Calendar
                                current={current}
                                onDayPress={this.handleDateChange}
                                markedDates={markedDates}
                                markingType="period"
        Severity: Major
        Found in packages/native/src/components/date/DatePicker.js and 1 other location - About 2 hrs to fix
        packages/native/src/components/date/DateRange.js on lines 424..434

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

        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/date/DatePicker.js and 4 other locations - About 1 hr to fix
        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
        packages/native/src/components/search/DataSearch.js on lines 337..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 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

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

                } else if (this.props.defaultSelected) {
                    const currentDate = {
                        dateString: new XDate(this.props.defaultSelected).toString('yyyy-MM-dd'),
                        timestamp: new XDate(this.props.defaultSelected).getTime(),
                    };
        Severity: Major
        Found in packages/native/src/components/date/DatePicker.js and 1 other location - About 1 hr to fix
        packages/native/src/components/date/DatePicker.js on lines 43..55

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

        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.selectedValue) {
                    const currentDate = {
                        dateString: new XDate(this.props.selectedValue).toString('yyyy-MM-dd'),
                        timestamp: new XDate(this.props.selectedValue).getTime(),
                    };
        Severity: Major
        Found in packages/native/src/components/date/DatePicker.js and 1 other location - About 1 hr to fix
        packages/native/src/components/date/DatePicker.js on lines 49..55

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

        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 performUpdate = () => {
                    this.setState(
                        {
                            currentDate,
                        },
        Severity: Major
        Found in packages/native/src/components/date/DatePicker.js and 2 other locations - About 1 hr to fix
        packages/native/src/components/list/SingleDropdownList.js on lines 111..121
        packages/native/src/components/range/SingleDropdownRange.js on lines 90..100

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

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

        const mapStateToProps = (state, props) => ({
            selectedValue: state.selectedValues[props.componentId]
                ? state.selectedValues[props.componentId].value
                : null,
        });
        Severity: Major
        Found in packages/native/src/components/date/DatePicker.js and 6 other locations - About 50 mins to fix
        packages/native/src/components/date/DateRange.js on lines 495..499
        packages/native/src/components/range/MultiDropdownRange.js on lines 323..327
        packages/web/src/components/basic/NumberBox.js on lines 238..242
        packages/web/src/components/date/DatePicker.js on lines 258..262
        packages/web/src/components/date/DateRange.js on lines 456..460
        packages/web/src/components/range/MultiRange.js on lines 266..270

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

        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

                        <Item
                            regular
                            style={{ marginLeft: 0, ...this.props.style }}
                            {...getInnerKey(this.props.innerProps, 'item')}
                        >
        Severity: Minor
        Found in packages/native/src/components/date/DatePicker.js and 2 other locations - About 40 mins to fix
        packages/native/src/components/basic/TextField.js on lines 132..195
        packages/native/src/components/date/DateRange.js on lines 339..367

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

        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