Showing 67 of 71 total issues
File index.js
has 323 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*!
* React Dropdown Tree Select
* A lightweight, fast and highly customizable tree select component.
* Hrusikesh Panda <hrusikesh.panda@dowjones.com>
* Copyright (c) 2017 Dow Jones, Inc. <support@dowjones.com> (http://dowjones.com)
Function render
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { disabled, readOnly, mode, texts, inlineSearchInput, tabIndex } = this.props
const { showDropdown, currentFocus, tags } = this.state
const activeDescendant = currentFocus ? `${currentFocus}_li` : undefined
Function setNodeCheckedState
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
setNodeCheckedState(id, checked) {
// radioSelect must be done before setting node checked, to avoid conflicts with partialCheckParents
// this only occurs when selecting the parent of a previously selected child when the parent also has a parent
if (this.radioSelect) this.togglePreviousChecked(id, checked)
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
const {
keepTreeOnSearch,
keepChildrenOnSearch,
_children,
matchInChildren,
- Read upRead up
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 73.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
static propTypes = {
title: PropTypes.string,
text: PropTypes.string,
className: PropTypes.string,
actionData: PropTypes.object,
- Read upRead up
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 60.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
static propTypes = {
tags: PropTypes.array,
onTagRemove: PropTypes.func,
readOnly: PropTypes.bool,
disabled: PropTypes.bool,
- Read upRead up
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 60.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function render
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
render() {
const { mode, title, label, id, partial, checked } = this.props
const { value, disabled, showPartiallySelected, readOnly, clientId } = this.props
const nodeLabelProps = { className: 'node-label' }
- 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 render
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
render() {
const { id, label, labelRemove = 'Remove', readOnly, disabled } = this.props
const tagId = getTagId(id)
const buttonId = `${id}_button`
- 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 findIndex
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function findIndex(arr, predicate, thisArg) {
// if native support is available, ship it off
if (Array.prototype.findIndex) {
return arr.findIndex(predicate, thisArg)
}
- 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
Replace e
with (e)
Open
handleClick = e => {
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace t
with (t)
Open
tags.forEach(t => {
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace el
with (el)
Open
inputRef={el => {
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace n
with (n)
Open
let focusIndex = findIndex(this.allVisibleNodes, n => n.key === currentId) + 1
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace e
with (e)
Open
onToggle = e => {
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace e
with (e)
Open
onKeyUp = e => {
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace (m
with ((m)
Open
matches.forEach(m => {
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace node
with (node)
Open
this.tree.forEach(node => {
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace nextProps
with (nextProps)
Open
UNSAFE_componentWillReceiveProps = nextProps => {
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace c
with (c)
Open
node._children.forEach(c => markSubTreeVisited(getItemById(c), visited, getItemById))
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/
Replace e
with (e)
Open
handleTrigger = e => {
- Read upRead up
- Exclude checks
For more information visit Source: http://eslint.org/docs/rules/