Vizzuality/landgriffon

View on GitHub

Showing 1,408 of 1,408 total issues

Function getMaterialsH3DataYearsList has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private async getMaterialsH3DataYearsList(
    year: number,
    materialIds?: string[],
  ): Promise<MaterialsH3DataYears[]> {
    const materialsH3DataYears: MaterialsH3DataYears[] = [];
Severity: Minor
Found in api/src/modules/h3-data/h3-data-map.service.ts - About 1 hr to fix

    Function geocode has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async geocode(args: GeocodeArgs): Promise<GeocodeResponseData> {
        if (!this.apiKey) {
          this.logger.error(
            'Google API key missing when attempting to geocode location. Cannot process request.',
          );
    Severity: Minor
    Found in api/src/modules/geo-coding/geocoders/google-maps.geocoder.ts - About 1 hr to fix

      Function up has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public async up(queryRunner: QueryRunner): Promise<void> {
          await queryRunner.query(`CREATE OR REPLACE FUNCTION sum_h3_weighted_cropland_area(
          geo_region_id uuid,
          material_id uuid,
          h3_data_type material_to_h3_type_enum
      Severity: Minor
      Found in api/src/migrations/1667976597890-PointerToAllHarvestSumColumn.ts - About 1 hr to fix

        Function AdminDataPage has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const AdminDataPage: React.FC = () => {
          const { data, isFetched: sourcingLocationsAreFetched } = useSourcingLocations({
            fields: 'updatedAt',
            'page[number]': 1,
            'page[size]': 1,
        Severity: Minor
        Found in client/src/pages/data/index.tsx - About 1 hr to fix

          Function generateNewLocationsForIntervention has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async generateNewLocationsForIntervention(
              dto: CreateScenarioInterventionDto,
              newIntervention: ScenarioIntervention,
              actualSourcingLocations: SourcingLocation[],
              locationData: {

            Function populateValuesRecursively has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private populateValuesRecursively(
                entity: ImpactTableRows,
                entityMap: Map<string, Map<number, ImpactTableRowsValues>>,
                rangeOfYears: number[],
              ): ImpactTableRowsValues[] {
            Severity: Minor
            Found in api/src/modules/impact/impact.service.ts - About 1 hr to fix

              Function calculateScenarioComparisonQuantiles has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private async calculateScenarioComparisonQuantiles(
                  tmpTableName: string,
                ): Promise<number[]> {
                  try {
                    // due to the inner workings of the pg driver and the way it parses different number types
              Severity: Minor
              Found in api/src/modules/h3-data/h3-data.repository.ts - About 1 hr to fix

                Function postProcessYearIndicatorData has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  private postProcessYearIndicatorData(
                    entityMap: Map<string, Map<number, ActualVsScenarioImpactTableRowsValues>>,
                    rangeOfYears: number[],
                    lastYearWithData: number,
                  ): void {
                Severity: Minor
                Found in api/src/modules/impact/comparison/actual-vs-scenario.service.ts - About 1 hr to fix

                  Function SBTNandTNFDOverview has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const SBTNandTNFDOverview: React.FC = () => {
                    return (
                      <section className="bg-white">
                        <Wrapper>
                          <div className="relative md:py-32 py-12 border-t border-black/10">

                    Function load_csvs_into_tables has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def load_csvs_into_tables(csv_file_list):
                        conn = psycopg2.connect(
                            host=os.getenv('API_POSTGRES_HOST'),
                            port=os.getenv('API_POSTGRES_PORT'),
                            database=os.getenv('API_POSTGRES_DATABASE'),
                    Severity: Minor
                    Found in data/base_data_importer/csv_to_table.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 DeforestationAlertsChart has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const DeforestationAlertsChart = (): JSX.Element => {
                      const [selectedPlots, setSelectedPlots] = useState<string[]>([]);
                      const [selectedDate, setSelectedDate] = useState<number>(null);
                      const ticks = useRef<number[]>([]);
                      const { supplierId }: { supplierId: string } = useParams();

                    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 useBottomScrollListener has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function useBottomScrollListener<T extends HTMLDivElement>(
                      onBottom: () => void,
                      scrollref?: MutableRefObject<HTMLDivElement | null>,
                      options?: {
                        offset?: number;
                    Severity: Minor
                    Found in client/src/hooks/scroll/index.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 ContextualLegendItem has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const ContextualLegendItem = ({ layer }: ContextualLegendItemProps) => {
                      const dispatch = useAppDispatch();
                    
                      const { isFetching: areLayersLoading } = useContextualLayers();
                      const { isLoading: isLoadingData } = useContextualLayer(layer.id);

                    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 InterventionPhrase has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const InterventionPhrase: React.FC<InterventionPhraseProps> = ({ intervention, short = false }) => {
                      const year = useMemo(() => <strong>{intervention.startYear}</strong>, [intervention.startYear]);
                    
                      const materials = useMemo(
                        () => <strong>{intervention.replacedMaterials[0].name}</strong>,
                    Severity: Minor
                    Found in client/src/containers/interventions/phrase/component.tsx - 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 populateValuesRecursively has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      private populateValuesRecursively(
                        entity: ActualVsScenarioImpactTableRows,
                        entityDataMap: Map<
                          string,
                          Map<number, ActualVsScenarioImpactTableRowsValues>
                    Severity: Minor
                    Found in api/src/modules/impact/comparison/actual-vs-scenario.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 buildQuery has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      buildQuery(): Query {
                        if (this.dto?.supplierIds) {
                          this.queryBuilder.andWhere(
                            `${EUDRAlertsFields.supplierId} IN (:...supplierIds)`,
                            {

                    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 postProcessYearIndicatorData has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      private postProcessYearIndicatorData(
                        rangeOfYears: number[],
                        lastYearWithData: number,
                        entityMap: Map<string, Map<number, ImpactTableRowsValues>>,
                      ): Map<number, number> {
                    Severity: Minor
                    Found in api/src/modules/impact/impact.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 validate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      validate(addressInput: string, args: ValidationArguments): boolean {
                        if (
                          (args.object as SourcingDataExcelValidator).location_type ===
                            LOCATION_TYPES.UNKNOWN ||
                          (args.object as SourcingDataExcelValidator).location_type ===

                    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 validateDTOs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      private async validateDTOs(
                        dtoLists: SourcingDataDTOs,
                      ): Promise<void | Array<ErrorConstructor>> {
                        const validationErrorArray: {
                          line: number;
                    Severity: Minor
                    Found in api/src/modules/import-data/eudr/eudr.import.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 aggregateFlows has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function aggregateFlows<F>(flows: F[], flowAccessors: FlowAccessors<F>): AggregateFlow[] {
                      // Sum up flows with same origin, dest
                      const byOriginDest = nest<F, AggregateFlow>()
                        .key(flowAccessors.getFlowOriginId)
                        .key(flowAccessors.getFlowDestId)
                    Severity: Minor
                    Found in cookie-traceability/src/lib/flowmap/data/FlowMapSelectors.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

                    Severity
                    Category
                    Status
                    Source
                    Language