Showing 20 of 75 total issues
File Modal.spec.js
has 734 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint-env mocha */
import should from "should";
import React, { Component } from "react";
import ReactDOM from "react-dom";
import Modal from "react-modal";
File ModalPortal.js
has 347 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { Component } from "react";
import PropTypes from "prop-types";
import * as focusManager from "../helpers/focusManager";
import scopeTab from "../helpers/scopeTab";
import * as ariaAppHider from "../helpers/ariaAppHider";
ModalPortal
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
export default class ModalPortal extends Component {
static defaultProps = {
style: {
overlay: {},
content: {}
File Modal.events.spec.js
has 282 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint-env mocha */
import React from "react";
import ReactDOM from "react-dom";
import "should";
import sinon from "sinon";
Function scopeTab
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
export default function scopeTab(node, event) {
const tabbable = findTabbable(node);
if (!tabbable.length) {
// Do nothing, since there are no elements that can receive focus.
- 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 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { isOpen } = this.state;
return (
<div>
Function scopeTab
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function scopeTab(node, event) {
const tabbable = findTabbable(node);
if (!tabbable.length) {
// Do nothing, since there are no elements that can receive focus.
Function render
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const {
id,
className,
overlayClassName,
Function render
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { listItemsIsOpen } = this.state;
return (
<div>
<button type="button" className="btn btn-primary" onClick={this.toggleModal}>Open Modal A</button>
Function bodyTrap
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function bodyTrap(eventType, openInstances) {
if (!before && !after) {
before = document.createElement("div");
before.setAttribute("data-react-modal-body-trap", "");
before.style.position = "absolute";
- 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 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
return (
<div>
<button type="button" className="btn btn-primary" onClick={this.openModal}>Open Modal</button>
<Modal
Function render
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const { currentModal } = this.state;
return (
<div>
Function render
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
return (
<div>
<button type="button" className="btn btn-primary" onClick={this.openModal}>Open Modal</button>
<Modal
Function bodyTrap
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function bodyTrap(eventType, openInstances) {
if (!before && !after) {
before = document.createElement("div");
before.setAttribute("data-react-modal-body-trap", "");
before.style.position = "absolute";
Function componentDidUpdate
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
componentDidUpdate(prevProps, prevState) {
if (process.env.NODE_ENV !== "production") {
if (prevProps.bodyOpenClassName !== this.props.bodyOpenClassName) {
// eslint-disable-next-line no-console
console.warn(
Function componentDidUpdate
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
componentDidUpdate(prevProps, prevState) {
if (process.env.NODE_ENV !== "production") {
if (prevProps.bodyOpenClassName !== this.props.bodyOpenClassName) {
// eslint-disable-next-line no-console
console.warn(
- 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 componentWillUnmount
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
componentWillUnmount() {
if (!canUseDOM || !this.node || !this.portal) return;
const state = this.portal.state;
const now = Date.now();
- 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 visible
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function visible(element) {
let parentElement = element;
let rootNode = element.getRootNode && element.getRootNode();
while (parentElement) {
if (parentElement === document.body) break;
- 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 log_in_between_versions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def log_in_between_versions(t):
(a, b, logs) = t
v = b and to_version(b) or head_version
dt = get_tags_date(v)
- 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
Avoid too many return
statements within this function. Open
return;