reactjs/react-modal

View on GitHub

Showing 75 of 75 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    overlayClassName: PropTypes.oneOfType([
      PropTypes.string,
      PropTypes.shape({
        base: PropTypes.string.isRequired,
        afterOpen: PropTypes.string.isRequired,
Severity: Major
Found in src/components/Modal.js and 1 other location - About 1 hr to fix
src/components/Modal.js on lines 45..52

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 68.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  it("should trigger onAfterClose callback when unmounting an opened modal", () => {
    const onAfterCloseCallback = sinon.spy();
    withModal({ isOpen: true, onAfterClose: onAfterCloseCallback });
    onAfterCloseCallback.called.should.be.ok();
  });
Severity: Major
Found in specs/Modal.events.spec.js and 1 other location - About 1 hr to fix
specs/Modal.events.spec.js on lines 52..59

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 67.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  it("should trigger the onAfterClose callback", () => {
    const onAfterCloseCallback = sinon.spy();
    withModal({
      isOpen: true,
      onAfterClose: onAfterCloseCallback
Severity: Major
Found in specs/Modal.events.spec.js and 1 other location - About 1 hr to fix
specs/Modal.events.spec.js on lines 67..71

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 67.

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

Further Reading

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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            it("append class to document.body if modal is open.", () => {
              const props = { isOpen: true };
              withModal(props, null, () => {
                isDocumentWithReactModalOpenClass().should.be.ok();
              });
          Severity: Major
          Found in specs/Modal.spec.js and 1 other location - About 1 hr to fix
          specs/Modal.spec.js on lines 436..441

          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

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            it("don't append class to <html /> if not defined.", () => {
              const props = { isOpen: true };
              withModal(props, null, () => {
                htmlClassList().should.be.empty();
              });
          Severity: Major
          Found in specs/Modal.spec.js and 1 other location - About 1 hr to fix
          specs/Modal.spec.js on lines 429..434

          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

          Further Reading

          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

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                appElement: PropTypes.oneOfType([
                  PropTypes.instanceOf(SafeHTMLElement),
                  PropTypes.instanceOf(SafeHTMLCollection),
                  PropTypes.instanceOf(SafeNodeList),
                  PropTypes.arrayOf(PropTypes.instanceOf(SafeHTMLElement))
            Severity: Major
            Found in src/components/ModalPortal.js and 1 other location - About 1 hr to fix
            src/components/Modal.js on lines 61..66

            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 58.

            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

            Further Reading

            Identical blocks of code found in 2 locations. Consider refactoring.
            Open

                appElement: PropTypes.oneOfType([
                  PropTypes.instanceOf(SafeHTMLElement),
                  PropTypes.instanceOf(SafeHTMLCollection),
                  PropTypes.instanceOf(SafeNodeList),
                  PropTypes.arrayOf(PropTypes.instanceOf(SafeHTMLElement))
            Severity: Major
            Found in src/components/Modal.js and 1 other location - About 1 hr to fix
            src/components/ModalPortal.js on lines 55..60

            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 58.

            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

            Further Reading

            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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                export const remove = (element, classString) =>
                  untrackClass(
                    element.classList,
                    element.nodeName.toLowerCase() == "html" ? htmlClassList : docBodyClassList,
                    classString.split(" ")
                Severity: Minor
                Found in src/helpers/classList.js and 1 other location - About 50 mins to fix
                src/helpers/classList.js on lines 115..120

                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 52.

                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

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                export const add = (element, classString) =>
                  trackClass(
                    element.classList,
                    element.nodeName.toLowerCase() == "html" ? htmlClassList : docBodyClassList,
                    classString.split(" ")
                Severity: Minor
                Found in src/helpers/classList.js and 1 other location - About 50 mins to fix
                src/helpers/classList.js on lines 128..133

                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 52.

                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

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                  constructor(props) {
                    super(props);
                
                    this.state = {
                      isOpen: false,
                Severity: Minor
                Found in examples/basic/nested_modals/index.js and 1 other location - About 50 mins to fix
                examples/basic/multiple_modals/index.js on lines 18..26

                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 51.

                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

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        <Modal
                          id="test"
                          closeTimeoutMS={150}
                          contentLabel="modalA"
                          isOpen={isOpen}
                Severity: Minor
                Found in examples/basic/nested_modals/index.js and 1 other location - About 50 mins to fix
                examples/basic/multiple_modals/index.js on lines 75..88

                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 51.

                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

                Further Reading

                Severity
                Category
                Status
                Source
                Language