TryGhost/Ghost

View on GitHub
apps/sodo-search/src/components/PopupModal.js

Summary

Maintainability
F
5 days
Test Coverage

File PopupModal.js has 619 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Frame from './Frame';
import AppContext from '../AppContext';
import {ReactComponent as SearchIcon} from '../icons/search.svg';
import {ReactComponent as ClearIcon} from '../icons/clear.svg';
import {ReactComponent as CircleAnimated} from '../icons/circle-anim.svg';
Severity: Major
Found in apps/sodo-search/src/components/PopupModal.js - About 1 day to fix

    Function SearchBox has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function SearchBox() {
        const {searchValue, dispatch, inputRef} = useContext(AppContext);
        const containerRef = useRef(null);
        useEffect(() => {
            setTimeout(() => {
    Severity: Minor
    Found in apps/sodo-search/src/components/PopupModal.js - About 1 hr to fix

      Function SearchResultBox has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function SearchResultBox() {
          const {searchValue = '', searchIndex, indexComplete} = useContext(AppContext);
          let searchResults = null;
          let filteredTags = [];
          let filteredPosts = [];
      Severity: Minor
      Found in apps/sodo-search/src/components/PopupModal.js - About 1 hr to fix

        Function StylesWrapper has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const StylesWrapper = () => {
            return {
                modalContainer: {
                    zIndex: '3999999',
                    position: 'fixed',
        Severity: Minor
        Found in apps/sodo-search/src/components/PopupModal.js - About 1 hr to fix

          Function HighlightedSection has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          function HighlightedSection({text = '', highlight = '', isExcerpt}) {
              text = text || '';
              highlight = highlight || '';
              let {parts, highlightIndexes} = getHighlightParts({text, highlight});
              if (isExcerpt && highlightIndexes?.[0]) {
          Severity: Minor
          Found in apps/sodo-search/src/components/PopupModal.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

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

          function TagResults({tags, selectedResult, setSelectedResult}) {
              if (!tags?.length) {
                  return null;
              }
          
          
          Severity: Major
          Found in apps/sodo-search/src/components/PopupModal.js and 1 other location - About 5 hrs to fix
          apps/sodo-search/src/components/PopupModal.js on lines 439..460

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

          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

          function AuthorResults({authors, selectedResult, setSelectedResult}) {
              if (!authors?.length) {
                  return null;
              }
          
          
          Severity: Major
          Found in apps/sodo-search/src/components/PopupModal.js and 1 other location - About 5 hrs to fix
          apps/sodo-search/src/components/PopupModal.js on lines 197..217

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

          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

          const StylesWrapper = () => {
              return {
                  modalContainer: {
                      zIndex: '3999999',
                      position: 'fixed',
          Severity: Major
          Found in apps/sodo-search/src/components/PopupModal.js and 1 other location - About 4 hrs to fix
          apps/portal/src/components/PopupModal.js on lines 11..40

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

          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 3 locations. Consider refactoring.
          Open

                  <div
                      className={className}
                      onClick={() => {
                          if (url) {
                              window.location.href = url;
          Severity: Major
          Found in apps/sodo-search/src/components/PopupModal.js and 2 other locations - About 1 hr to fix
          apps/sodo-search/src/components/PopupModal.js on lines 227..244
          apps/sodo-search/src/components/PopupModal.js on lines 409..422

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

          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 3 locations. Consider refactoring.
          Open

                  <div
                      className={className}
                      onClick={() => {
                          if (url) {
                              window.location.href = url;
          Severity: Major
          Found in apps/sodo-search/src/components/PopupModal.js and 2 other locations - About 1 hr to fix
          apps/sodo-search/src/components/PopupModal.js on lines 180..193
          apps/sodo-search/src/components/PopupModal.js on lines 409..422

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

          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 3 locations. Consider refactoring.
          Open

                  <div
                      className={className}
                      onClick={() => {
                          if (url) {
                              window.location.href = url;
          Severity: Major
          Found in apps/sodo-search/src/components/PopupModal.js and 2 other locations - About 1 hr to fix
          apps/sodo-search/src/components/PopupModal.js on lines 180..193
          apps/sodo-search/src/components/PopupModal.js on lines 227..244

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

          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

              handlePopupClose(e) {
                  e.preventDefault();
                  if (e.target === e.currentTarget) {
                      this.context.dispatch('update', {
                          showPopup: false
          Severity: Major
          Found in apps/sodo-search/src/components/PopupModal.js and 1 other location - About 1 hr to fix
          apps/sodo-search/src/components/PopupModal.js on lines 57..64

          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

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

              handlePopupClose(e) {
                  e.preventDefault();
                  if (e.target === e.currentTarget) {
                      this.context.dispatch('update', {
                          showPopup: false
          Severity: Major
          Found in apps/sodo-search/src/components/PopupModal.js and 1 other location - About 1 hr to fix
          apps/sodo-search/src/components/PopupModal.js on lines 620..627

          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

              filteredAuthors = filteredAuthors.filter((author) => {
                  const invalidUrlRegex = /\/404\/$/;
                  return !(author?.url && invalidUrlRegex.test(author?.url));
              });
          Severity: Minor
          Found in apps/sodo-search/src/components/PopupModal.js and 1 other location - About 55 mins to fix
          apps/sodo-search/src/components/PopupModal.js on lines 481..484

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

          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

              filteredTags = filteredTags.filter((tag) => {
                  const invalidUrlRegex = /\/404\/$/;
                  return !(tag?.url && invalidUrlRegex.test(tag?.url));
              });
          Severity: Minor
          Found in apps/sodo-search/src/components/PopupModal.js and 1 other location - About 55 mins to fix
          apps/sodo-search/src/components/PopupModal.js on lines 476..479

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

          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

                  return (
                      <>
                          <style dangerouslySetInnerHTML={{__html: styles}} />
                          <meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1' />
                      </>
          Severity: Minor
          Found in apps/sodo-search/src/components/PopupModal.js and 1 other location - About 40 mins to fix
          apps/portal/src/components/PopupModal.js on lines 274..279

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

          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

                      <h2 className='text-[1.65rem] font-medium leading-tight text-neutral-800'>
                          <HighlightedSection text={title} highlight={searchValue} isExcerpt={false} />
                      </h2>
          Severity: Minor
          Found in apps/sodo-search/src/components/PopupModal.js and 1 other location - About 35 mins to fix
          apps/sodo-search/src/components/PopupModal.js on lines 241..243

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

          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

                      <p className='text-neutral-400 leading-normal text-sm mt-0 mb-0 truncate'>
                          <HighlightedSection text={excerpt} highlight={searchValue} isExcerpt={true} />
                      </p>
          Severity: Minor
          Found in apps/sodo-search/src/components/PopupModal.js and 1 other location - About 35 mins to fix
          apps/sodo-search/src/components/PopupModal.js on lines 238..240

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

          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

              render() {
                  const {showPopup} = this.context;
                  if (showPopup) {
                      return this.renderFrameContainer();
                  }
          Severity: Minor
          Found in apps/sodo-search/src/components/PopupModal.js and 1 other location - About 30 mins to fix
          apps/portal/src/components/PopupModal.js on lines 314..320

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

          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

          There are no issues that match your filters.

          Category
          Status