Vizzuality/landgriffon

View on GitHub

Showing 1,408 of 1,408 total issues

Function DataUploadError has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const DataUploadError: React.FC<DataUploadErrorProps> = ({ task }) => {
  const [open, setOpen] = useState(true);
  const updateTask = useUpdateTask();
  const { data: profile, isLoading: profileIsLoading } = useProfile();

Severity: Minor
Found in client/src/containers/admin/data-upload-error/index.tsx - About 25 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 Input has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  ({ className, error, icon, type = 'text', unit, showHint = true, ...inputProps }, ref) => (
    <>
      <div className={classnames('relative rounded-md shadow-sm', className)}>
        {icon && (
          <div className="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
Severity: Minor
Found in client/src/components/forms/input/component.tsx - About 25 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 setTooltipData has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    setTooltipData: (state, action: PayloadAction<TooltipData>) => {
      const exists = !!state.tooltipData.find(({ id }) => action.payload.id === id);
      // Remove tooltip is value is undefined but not zero
      if (exists && !action.payload.value && action.payload.value !== 0) {
        return {
Severity: Minor
Found in client/src/store/features/analysis/map.ts - About 25 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 AdminEditTargetModal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const AdminEditTargetModal: React.FC<EditTargetModalProps> = ({ title, open, onDismiss }) => {
  const { data, isLoading } = useSourcingRecordsYears();
  const { data: targets } = useTargets();

  const [selectedOption, setSelectedOption] = useState<Option<number>>(null);
Severity: Minor
Found in client/src/containers/admin/edit-target-modal/component.tsx - About 25 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 nominatim_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def nominatim_request(params, request_type="search", pause=1, error_pause=60):
    """
    Send a HTTP GET request to the Nominatim API and return JSON response.
    Parameters
    ----------
Severity: Minor
Found in data/notebooks/Lab/processing/utils.py - About 25 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 open_clean has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def open_clean(file):
    # Define the units available for conversion
    units_to_tonnes = {"100 g/An": 100000, "100 mg/An": 1000000}

    # Open the file
Severity: Minor
Found in data/preprocessing/farm_ghg/preprocess_faostats.py - About 25 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 Pagination has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const Pagination: React.FC<PaginationProps> = ({
  className,
  currentPage,
  isLoading = false,
  onPageChange,
Severity: Minor
Found in client/src/components/table/pagination/component.tsx - About 25 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 buildTags has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const buildTags = ({ title, titleTemplate, defaultTitle }: TitleTemplateProps) => {
  const tagsToRender: React.ReactNode[] = [];

  if (titleTemplate) {
    defaults.titleTemplate = titleTemplate;
Severity: Minor
Found in client/src/utils/titleTemplate.tsx - About 25 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 CustomTooltip has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const CustomTooltip: React.FC<CustomTooltipProps> = ({ payload }) => {
  const { comparisonMode } = useAppSelector(scenarios);
  const tooltipData = uniqBy(payload, 'stroke');
  // We will assume that actual-data is the first item and the scenario is the second one
  const baseValue = tooltipData[0]?.value;

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

const AdminDataPage: React.FC = () => {
  const { push, query } = useRouter();
  const [sorting, setSorting] = useState<SortingState>([]);
  const { data: session } = useSession();
  const { data: task } = useLasTask();
Severity: Minor
Found in client/src/containers/admin/data-table/index.tsx - About 25 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 AdminDataPage has a Cognitive Complexity of 6 (exceeds 5 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 25 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 getAdminRegionDescendants has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  async getAdminRegionDescendants(
    adminRegionIds: string[],
    options?: { fullEntities?: boolean; treeResponse?: boolean },
  ): Promise<any> {
    // using type casting not to search for and r
Severity: Minor
Found in api/src/modules/admin-regions/admin-regions.service.ts - About 25 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 getContextualLayerH3 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  async getContextualLayerH3(
    contextualLayerId: string,
    resolution?: number,
    year?: number,
  ): Promise<{
Severity: Minor
Found in api/src/modules/contextual-layers/contextual-layers.service.ts - About 25 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 addEntityFiltersToQuery has a Cognitive Complexity of 6 (exceeds 5 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 25 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 geoCodeSourcingLocation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  async geoCodeSourcingLocation(
    locationInfo: locationInfo,
  ): Promise<SourcingLocation> {
    let geoCodedSourcingLocation: Partial<SourcingData> = {};
    if (locationInfo.locationType === LOCATION_TYPES.UNKNOWN) {
Severity: Minor
Found in api/src/modules/geo-coding/geo-coding.service.ts - About 25 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 getDataForImpactTable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  getDataForImpactTable(
    impactTableDto: AnyImpactTableDto,
    entities: ImpactTableEntityType[],
  ): Promise<ImpactTableData[]> {
    if (entities.length) {
Severity: Minor
Found in api/src/modules/impact/base-impact.service.ts - About 25 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 addOrganisationalEntityFilters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  private addOrganisationalEntityFilters(
    baseImpactMapFilters: BaseImpactMapFiltersType,
    queryBuilder: { subQueryBuilder: SelectQueryBuilder<any> },
  ): SelectQueryBuilder<any> {
    const {
Severity: Minor
Found in api/src/modules/h3-data/h3-data.repository.ts - About 25 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 populateValuesRecursively has a Cognitive Complexity of 6 (exceeds 5 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 25 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 createIndicatorRecordsBySourcingRecords has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  async createIndicatorRecordsBySourcingRecords(
    sourcingData: {
      sourcingRecordId: string;
      geoRegionId: string;
      materialId: string;
Severity: Minor
Found in api/src/modules/indicator-records/services/impact-calculator.service.ts - About 25 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 defaultMessage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  defaultMessage(args: ValidationArguments): string {
    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

Severity
Category
Status
Source
Language