imaginerio/imaginerioNext

View on GitHub

Showing 21 of 57 total issues

Function LegendSwatches has 93 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const LegendSwatches = () => {
  const { locale } = useRouter();
  const [legend, setLegend] = useState(null);
  const [{ year, highlightedLayer }, dispatch] = useImages();
  const { data } = useSwr(
Severity: Major
Found in components/Legend/LegendSwatches.js - About 3 hrs to fix

    Function Footer has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const Footer = () => {
      const { locale } = useRouter();
      return (
        <Box as="section" backgroundColor="#F7F9FC" py={[5, 50]}>
          <Container>
    Severity: Major
    Found in components/Footer/index.js - About 2 hrs to fix

      File ImageContext.js has 259 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import React, { createContext, useContext, useEffect, useReducer } from 'react';
      import PropTypes from 'prop-types';
      import { orderBy, countBy } from 'lodash';
      import unaccent from '../utils/unaccent';
      
      
      Severity: Minor
      Found in providers/ImageContext.js - About 2 hrs to fix

        Function Legend has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const Legend = () => {
          const { locale, query } = useRouter();
          const [{ year, drawSearch, highlightedFeature }] = useImages();
          const [legendOpen, setLegendOpen] = useState(Boolean(query.feature));
          const [searchResultsActive, setSearchResultsActive] = useState(Boolean(query.feature));
        Severity: Minor
        Found in components/Legend/index.js - About 1 hr to fix

          Function Intro has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const Intro = () => {
            const [{ showIntro }, dispatch] = useImages();
            const { locale } = useRouter();
            const [steps, setSteps] = useState([]);
            const [introCookie, setIntroCookie] = useState(false);
          Severity: Minor
          Found in components/Intro/index.js - About 1 hr to fix

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

            const HeaderLinks = () => {
              const { locale, asPath } = useRouter();
              return (
                <>
                  <Link
            Severity: Minor
            Found in components/Header/index.js - About 1 hr to fix

              Function Header has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const Header = () => {
                const { locale } = useRouter();
                return (
                  <Container maxW="6xl">
                    <Flex h="90px" alignItems="center">
              Severity: Minor
              Found in components/Header/index.js - About 1 hr to fix

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

                const CollectionFilter = () => {
                  const { locale, query } = useRouter();
                  const [{ categories, collection }, dispatch] = useImages();
                
                  useEffect(() => {
                Severity: Minor
                Found in components/ImageFilter/index.js - About 1 hr to fix

                  Function search has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const search = ({ query, dates, sort, direction, allImages, collection, mapBounds }) => {
                    if (!allImages) return [];
                    let items = allImages;
                    if (query) items = items.filter(item => textSearch({ item, query }));
                    if (collection && collection !== 'all')
                  Severity: Minor
                  Found in providers/ImageContext.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 ImageSort has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const ImageSort = ({ small, collection }) => {
                    const { locale } = useRouter();
                    const [{ direction }, dispatch] = useImages();
                  
                    return (
                  Severity: Minor
                  Found in components/ImageSort/index.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 MapSearch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const MapSearch = ({ handler }) => {
                    const { locale, query } = useRouter();
                    const [{ year, drawSearch, drawSearchCoords, highlightedFeature }, dispatch] = useImages();
                  
                    const [string, setString] = useState(query.feature || '');
                  Severity: Minor
                  Found in components/MapSearch/index.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

                  Avoid too many return statements within this function.
                  Open

                        } else if (unaccent(item.source.value).match(regex)) return true;
                  Severity: Major
                  Found in providers/ImageContext.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            if (item.depicts.value.some(d => unaccent(d).match(regex))) return true;
                    Severity: Major
                    Found in providers/ImageContext.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            } else if (unaccent(item.depicts).match(regex)) return true;
                      Severity: Major
                      Found in providers/ImageContext.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                if (item.source.value.some(d => unaccent(d).match(regex))) return true;
                        Severity: Major
                        Found in providers/ImageContext.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              if (item.date && item.date.toString().match(regex)) return true;
                          Severity: Major
                          Found in providers/ImageContext.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    if (unaccent(item.depicts.value).match(regex)) return true;
                            Severity: Major
                            Found in providers/ImageContext.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                  return false;
                              Severity: Major
                              Found in providers/ImageContext.js - About 30 mins to fix

                                Function MetaLinks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                Open

                                export const MetaLinks = ({ source }) => {
                                  let links;
                                  if (typeof source === 'string') return <>{source}</>;
                                  if (source && source.link) {
                                    links = [];
                                Severity: Minor
                                Found in components/ImageList/RowComponents.js - About 25 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 AtlasController has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                Open

                                const AtlasController = ({ width, height, mobile }) => {
                                  const [
                                    {
                                      activeImages,
                                      year,
                                Severity: Minor
                                Found in components/AtlasController/index.js - About 25 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

                                Severity
                                Category
                                Status
                                Source
                                Language