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(
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>
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';
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));
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);
Function HeaderLinks
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
const HeaderLinks = () => {
const { locale, asPath } = useRouter();
return (
<>
<Link
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">
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(() => {
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')
- 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 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 (
- 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 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 || '');
- 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
} else if (unaccent(item.source.value).match(regex)) return true;
Avoid too many return
statements within this function. Open
if (item.depicts.value.some(d => unaccent(d).match(regex))) return true;
Avoid too many return
statements within this function. Open
} else if (unaccent(item.depicts).match(regex)) return true;
Avoid too many return
statements within this function. Open
if (item.source.value.some(d => unaccent(d).match(regex))) return true;
Avoid too many return
statements within this function. Open
if (item.date && item.date.toString().match(regex)) return true;
Avoid too many return
statements within this function. Open
if (unaccent(item.depicts.value).match(regex)) return true;
Avoid too many return
statements within this function. Open
return false;
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 = [];
- 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 AtlasController
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const AtlasController = ({ width, height, mobile }) => {
const [
{
activeImages,
year,
- 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"