Vizzuality/landgriffon

View on GitHub

Showing 438 of 1,408 total issues

Function baseQueryExtend has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    const baseQueryExtend = (baseQuery: SelectQueryBuilder<any>): void => {
      //Having a scenarioId present as an argument, will change the query to include
      // *all* indicator records of the interventions pertaining to that scenario (both
      // the CANCELLED and REPLACING records)
      if (dto.scenarioId) {
Severity: Minor
Found in api/src/modules/h3-data/h3-data.repository.ts - About 1 hr to fix

    Function validate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Function validate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

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

        Function Video has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const Video: React.FC = () => {
          const videoRef = useRef<HTMLVideoElement>();
          const { ref, inView } = useInView();
        
          useEffect(() => {
        Severity: Minor
        Found in marketing/src/containers/about/video/component.tsx - About 1 hr to fix

          Function buildQueryForImport has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            buildQueryForImport(nameCodes: INDICATOR_NAME_CODES[]): {
              params: string;
              query: string;
            } {
              const importQueryFields: string[] = [

            Function open_clean has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def open_clean(file, data_type):
                # Define the units available for conversion
                units_to_tonnes = {"100 g/An": 100000, "100 mg/An": 1000000, "LSU/ha": 1}
            
                # Open the file
            Severity: Minor
            Found in data/preprocessing/livestock_processed/preprocess_faostats_ha_prod.py - About 55 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 ComparisonCell has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            const ComparisonCell: React.FC<ComparisonCellProps> = ({
              value,
              scenarioValue,
              absoluteDifference,
              percentageDifference,

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

            export function getColors(
              diffMode: boolean,
              schemeKey: string | undefined,
              darkMode: boolean,
              fadeEnabled: boolean,
            Severity: Minor
            Found in cookie-traceability/src/lib/flowmap/data/colors.ts - About 55 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 filterMaterialTree has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              static filterMaterialTree(root: Material): Material[] {
                let result: Material[] = [];
                if (!root.materialToH3s || root.materialToH3s.length === 0) {
                  if (root.children) {
                    root.children.forEach((child: Material) => {
            Severity: Minor
            Found in api/src/modules/materials/materials.service.ts - About 55 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 getFlowMagnitudeExtent has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              getFlowMagnitudeExtent(
                state: FlowMapState,
                props: FlowMapData<L, F>,
              ): [number, number] | undefined {
                if (state.settingsState.adaptiveScalesEnabled) {
            Severity: Minor
            Found in cookie-traceability/src/lib/flowmap/data/FlowMapSelectors.ts - About 55 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 insert_to_h3_master_table has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def insert_to_h3_master_table(
            Severity: Major
            Found in data/h3_data_importer/raster_folder_to_h3_table.py - About 50 mins to fix

              Function main has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def main(folder: Path, table: str, data_type: str, dataset: str, year: int, h3_res: int, thread_count: int):
              Severity: Major
              Found in data/h3_data_importer/raster_folder_to_h3_table.py - About 50 mins to fix

                Function insert_to_h3_data_and_contextual_layer_tables has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def insert_to_h3_data_and_contextual_layer_tables(
                Severity: Major
                Found in data/h3_data_importer/utils.py - About 50 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(eudrDetail);
                  Severity: Minor
                  Found in client/src/containers/analysis-eudr-detail/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

                  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
                        Severity
                        Category
                        Status
                        Source
                        Language