huridocs/uwazi

View on GitHub
app/react/Attachments/components/Attachment.js

Summary

Maintainability
A
35 mins
Test Coverage
D
69%

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

                    >

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

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

  render() {
    const { file, model, storeKey, entity } = this.props;
    const sizeString = file.size ? filesize(file.size) : '';
    const item = getItemOptions(file.filename, file.url);
    let name = (
Severity: Minor
Found in app/react/Attachments/components/Attachment.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

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

  model: PropTypes.string,

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

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

  deleteAttachment: PropTypes.func,

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

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

  renameAttachment: PropTypes.func,

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

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

  parentSharedId: PropTypes.string,

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

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

  readOnly: PropTypes.bool,

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

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

  beingEdited: PropTypes.bool,

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

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

  submitForm: PropTypes.func,

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

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

  resetForm: PropTypes.func,

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/

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

  loadForm: PropTypes.func,

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

Prop type "object" is forbidden
Open

  entity: PropTypes.object,

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

Prop type "object" is forbidden
Open

  file: PropTypes.object,

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

Prefer named exports.
Open

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

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

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

  file: PropTypes.object,

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

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

  storeKey: PropTypes.string,

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

There are no issues that match your filters.

Category
Status