huridocs/uwazi

View on GitHub
app/react/Metadata/components/SelectMultiplePanel.js

Summary

Maintainability
B
6 hrs
Test Coverage
B
88%

File has too many lines (280). Maximum allowed is 250.
Open

  getAndSelectDocument: PropTypes.func.isRequired,

title: max-lines ruletype: suggestion relatedrules: - complexity - max-depth - max-lines-per-function - max-nested-callbacks - max-params - max-statements further_reading:

- https://web.archive.org/web/20160725154648/http://www.mind2b.com/component/content/article/24-software-module-size-and-file-size

Some people consider large files a code smell. Large files tend to do a lot of things and can make it hard following what's going. While there is not an objective maximum number of lines considered acceptable in a file, most people would agree it should not be in the thousands. Recommendations usually range from 100 to 500 lines.

Rule Details

This rule enforces a maximum number of lines per file, in order to aid in maintainability and reduce complexity.

Please note that most editors show an additional empty line at the end if the file ends with a line break. This rule does not count that extra line.

Options

This rule has a number or object option:

  • "max" (default 300) enforces a maximum number of lines in a file

  • "skipBlankLines": true ignore lines made up purely of whitespace.

  • "skipComments": true ignore lines containing just comments

max

Examples of incorrect code for this rule with a max value of 2:

::: incorrect

/*eslint max-lines: ["error", 2]*/
var a,
    b,
    c;

:::

::: incorrect

/*eslint max-lines: ["error", 2]*/

var a,
    b,c;

:::

::: incorrect

/*eslint max-lines: ["error", 2]*/
// a comment
var a,
    b,c;

:::

Examples of correct code for this rule with a max value of 2:

::: correct

/*eslint max-lines: ["error", 2]*/
var a,
    b, c;

:::

::: correct

/*eslint max-lines: ["error", 2]*/

var a, b, c;

:::

::: correct

/*eslint max-lines: ["error", 2]*/
// a comment
var a, b, c;

:::

skipBlankLines

Examples of incorrect code for this rule with the { "skipBlankLines": true } option:

::: incorrect

/*eslint max-lines: ["error", {"max": 2, "skipBlankLines": true}]*/

var a,
    b,
    c;

:::

Examples of correct code for this rule with the { "skipBlankLines": true } option:

::: correct

/*eslint max-lines: ["error", {"max": 2, "skipBlankLines": true}]*/

var a,
    b, c;

:::

skipComments

Examples of incorrect code for this rule with the { "skipComments": true } option:

::: incorrect

/*eslint max-lines: ["error", {"max": 2, "skipComments": true}]*/
// a comment
var a,
    b,
    c;

:::

Examples of correct code for this rule with the { "skipComments": true } option:

::: correct

/*eslint max-lines: ["error", {"max": 2, "skipComments": true}]*/
// a comment
var a,
    b, c;

:::

When Not To Use It

You can turn this rule off if you are not concerned with the number of lines in your files.

Compatibility

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

  renderEditingForm() {
    const { formKey, thesauris } = this.props;

    return (
      <>
Severity: Major
Found in app/react/Metadata/components/SelectMultiplePanel.js and 1 other location - About 6 hrs to fix
app/react/SemanticSearch/components/SemanticSearchMultieditPanel.js on lines 87..111

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

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

  metadataFieldModified(key) {
    return (
      !this.props.formState.metadata[key].pristine &&
      (!this.props.formState.metadata[key].$form ||
        !this.props.formState.metadata[key].$form.pristine)
Severity: Minor
Found in app/react/Metadata/components/SelectMultiplePanel.js and 1 other location - About 30 mins to fix
app/react/SemanticSearch/components/SemanticSearchMultieditPanel.js on lines 41..47

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

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

Prefer named exports.
Open

export default connect(mapStateToProps, mapDispatchToProps)(withContext(SelectMultiplePanel));

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/

Non-interactive elements should not be assigned mouse or keyboard event listeners.
Open

            <li key={index} onClick={onClick}>

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

Do not use Array index in keys
Open

            <li key={index} onClick={onClick}>

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

There are no issues that match your filters.

Category
Status