Vizzuality/landgriffon

View on GitHub

Showing 438 of 1,408 total issues

Function parseSourcingDataFromSheet has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  async parseSourcingDataFromSheet(customData: WorkSheet[]): Promise<{
    sourcingData: SourcingData[];
  }> {
    this.logger.debug(`Cleaning ${customData.length} custom data rows`);
    const sourcingData: SourcingData[] = [];
Severity: Minor
Found in api/src/modules/import-data/sourcing-data/dto-processor.service.ts - About 1 hr 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 DeforestationAlerts has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const DeforestationAlerts = (): JSX.Element => {
  const { supplierId }: { supplierId: string } = useParams();
  const {
    filters: { dates },
  } = useAppSelector(eudrDetail);

    Function YearsFilter has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const YearsFilter: React.FC = () => {
      const dispatch = useAppDispatch();
      const filters = useAppSelector(analysisFilters);
      const { layer, materials, indicator, startYear } = filters;
    
    
    Severity: Minor
    Found in client/src/containers/years/component.tsx - About 1 hr to fix

      Function RADDSlider has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const RADDSlider = () => {
        const dispatch = useAppDispatch();
        const [values, setValues] = useState<number[]>([0, 0]);
        const data = layersData.find((layer) => layer.id === LAYERD_ID);
        const dates = data?.legend?.dates;
      Severity: Minor
      Found in client/src/containers/analysis-eudr/map/legend/radd-slider.tsx - About 1 hr to fix

        Function buildImpactTable has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private buildImpactTable(
            queryDto: GetImpactTableDto,
            indicators: Indicator[],
            dataForImpactTable: ImpactTableData[],
            entityTree: ImpactTableEntityType[],
        Severity: Minor
        Found in api/src/modules/impact/impact.service.ts - About 1 hr to fix

          Function groupAndFillAlertsByMonth has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const groupAndFillAlertsByMonth = (
            alerts: AlertsOutput[],
            geoRegionMap: Map<string, any>,
            startDate: Date,
            endDate: Date,
          Severity: Minor
          Found in api/src/modules/eudr-alerts/dashboard/dashboard-utils.ts - About 1 hr to fix

            Function ImpactBeyondCompliance has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const ImpactBeyondCompliance: React.FC = () => {
              return (
                <section className="relative space-y-12 bg-blue-600 md:space-y-64">
                  <Wrapper>
                    <div className="space-y-10 text-white md:space-y-20 md:py-32 py-12">

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

                async createUser(dto: CreateUserDTO): Promise<Partial<User>> {
                  const user: User = new User();
                  user.fname = dto.fname ?? DEFAULT_USER_NAME;
                  user.lname = dto.lname;
                  user.title = dto.title;
              Severity: Minor
              Found in api/src/modules/authentication/authentication.service.ts - About 1 hr to fix

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

                  private addEntityFiltersToQuery(
                    selectQueryBuilder: SelectQueryBuilder<SourcingRecord>,
                    impactDataDto: GetActualVsScenarioImpactTableDto | GetImpactTableDto,
                  ): SelectQueryBuilder<SourcingRecord> {
                    if (impactDataDto.materialIds) {
                Severity: Minor
                Found in api/src/modules/impact/impact.repository.ts - About 1 hr to fix

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

                    async geoCodeAdministrativeRegionOfProduction(
                      sourcingData: SourcingData,
                    ): Promise<SourcingData> {
                      // TODO: Since this has become required for all location types, we should validate this at DTO level
                      if (!sourcingData.locationCountryInput) {

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

                      async getEntityMetadata(dto: GetDashBoardDTO): Promise<EntityMetadata[]> {
                        const queryBuilder: SelectQueryBuilder<EntityMetadata> =
                          this.datasource.createQueryBuilder();
                        queryBuilder
                          .select('s.id', 'supplierId')
                    Severity: Minor
                    Found in api/src/modules/eudr-alerts/dashboard/eudr-dashboard.service.ts - About 1 hr to fix

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

                      const Hero: React.FC = () => {
                        return (
                          <section className="relative flex flex-col items-center justify-center w-full py-12 overflow-hidden bg-blue-600 md:h-screen">
                            <div className="absolute top-0 right-0 hidden w-[800px] h-[800px] bg-right-bottom bg-no-repeat pointer-events-none md:block">
                              <object
                      Severity: Minor
                      Found in marketing/src/containers/home/hero/component.tsx - About 1 hr to fix

                        Function main has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def main(drop_contextuals: bool, dry_run: bool):
                            with psycopg.connect(get_connection_info()) as conn:
                                with conn.cursor() as cursor:
                                    # find all the tables that start with h3_grid*
                                    cursor.execute(
                        Severity: Minor
                        Found in data/h3_data_importer/delete_h3_tables.py - About 1 hr 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 cluster has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function cluster(points: Point[], zoom: number, tree: ZoomLevelKDBush, options: Options) {
                          const clusters: Point[] = [];
                          const { radius, extent } = options;
                          const r = radius / (extent * Math.pow(2, zoom));
                        
                        
                        Severity: Minor
                        Found in cookie-traceability/src/lib/flowmap/data/cluster/cluster.ts - About 1 hr 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 addGroupAndOrderByToQuery has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          private addGroupAndOrderByToQuery(
                            selectQueryBuilder: SelectQueryBuilder<SourcingRecord>,
                            impactDataDto: GetActualVsScenarioImpactTableDto | BaseImpactTableDto,
                          ): SelectQueryBuilder<SourcingRecord> {
                            switch (impactDataDto.groupBy) {
                        Severity: Minor
                        Found in api/src/modules/impact/impact.repository.ts - About 1 hr to fix

                          Function getActualVsScenarioImpactMap has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async getActualVsScenarioImpactMap(
                              dto: GetActualVsScenarioImpactMapDto,
                            ): Promise<{ impactMap: H3IndexValueData[]; quantiles: number[] }> {
                              const baseQueryExtend = (baseQuery: SelectQueryBuilder<any>): void => {
                                //Add selection criteria to also select both comparedScenario in the select statement
                          Severity: Minor
                          Found in api/src/modules/h3-data/h3-data.repository.ts - About 1 hr to fix

                            Function serializerConfig has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              get serializerConfig(): JSONAPISerializerConfig<User> {
                                return {
                                  attributes: [
                                    'fname',
                                    'lname',
                            Severity: Minor
                            Found in api/src/modules/users/users.service.ts - About 1 hr to fix

                              Function parseSourcingDataFromSheet has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                async parseSourcingDataFromSheet(customData: WorkSheet[]): Promise<{
                                  sourcingData: SourcingData[];
                                }> {
                                  this.logger.debug(`Cleaning ${customData.length} custom data rows`);
                                  const sourcingData: SourcingData[] = [];
                              Severity: Minor
                              Found in api/src/modules/import-data/sourcing-data/dto-processor.service.ts - About 1 hr to fix

                                Function MapPage has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                const MapPage: NextPageWithLayout = () => {
                                  const scrollRef = useRef<HTMLDivElement>(null);
                                  const { planetCompareLayer } = useAppSelector((state) => state.eudr);
                                  const [isCollapsed, setIsCollapsed] = useState(false);
                                
                                
                                Severity: Minor
                                Found in client/src/pages/eudr/index.tsx - About 1 hr to fix

                                  Function GroupByFilter has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  const GroupByFilter: React.FC = () => {
                                    const { replace, query = {} } = useRouter();
                                    const dispatch = useAppDispatch();
                                    const filters = useAppSelector(analysisFilters);
                                  
                                  
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language