Vizzuality/landgriffon

View on GitHub

Showing 1,408 of 1,408 total issues

Function DataUploader has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const DataUploader: React.FC<DataUploaderProps> = ({ variant = 'default', onUploadInProgress }) => {
  const [currentTaskId, setCurrentTaskId] = useState<Task['id']>(null);
  const router = useRouter();
  const uploadDataSource = useUploadDataSource();
  const lastTask = useLasTask();
Severity: Minor
Found in client/src/containers/uploader/index.tsx - About 45 mins 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 ZoomControl has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export const ZoomControl: React.FC<ZoomControlProps> = ({ className, mapId = 'default' }) => {
  const { [mapId]: mapRef } = useMap();
  const zoom = mapRef?.getZoom();
  const minZoom = mapRef?.getMinZoom();
  const maxZoom = mapRef?.getMaxZoom();
Severity: Minor
Found in client/src/components/map/controls/zoom/component.tsx - About 45 mins 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

Avoid deeply nested control flow statements.
Open

                    if dry_run:
                        print(contextuals_to_drop)
                        return
                    cursor.execute(
Severity: Major
Found in data/h3_data_importer/delete_h3_tables.py - About 45 mins to fix

    Function DatesRange has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const DatesRange = (): JSX.Element => {
      const dispatch = useAppDispatch();
      const {
        filters: { dates },
      } = useAppSelector(eudr);
    Severity: Minor
    Found in client/src/containers/analysis-eudr/filters/years-range/index.tsx - About 45 mins 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

    Avoid deeply nested control flow statements.
    Open

                        for table in tables_to_drop:
                            cursor.execute(f"DROP TABLE {table[0]}")
                    log.info(f"Deleted tables {', '.join(table[0] for table in tables_to_drop)}")
    Severity: Major
    Found in data/h3_data_importer/delete_h3_tables.py - About 45 mins to fix

      Function to_the_db has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def to_the_db(df: pd.DataFrame, table: str, data_type: str, dataset: str, year: int, h3_res: int):
      Severity: Minor
      Found in data/h3_data_importer/raster_folder_to_h3_table.py - About 45 mins to fix

        Function fix_invalid_geometries has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def fix_invalid_geometries(gdf):
            """
            Identify and fix invalid geometries in a GeoDataFrame.
        
            Parameters:
        Severity: Minor
        Found in data/preprocessing/unsustainable_water_use/preprocess_data.py - About 45 mins 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 storeToQueryParams has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export const storeToQueryParams = ({
          startYear,
          indicators,
          materials,
          businessUnits,
        Severity: Minor
        Found in client/src/hooks/h3-data/utils.ts - About 45 mins 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 ScenariosComponent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        const ScenariosComponent: React.FC<{ scrollref?: MutableRefObject<HTMLDivElement> }> = ({
          scrollref,
        }) => {
          const { query, push } = useRouter();
          const { scenarioId = ACTUAL_DATA.id } = query;
        Severity: Minor
        Found in client/src/containers/analysis-sidebar/component.tsx - About 45 mins 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 UserForm has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        const UserForm = ({ user, onSubmit, children }: UserFormProps) => {
          const roleOptions = Object.values(RoleName).map((role) => ({ label: role, value: role }));
        
          const {
            register,
        Severity: Minor
        Found in client/src/containers/edit-user/user-form.tsx - About 45 mins 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 saveListToTree has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          public async saveListToTree(
            importData: CreateDto[],
            pathKey: keyof CreateDto,
          ): Promise<Entity[]> {
            let rest: (CreateDto & WithExplodedPath)[] = importData.map(
        Severity: Minor
        Found in api/src/utils/tree.repository.ts - About 45 mins 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 parseTime has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export function parseTime(input: string | Date | undefined): Date | undefined {
          if (input != null) {
            if (input instanceof Date) {
              return input;
            }
        Severity: Minor
        Found in cookie-traceability/src/lib/flowmap/data/time.ts - About 45 mins 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 _getHighlightedObject has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          private _getHighlightedObject(info: Record<string, any>): HighlightedObject | undefined {
            const { index, sourceLayer } = info;
            if (index < 0) return undefined;
            if (sourceLayer instanceof FlowLinesLayer || sourceLayer instanceof AnimatedFlowLinesLayer) {
              const { lineAttributes } = this.state?.layersData || {};
        Severity: Minor
        Found in cookie-traceability/src/lib/flowmap/layers/FlowMapLayer.ts - About 45 mins 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 getColors has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          diffMode: boolean,
          schemeKey: string | undefined,
          darkMode: boolean,
          fadeEnabled: boolean,
          fadeAmount: number,
        Severity: Minor
        Found in cookie-traceability/src/lib/flowmap/data/colors.ts - About 45 mins to fix

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

            @ApiPropertyOptional({
              description:
                'Sort all the entities recursively by the impact value corresponding to the sortingYear',
            })
            @Type(() => Number)
          Severity: Major
          Found in api/src/modules/impact/dto/impact-table.dto.ts and 2 other locations - About 45 mins to fix
          api/src/modules/impact/dto/impact-table.dto.ts on lines 156..164
          api/src/modules/impact/dto/impact-table.dto.ts on lines 189..197

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 50.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              () =>
                apiService
                  .request({
                    method: 'GET',
                    url: '/suppliers',
          Severity: Major
          Found in client/src/hooks/suppliers/index.ts and 2 other locations - About 45 mins to fix
          client/src/hooks/eudr/index.ts on lines 135..142
          client/src/hooks/targets/index.ts on lines 58..65

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 50.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              () =>
                apiService
                  .request({
                    method: 'GET',
                    url: '/eudr/dates',
          Severity: Major
          Found in client/src/hooks/eudr/index.ts and 2 other locations - About 45 mins to fix
          client/src/hooks/suppliers/index.ts on lines 39..46
          client/src/hooks/targets/index.ts on lines 58..65

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 50.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              () =>
                apiService
                  .request({
                    method: 'GET',
                    url: '/targets',
          Severity: Major
          Found in client/src/hooks/targets/index.ts and 2 other locations - About 45 mins to fix
          client/src/hooks/eudr/index.ts on lines 135..142
          client/src/hooks/suppliers/index.ts on lines 39..46

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 50.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

            @ApiPropertyOptional({
              description:
                'Sort all the entities recursively by the absolute difference value corresponding to the sortingYear',
            })
            @Type(() => Number)
          Severity: Major
          Found in api/src/modules/impact/dto/impact-table.dto.ts and 2 other locations - About 45 mins to fix
          api/src/modules/impact/dto/impact-table.dto.ts on lines 128..136
          api/src/modules/impact/dto/impact-table.dto.ts on lines 156..164

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 50.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

            @ApiPropertyOptional({
              description:
                'Sort all the entities recursively by the absolute difference value corresponding to the sortingYear',
            })
            @Type(() => Number)
          Severity: Major
          Found in api/src/modules/impact/dto/impact-table.dto.ts and 2 other locations - About 45 mins to fix
          api/src/modules/impact/dto/impact-table.dto.ts on lines 128..136
          api/src/modules/impact/dto/impact-table.dto.ts on lines 189..197

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 50.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language