reactjs/react-modal

View on GitHub

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";
Severity: Major
Found in specs/Modal.spec.js - About 1 day to fix

    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";
    Severity: Minor
    Found in src/components/ModalPortal.js - About 4 hrs to fix

      ModalPortal has 26 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export default class ModalPortal extends Component {
        static defaultProps = {
          style: {
            overlay: {},
            content: {}
      Severity: Minor
      Found in src/components/ModalPortal.js - About 3 hrs to fix

        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";
        Severity: Minor
        Found in specs/Modal.events.spec.js - About 2 hrs to fix

          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.
          Severity: Minor
          Found in src/helpers/scopeTab.js - About 2 hrs 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

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

            render() {
              const { isOpen } = this.state;
          
              return (
                <div>
          Severity: Minor
          Found in examples/basic/forms/index.js - About 1 hr to fix

            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.
            Severity: Minor
            Found in src/helpers/scopeTab.js - About 1 hr to fix

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

                render() {
                  const {
                    id,
                    className,
                    overlayClassName,
              Severity: Minor
              Found in src/components/ModalPortal.js - About 1 hr to fix

                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>
                Severity: Minor
                Found in examples/basic/multiple_modals/index.js - About 1 hr to fix

                  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";
                  Severity: Minor
                  Found in src/helpers/bodyTrap.js - About 1 hr 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

                  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
                  Severity: Minor
                  Found in examples/wc/app.js - About 1 hr to fix

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

                      render() {
                        const { currentModal } = this.state;
                    
                        return (
                          <div>
                    Severity: Minor
                    Found in examples/basic/simple_usage/index.js - About 1 hr to fix

                      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
                      Severity: Minor
                      Found in examples/bootstrap/app.js - About 1 hr to fix

                        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";
                        Severity: Minor
                        Found in src/helpers/bodyTrap.js - About 1 hr to fix

                          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(
                          Severity: Minor
                          Found in src/components/ModalPortal.js - About 1 hr to fix

                            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(
                            Severity: Minor
                            Found in src/components/ModalPortal.js - About 55 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

                            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();
                            Severity: Minor
                            Found in src/components/Modal.js - About 45 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

                            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;
                            Severity: Minor
                            Found in src/helpers/tabbable.js - About 35 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

                            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)
                            Severity: Minor
                            Found in scripts/changelog.py - About 35 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

                            Avoid too many return statements within this function.
                            Open

                                return;
                            Severity: Major
                            Found in src/helpers/scopeTab.js - About 30 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language