Showing 438 of 1,408 total issues
Function NewsLetter
has 108 lines of code (exceeds 25 allowed). Consider refactoring. Open
const NewsLetter: React.FC = () => {
const [submitting, setSubmitting] = useState(false);
const [success, setSuccess] = useState(false);
const { register, handleSubmit, formState } = useForm({
Function StackedAreaChart
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
const StackedAreaChart: React.FC<StackedAreaChartProps> = ({ indicator }) => {
const router = useRouter();
const { scenarioId, compareScenarioId } = router.query || {};
const [itemOpacity, setItemOpacity] = useState<Record<string, number>>({});
- 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 MaterialLayer
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
const MaterialLayer = () => {
const dispatch = useAppDispatch();
const { materialId } = useAppSelector(analysisFilters);
const [syncedIndicators] = useSyncIndicators();
Function SuppliersListTable
has 104 lines of code (exceeds 25 allowed). Consider refactoring. Open
const SuppliersListTable = (): JSX.Element => {
const dispatch = useAppDispatch();
// const [rowSelection, setRowSelection] = useState({});
// const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
// const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
Function AppScreens
has 104 lines of code (exceeds 25 allowed). Consider refactoring. Open
const AppScreens: React.FC = () => {
const { ref: highlightRef, inView } = useInView();
const [ref, percentage] = useScrollPercentage();
Function AnalysisMap
has 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
const AnalysisMap = () => {
const { layers } = useAppSelector(analysisMap);
const { isSidebarCollapsed } = useAppSelector(analysisUI);
const [mapStyle, setMapStyle] = useState<MapStyle>('terrain');
File compare.tsx
has 331 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { useState, useCallback, useEffect, useMemo } from 'react';
import DeckGL from '@deck.gl/react/typed';
import { GeoJsonLayer } from '@deck.gl/layers/typed';
import Map, { useMap, Source, Layer } from 'react-map-gl/maplibre';
import { WebMercatorViewport } from '@deck.gl/core/typed';
Function tickMultiFormat
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
export function tickMultiFormat(date: Date) {
return (
timeSecond(date) < date
? formatMillisecond
: timeMinute(date) < date
- 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 SignIn
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
const SignIn: NextPageWithLayout = () => {
const {
register,
handleSubmit,
formState: { errors },
Function Step04
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
const Step04: React.FC = () => {
return (
<article
className={cx({
'flex flex-col lg:flex-row-reverse justify-between space-y-10 lg:space-x-10 lg:space-x-reverse lg:space-y-0':
Function Team
has 92 lines of code (exceeds 25 allowed). Consider refactoring. Open
const Team: React.FC = () => {
const CORE_TEAM = useMemo(() => {
return TEAM.filter(({ group }) => group === 'core').sort((a, b) => {
// if (ROLE_ORDER.indexOf(a.role) === ROLE_ORDER.indexOf(b.role)) {
// return a.name.localeCompare(b.name);
File component.tsx
has 317 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { useCallback, useEffect, useMemo, useState } from 'react';
import omit from 'lodash-es/omit';
import chroma from 'chroma-js';
import {
AreaChart,
Function importSourcingData
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
async importSourcingData(filePath: string, taskId: string): Promise<any> {
this.logger.log(`Starting import process`);
await this.fileService.isFilePresentInFs(filePath);
try {
const parsedXLSXDataset: SourcingRecordsSheets =
Function What
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
const What: React.FC = () => {
const [slide, setSlide] = useState(0);
const DESCRIPTION = useMemo(() => {
return SLIDES[slide]?.description;
Function IndicatorsMapFilter
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
const IndicatorsMapFilter = () => {
const [value, setValue] = useState<string | undefined>(undefined);
const [syncedIndicators, setSyncedIndicators] = useSyncIndicators();
const { data, isFetching, isFetched } = useIndicators(
Function prepareLayersData
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
prepareLayersData(state: FlowMapState, props: FlowMapData<L, F>): LayersData {
const locations = this.getLocationsForFlowMapLayer(state, props) || [];
const flows = this.getFlowsForFlowMapLayer(state, props) || [];
const { getFlowOriginId, getFlowDestId, getFlowMagnitude, getLocationId, getLocationCentroid } =
this.accessors;
Function StackedAreaChart
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
const StackedAreaChart: React.FC<StackedAreaChartProps> = ({ indicator }) => {
const [legendKey, setLegendKey] = useState<string | null>(null);
const filters = useAppSelector(filtersForTabularAPI);
const { currentScenario: scenarioId } = useAppSelector(scenarios);
- 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 geoCodePointOfProduction
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
async geoCodePointOfProduction(sourcingData: SourcingData): Promise<any> {
if (!sourcingData.locationCountryInput)
throw new Error(
'A country must be provided for Point of Production location type',
);
Function Footer
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
const Footer: React.FC = () => {
return (
<footer className="bg-white ">
<Wrapper>
<nav className="py-12 md:py-32">
Function useImpactLayer
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const useImpactLayer = () => {
const searchParams = useSearchParams();
const compareScenarioId = searchParams.get('compareScenarioId');
const scenarioId = searchParams.get('scenarioId');
const isComparisonEnabled = Boolean(compareScenarioId);