huridocs/uwazi

View on GitHub
app/react/Forms/components/MultiDateRange.js

Summary

Maintainability
A
1 hr
Test Coverage
B
80%

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

  fromChange(index, value) {
    const values = this.state.values.slice();
    values[index] = { ...values[index] };
    values[index].from = value;
    this.setState({ values });
Severity: Minor
Found in app/react/Forms/components/MultiDateRange.js and 1 other location - About 55 mins to fix
app/react/Forms/components/MultiDateRange.js on lines 23..29

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

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

  toChange(index, value) {
    const values = this.state.values.slice();
    values[index] = { ...values[index] };
    values[index].to = value;
    this.setState({ values });
Severity: Minor
Found in app/react/Forms/components/MultiDateRange.js and 1 other location - About 55 mins to fix
app/react/Forms/components/MultiDateRange.js on lines 15..21

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

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

Use callback in setState when referencing the previous state.
Open

    const values = this.state.values.slice();

For more information visit Source: http://eslint.org/docs/rules/

JSX props should not use .bind()
Open

                    onChange={this.toChange.bind(this, index)}

For more information visit Source: http://eslint.org/docs/rules/

Empty components are self-closing
Open

                <div className="multidate-range-clear-float"></div>

For more information visit Source: http://eslint.org/docs/rules/

propType "value" is not required, but has no corresponding defaultProps declaration.
Open

  value: PropTypes.array,

For more information visit Source: http://eslint.org/docs/rules/

Missing an explicit type attribute for button
Open

        <button className="btn btn-success add" onClick={this.add.bind(this)}>

For more information visit Source: http://eslint.org/docs/rules/

JSX props should not use .bind()
Open

                    onChange={this.fromChange.bind(this, index)}

For more information visit Source: http://eslint.org/docs/rules/

Missing an explicit type attribute for button
Open

                <button

For more information visit Source: http://eslint.org/docs/rules/

Prop type "array" is forbidden
Open

  value: PropTypes.array,

For more information visit Source: http://eslint.org/docs/rules/

Use callback in setState when referencing the previous state.
Open

    const values = this.state.values.slice();

For more information visit Source: http://eslint.org/docs/rules/

Use callback in setState when referencing the previous state.
Open

    const values = this.state.values.slice();

For more information visit Source: http://eslint.org/docs/rules/

Use callback in setState when referencing the previous state.
Open

    const values = this.state.values.slice();

For more information visit Source: http://eslint.org/docs/rules/

Prefer named exports.
Open

export default MultiDateRange;

For more information visit Source: http://eslint.org/docs/rules/

propType "onChange" is not required, but has no corresponding defaultProps declaration.
Open

  onChange: PropTypes.func,

For more information visit Source: http://eslint.org/docs/rules/

A control must be associated with a text label.
Open

                <button

For more information visit Source: http://eslint.org/docs/rules/

propType "format" is not required, but has no corresponding defaultProps declaration.
Open

  format: PropTypes.string,

For more information visit Source: http://eslint.org/docs/rules/

Definition for rule 'node/no-restricted-import' was not found.
Open

import PropTypes from 'prop-types';

For more information visit Source: http://eslint.org/docs/rules/

Do not use Array index in keys
Open

            <div key={index} className="multidate-item">

For more information visit Source: http://eslint.org/docs/rules/

There are no issues that match your filters.

Category
Status