Showing 15 of 52 total issues
File reactTags.test.js
has 900 lines of code (exceeds 250 allowed). Consider refactoring. Open
import React from 'react';
import { expect } from 'chai';
import { mount, shallow } from 'enzyme';
import { spy, stub, createSandbox } from 'sinon';
File ReactTags.js
has 540 lines of code (exceeds 250 allowed). Consider refactoring. Open
import React, { Component, createRef } from 'react';
import { DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
import isEqual from 'lodash/isEqual';
import noop from 'lodash/noop';
Function render
has 102 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const tagItems = this.getTagItems();
const classNames = { ...DEFAULT_CLASSNAMES, ...this.props.classNames };
// get the suggestions for the given query
ReactTags
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class ReactTags extends Component {
static propTypes = {
placeholder: PropTypes.string,
labelField: PropTypes.string,
suggestions: PropTypes.arrayOf(
Function handleKeyDown
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
handleKeyDown(e) {
const { query, selectedIndex, suggestions, selectionMode } = this.state;
// hide suggestions menu on escape
if (e.keyCode === KEYS.ESCAPE) {
- Read upRead up
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
Function App
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
const App = () => {
const [tags, setTags] = React.useState([
{ id: 'Thailand', text: 'Thailand' },
{ id: 'India', text: 'India' },
{ id: 'Vietnam', text: 'Vietnam' },
Function Tag
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
const Tag = (props) => {
const tagRef = useRef(null);
const { readOnly, tag, classNames, index } = props;
const [{ isDragging }, drag] = useDrag(() => ({
Function handleKeyDown
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
handleKeyDown(e) {
const { query, selectedIndex, suggestions, selectionMode } = this.state;
// hide suggestions menu on escape
if (e.keyCode === KEYS.ESCAPE) {
Function RemoveComponent
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
const RemoveComponent = (props) => {
const { readOnly, removeComponent, onRemove, className, tag, index } = props;
const onKeydown = (event) => {
if (KEYS.ENTER.includes(event.keyCode) || event.keyCode === KEYS.SPACE) {
Function handleDelete
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
handleDelete(index, event) {
event.preventDefault();
event.stopPropagation();
const currentTags = this.props.tags.slice();
// Early exit from the function if the array
Function GitHubCorner
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
const GitHubCorner = () => {
return (
<>
<a
href="https://github.com/react-tags/react-tags"
Function render
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { props } = this;
const suggestions = props.suggestions.map(
function (item, i) {
Function constructor
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(props) {
super(props);
if (!props.inline) {
/* eslint-disable no-console */
Function RemoveComponent
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const RemoveComponent = (props) => {
const { readOnly, removeComponent, onRemove, className, tag, index } = props;
const onKeydown = (event) => {
if (KEYS.ENTER.includes(event.keyCode) || event.keyCode === KEYS.SPACE) {
- Read upRead up
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
Function handleDelete
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
handleDelete(index, event) {
event.preventDefault();
event.stopPropagation();
const currentTags = this.props.tags.slice();
// Early exit from the function if the array
- Read upRead up
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"