Vizzuality/landgriffon

View on GitHub

Showing 438 of 1,408 total issues

Function up has 71 lines of code (exceeds 25 allowed). Consider refactoring.
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

      private createBasicSelectQuery(
        impactDataDto: GetActualVsScenarioImpactTableDto | BaseImpactTableDto,
      ): SelectQueryBuilder<SourcingRecord> {
        const basicSelectQuery: SelectQueryBuilder<SourcingRecord> =
          this.entityManager
    Severity: Major
    Found in api/src/modules/impact/impact.repository.ts - About 2 hrs to fix

      Function saveListToTree has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public async saveListToTree(
          importData: CreateDto[],
          pathKey: keyof CreateDto,
        ): Promise<Entity[]> {
          let rest: (CreateDto & WithExplodedPath)[] = importData.map(
      Severity: Major
      Found in api/src/utils/tree.repository.ts - About 2 hrs to fix

        File create.scenario-intervention.dto.ts has 284 lines of code (exceeds 250 allowed). Consider refactoring.
        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

          import cx from 'classnames';
          
          import { useForm } from 'react-hook-form';
          import { yupResolver } from '@hookform/resolvers/yup';
          import * as yup from 'yup';
          Severity: Minor
          Found in marketing/src/containers/contact/component.tsx - About 2 hrs to fix

            Function DownloadMaterialsDataButton has 70 lines of code (exceeds 25 allowed). Consider refactoring.
            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

              const SupplierSourcingInfo = (): JSX.Element => {
                const { supplierId }: { supplierId: string } = useParams();
                const {
                  filters: { dates },
                } = useAppSelector(eudrDetail);
              Severity: Major
              Found in client/src/containers/analysis-eudr-detail/sourcing-info/index.tsx - About 2 hrs to fix

                Function ImpactLayer has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                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

                    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

                      renderLayers(): Array<any> {
                        const layers = [];
                        if (this.state?.layersData) {
                          const { layersData, highlightedObject } = this.state;
                          const { circleAttributes, lineAttributes } = layersData || {};
                    Severity: Major
                    Found in cookie-traceability/src/lib/flowmap/layers/FlowMapLayer.ts - About 2 hrs to fix

                      Function BlogPosts has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                      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
                      Severity: Major
                      Found in marketing/src/containers/blog-posts/component.tsx - About 2 hrs to fix

                        Function AdminTargetsPage has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const AdminTargetsPage: React.FC = () => {
                          const { data: indicators } = useIndicators(undefined, { select: (data) => data.data });
                          const { isLoading } = useTargets();
                          const hasData = useMemo(() => indicators?.length > 0, [indicators]);
                        
                        
                        Severity: Major
                        Found in client/src/pages/data/targets.tsx - About 2 hrs to fix

                          Function Newsletter has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const Newsletter: React.FC = () => {
                            const [status, setStatus] = useState(DEFAULT_STATUS);
                            const { basePath } = useRouter();
                          
                            const onSubmit = (values) => {
                          Severity: Major
                          Found in landing/components/newsletter/component.tsx - About 2 hrs to fix

                            Function calculateIndicatorValues has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                            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

                                private async _getFlowLayerPickingInfo(
                                  info: Record<string, any>,
                                ): Promise<FlowLayerPickingInfo<L, F> | undefined> {
                                  const { index, sourceLayer } = info;
                                  const { dataProvider, accessors } = this.state || {};
                              Severity: Minor
                              Found in cookie-traceability/src/lib/flowmap/layers/FlowMapLayer.ts - About 2 hrs 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

                              File scenario-intervention.repository.ts has 281 lines of code (exceeds 250 allowed). Consider refactoring.
                              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

                                  const subchartData = useMemo(() => {
                                    const {
                                      indicatorShortName,
                                      rows,
                                      yearSum,
                                Severity: Major
                                Found in client/src/containers/analysis-chart/impact-chart/component.tsx - About 2 hrs to fix

                                  Function Values has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                                  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">
                                  Severity: Major
                                  Found in marketing/src/containers/about/values/component.tsx - About 2 hrs to fix

                                    Function EditInterventionPage has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                                    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

                                        async getEntityTree(
                                          impactTableDto: AnyImpactTableDto,
                                        ): Promise<ImpactTableEntityType[]> {
                                          const treeOptions: CommonFiltersDto = {
                                            ...(impactTableDto.materialIds && {
                                      Severity: Major
                                      Found in api/src/modules/impact/base-impact.service.ts - About 2 hrs to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language