Showing 438 of 1,408 total issues
Function up
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
'CREATE OR REPLACE FUNCTION sum_weighted_deforestation_over_georegion(\n' +
' geo_region_id uuid,\n' +
' material_id uuid,\n' +
Function createBasicSelectQuery
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private createBasicSelectQuery(
impactDataDto: GetActualVsScenarioImpactTableDto | BaseImpactTableDto,
): SelectQueryBuilder<SourcingRecord> {
const basicSelectQuery: SelectQueryBuilder<SourcingRecord> =
this.entityManager
Function saveListToTree
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public async saveListToTree(
importData: CreateDto[],
pathKey: keyof CreateDto,
): Promise<Entity[]> {
let rest: (CreateDto & WithExplodedPath)[] = importData.map(
File create.scenario-intervention.dto.ts
has 284 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
ArrayMaxSize,
ArrayNotEmpty,
IsEnum,
File component.tsx
has 284 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import cx from 'classnames';
import { useForm } from 'react-hook-form';
import { yupResolver } from '@hookform/resolvers/yup';
import * as yup from 'yup';
Function DownloadMaterialsDataButton
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const DownloadMaterialsDataButton: React.FC = () => {
const [isDownloading, setIsDownloading] = useState<boolean>(false);
const {
data: sourcingLocations,
Function SupplierSourcingInfo
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const SupplierSourcingInfo = (): JSX.Element => {
const { supplierId }: { supplierId: string } = useParams();
const {
filters: { dates },
} = useAppSelector(eudrDetail);
Function ImpactLayer
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const ImpactLayer = () => {
const searchParams = useSearchParams();
const isComparisonEnabled = Boolean(searchParams.get('compareScenarioId'));
const dispatch = useAppDispatch();
Function down
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
'CREATE OR REPLACE FUNCTION sum_weighted_deforestation_over_georegion(\n' +
' geo_region_id uuid,\n' +
' material_id uuid,\n' +
Function renderLayers
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
renderLayers(): Array<any> {
const layers = [];
if (this.state?.layersData) {
const { layersData, highlightedObject } = this.state;
const { circleAttributes, lineAttributes } = layersData || {};
Function BlogPosts
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const BlogPosts: FC = () => {
const [slide, setSlide] = useState(1);
const { data, isFetched } = usePosts();
const posts = data?.items?.slice(0, 6); // Taking the first 4 posts
Function AdminTargetsPage
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const AdminTargetsPage: React.FC = () => {
const { data: indicators } = useIndicators(undefined, { select: (data) => data.data });
const { isLoading } = useTargets();
const hasData = useMemo(() => indicators?.length > 0, [indicators]);
Function Newsletter
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const Newsletter: React.FC = () => {
const [status, setStatus] = useState(DEFAULT_STATUS);
const { basePath } = useRouter();
const onSubmit = (values) => {
Function calculateIndicatorValues
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private calculateIndicatorValues(
rawData: SourcingRecordsWithIndicatorRawData,
tonnage: number,
): Map<INDICATOR_NAME_CODES, number> {
const map: Map<INDICATOR_NAME_CODES, number> = new Map();
Function _getFlowLayerPickingInfo
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
Open
private async _getFlowLayerPickingInfo(
info: Record<string, any>,
): Promise<FlowLayerPickingInfo<L, F> | undefined> {
const { index, sourceLayer } = info;
const { dataProvider, accessors } = this.state || {};
- 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
File scenario-intervention.repository.ts
has 281 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { DataSource, InsertResult, QueryRunner, Repository } from 'typeorm';
import { ScenarioIntervention } from 'modules/scenario-interventions/scenario-intervention.entity';
import { SourcingLocation } from 'modules/sourcing-locations/sourcing-location.entity';
import { SourcingRecord } from 'modules/sourcing-records/sourcing-record.entity';
import { IndicatorRecord } from 'modules/indicator-records/indicator-record.entity';
Function subchartData
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const subchartData = useMemo(() => {
const {
indicatorShortName,
rows,
yearSum,
Function Values
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const Values: React.FC = () => {
return (
<section className="relative z-10 overflow-hidden bg-white">
<Wrapper>
<FadeIn className="relative flex flex-col items-center justify-center py-12 space-y-20 md:py-32">
Function EditInterventionPage
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const EditInterventionPage: React.FC = () => {
const router = useRouter();
const { query } = router;
const { data, isLoading } = useIntervention({
interventionId: query?.interventionId as string,
Function getEntityTree
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async getEntityTree(
impactTableDto: AnyImpactTableDto,
): Promise<ImpactTableEntityType[]> {
const treeOptions: CommonFiltersDto = {
...(impactTableDto.materialIds && {