thepracticaldev/dev.to

View on GitHub
app/javascript/shared/components/tags.jsx

Summary

Maintainability
D
1 day
Test Coverage

File tags.jsx has 395 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { h, Component } from 'preact';
import PropTypes from 'prop-types';

const KEYS = {
  UP: 'ArrowUp',
Severity: Minor
Found in app/javascript/shared/components/tags.jsx - About 5 hrs to fix

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

      render() {
        let searchResultsHTML = '';
        const { searchResults, selectedIndex, showingRulesForTag } = this.state;
        const { classPrefix, defaultValue, maxTags, listing } = this.props;
        const searchResultsRows = searchResults.map((tag, index) => (
    Severity: Major
    Found in app/javascript/shared/components/tags.jsx - About 2 hrs to fix

      Tags has 23 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Tags extends Component {
        constructor(props) {
          super(props);
          this.state = {
            selectedIndex: -1,
      Severity: Minor
      Found in app/javascript/shared/components/tags.jsx - About 2 hrs to fix

        Function componentDidMount has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          componentDidMount() {
            const { listing } = this.props;
            if (listing === true) {
              this.setState({
                additionalTags: {
        Severity: Minor
        Found in app/javascript/shared/components/tags.jsx - About 1 hr to fix

          Function search has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            search(query) {
              if (query === '') {
                return new Promise(resolve => {
                  setTimeout(() => {
                    this.resetSearchResults();
          Severity: Minor
          Found in app/javascript/shared/components/tags.jsx - About 1 hr to fix

            There are no issues that match your filters.

            Category
            Status