huridocs/uwazi

View on GitHub
app/react/Library/components/SearchButton.js

Summary

Maintainability
A
25 mins
Test Coverage
B
85%

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

  render() {
    let toggle = this.props.open ? this.props.hideFilters : this.props.showFilters;
    let activeClass = this.props.open ? ' is-active' : '';

    if (this.props.open && this.props.metadataPanelIsOpen) {
Severity: Minor
Found in app/react/Library/components/SearchButton.js - 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

Export statements should appear at the end of the file
Open

export class SearchButton extends Component {

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

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

  metadataPanelIsOpen: PropTypes.bool,

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/

Export statements should appear at the end of the file
Open

export function mapStateToProps(state, props) {

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

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

  showFilters: PropTypes.func,

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

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

  unselectAllDocuments: PropTypes.func,

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

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

  open: PropTypes.bool,

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

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

  hideFilters: PropTypes.func,

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

Prefer named exports.
Open

export default connect(mapStateToProps, mapDispatchToProps)(SearchButton);

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

Anchor used as a button. Anchors are primarily expected to navigate. Use the button element instead. Learn more: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/HEAD/docs/rules/anchor-is-valid.md
Open

      <a href="#" className={`search-button btn ${activeClass}`} onClick={toggle}>

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

There are no issues that match your filters.

Category
Status