appbaseio/reactivesearch

View on GitHub
packages/vue/src/components/list/SingleDropdownList.jsx

Summary

Maintainability
F
5 days
Test Coverage

File SingleDropdownList.jsx has 326 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Actions, helper } from '@appbaseio/reactivecore';
import VueTypes from 'vue-types';
import types from '../../utils/vueTypes';
import { getAggsQuery, getCompositeAggsQuery } from './utils';
import Title from '../../styles/Title';
Severity: Minor
Found in packages/vue/src/components/list/SingleDropdownList.jsx - About 3 hrs to fix

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

        render() {
            const { showLoadMore, loadMoreLabel, renderListItem } = this.$props;
            const { isLastBucket } = this.$data;
            let selectAll = [];
            const renderListItemCalc
    Severity: Major
    Found in packages/vue/src/components/list/SingleDropdownList.jsx - About 2 hrs to fix

      Function defaultQuery has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      SingleDropdownList.defaultQuery = (value, props) => {
          let query = null;
          if (props.selectAllLabel && props.selectAllLabel === value) {
              if (props.showMissing) {
                  query = { match_all: {} };
      Severity: Minor
      Found in packages/vue/src/components/list/SingleDropdownList.jsx - About 1 hr to fix

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

        SingleDropdownList.defaultQuery = (value, props) => {
            let query = null;
            if (props.selectAllLabel && props.selectAllLabel === value) {
                if (props.showMissing) {
                    query = { match_all: {} };
        Severity: Minor
        Found in packages/vue/src/components/list/SingleDropdownList.jsx - 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

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

            render() {
                const { showLoadMore, loadMoreLabel, renderListItem } = this.$props;
                const { isLastBucket } = this.$data;
                let selectAll = [];
                const renderListItemCalc
        Severity: Minor
        Found in packages/vue/src/components/list/SingleDropdownList.jsx - About 25 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 options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                options(newVal, oldVal) {
                    checkPropChange(oldVal, newVal, () => {
                        const { showLoadMore, dataField } = this.$props;
                        const { modifiedOptions } = this.$data;
                        if (showLoadMore) {
        Severity: Minor
        Found in packages/vue/src/components/list/SingleDropdownList.jsx - About 25 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

                options(newVal, oldVal) {
                    checkPropChange(oldVal, newVal, () => {
                        const { showLoadMore, dataField } = this.$props;
                        const { modifiedOptions } = this.$data;
                        if (showLoadMore) {
        Severity: Major
        Found in packages/vue/src/components/list/SingleDropdownList.jsx and 1 other location - About 1 day to fix
        packages/vue/src/components/list/MultiDropdownList.jsx on lines 115..142

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

        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

            beforeMount() {
                this.addComponent(this.internalComponent);
                this.addComponent(this.$props.componentId);
                this.updateQueryOptions(this.$props);
                this.setReact(this.$props);
        Severity: Major
        Found in packages/vue/src/components/list/SingleDropdownList.jsx and 2 other locations - About 4 hrs to fix
        packages/vue/src/components/list/MultiList.jsx on lines 75..86
        packages/vue/src/components/list/SingleList.jsx on lines 73..84

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

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

                updateQueryHandler(value, props) {
                    const query = props.customQuery || SingleDropdownList.defaultQuery;
                    this.updateQuery({
                        componentId: props.componentId,
                        query: query(value, props),
        Severity: Major
        Found in packages/vue/src/components/list/SingleDropdownList.jsx and 5 other locations - About 3 hrs to fix
        packages/vue/src/components/list/MultiDropdownList.jsx on lines 302..313
        packages/vue/src/components/list/MultiList.jsx on lines 333..344
        packages/vue/src/components/list/SingleList.jsx on lines 280..291
        packages/vue/src/components/range/MultiRange.jsx on lines 91..102
        packages/vue/src/components/range/SingleRange.jsx on lines 145..156

        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

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

                updateQueryOptions(props, addAfterKey = false) {
                    // when using composite aggs flush the current options for a fresh query
                    if (props.showLoadMore && !addAfterKey) {
                        this.modifiedOptions = [];
                    } // for a new query due to other changes don't append after to get fresh results
        Severity: Major
        Found in packages/vue/src/components/list/SingleDropdownList.jsx and 1 other location - About 3 hrs to fix
        packages/vue/src/components/list/MultiDropdownList.jsx on lines 322..333

        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

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

                setReact(props) {
                    const { react } = props;
        
                    if (react) {
                        const newReact = pushToAndClause(react, this.internalComponent);
        Severity: Major
        Found in packages/vue/src/components/list/SingleDropdownList.jsx and 4 other locations - About 2 hrs to fix
        packages/vue/src/components/list/MultiDropdownList.jsx on lines 216..227
        packages/vue/src/components/list/MultiList.jsx on lines 247..258
        packages/vue/src/components/list/SingleList.jsx on lines 239..250
        packages/vue/src/components/result/ReactiveList.jsx on lines 411..422

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 91.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

                            items={[
                                ...selectAll,
                                ...this.$data.modifiedOptions
                                    .filter(item => String(item.key).trim().length)
                                    .map(item => ({
        Severity: Major
        Found in packages/vue/src/components/list/SingleDropdownList.jsx and 4 other locations - About 2 hrs to fix
        packages/native/src/components/list/MultiDropdownList.js on lines 297..302
        packages/vue/src/components/list/MultiDropdownList.jsx on lines 183..191
        packages/web/src/components/list/MultiDropdownList.js on lines 353..358
        packages/web/src/components/list/SingleDropdownList.js on lines 259..264

        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

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

                        {this.$props.title && (
                            <Title class={getClassName(this.$props.innerClass, 'title') || ''}>
                                {this.$props.title}
                            </Title>
                        )}
        Severity: Major
        Found in packages/vue/src/components/list/SingleDropdownList.jsx and 3 other locations - About 1 hr to fix
        packages/vue/src/components/list/MultiDropdownList.jsx on lines 176..180
        packages/vue/src/components/list/SingleList.jsx on lines 133..137
        packages/vue/src/components/search/DataSearch.jsx on lines 398..402

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

                            footer={
                                showLoadMore
                                && !isLastBucket && (
                                    <div css={loadMoreContainer}>
                                        <Button onClick={this.handleLoadMore}>{loadMoreLabel}</Button>
        Severity: Major
        Found in packages/vue/src/components/list/SingleDropdownList.jsx and 3 other locations - About 1 hr to fix
        packages/vue/src/components/list/MultiDropdownList.jsx on lines 202..209
        packages/web/src/components/list/MultiDropdownList.js on lines 369..376
        packages/web/src/components/list/SingleDropdownList.js on lines 274..281

        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

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

            created() {
                const onQueryChange = (...args) => {
                    this.$emit('queryChange', ...args);
                };
                this.setQueryListener(this.$props.componentId, onQueryChange, null);
        Severity: Major
        Found in packages/vue/src/components/list/SingleDropdownList.jsx and 6 other locations - About 1 hr to fix
        packages/vue/src/components/list/MultiDropdownList.jsx on lines 72..77
        packages/vue/src/components/list/MultiList.jsx on lines 69..74
        packages/vue/src/components/list/SingleList.jsx on lines 67..72
        packages/vue/src/components/range/MultiRange.jsx on lines 122..127
        packages/vue/src/components/range/RangeSlider.jsx on lines 125..130
        packages/vue/src/components/range/SingleRange.jsx on lines 38..43

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 58.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

                    const performUpdate = () => {
                        this.currentValue = value;
                        this.updateQueryHandler(value, props);
                        this.locked = false;
                        this.$emit('valueChange', value);
        Severity: Major
        Found in packages/vue/src/components/list/SingleDropdownList.jsx and 3 other locations - About 1 hr to fix
        packages/vue/src/components/list/MultiDropdownList.jsx on lines 287..292
        packages/vue/src/components/list/SingleList.jsx on lines 265..270
        packages/vue/src/components/range/SingleRange.jsx on lines 130..135

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 58.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

        SingleDropdownList.generateQueryOptions = (props, after) => {
            const queryOptions = getQueryOptions(props);
            return props.showLoadMore
                ? getCompositeAggsQuery(queryOptions, props, after)
                : getAggsQuery(queryOptions, props);
        Severity: Minor
        Found in packages/vue/src/components/list/SingleDropdownList.jsx and 1 other location - About 55 mins to fix
        packages/vue/src/components/list/MultiDropdownList.jsx on lines 424..429

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

        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

                dataField() {
                    this.updateQueryOptions(this.$props);
                    this.updateQueryHandler(this.$data.currentValue, this.$props);
                },
        Severity: Major
        Found in packages/vue/src/components/list/SingleDropdownList.jsx and 3 other locations - About 35 mins to fix
        packages/vue/src/components/list/MultiDropdownList.jsx on lines 146..149
        packages/vue/src/components/list/MultiList.jsx on lines 106..109
        packages/vue/src/components/list/SingleList.jsx on lines 105..108

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

        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

                generateQueryOptions(props, after) {
                    const queryOptions = getQueryOptions(props);
                    return props.showLoadMore
                        ? getCompositeAggsQuery(queryOptions, props, after)
                        : getAggsQuery(queryOptions, props);
        Severity: Minor
        Found in packages/vue/src/components/list/SingleDropdownList.jsx and 1 other location - About 30 mins to fix
        packages/vue/src/components/list/MultiDropdownList.jsx on lines 315..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 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