Vizzuality/landgriffon

View on GitHub

Showing 438 of 1,408 total issues

Function processImpactDataWithScenario has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  private static processImpactDataWithScenario(
    dataForImpactTableWithScenario: ImpactTableData[],
  ): ImpactTableData[] {
    // Separate the data into different groups depending on whether data is from a scenario or not
    const actualData: Map<string, ImpactTableData> = new Map();
Severity: Minor
Found in api/src/modules/impact/impact.service.ts - About 35 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 getTrees has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  async getTrees(
    supplierTreeOptions: GetSupplierTreeWithOptions,
  ): Promise<Supplier[]> {
    if (supplierTreeOptions.withSourcingLocations) {
      if (supplierTreeOptions.originIds) {
Severity: Minor
Found in api/src/modules/suppliers/suppliers.service.ts - About 35 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 processDataForComparison has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  static processDataForComparison(
    impactTableData: ImpactTableData[],
  ): ActualVsScenarioImpactTableData[] {
    // Separate the data into different maps depending on whether data is from a scenario or not
    const actualData: Map<string, ActualVsScenarioImpactTableData> = new Map();
Severity: Minor
Found in api/src/modules/impact/base-impact.service.ts - About 35 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 getFromArrayAndParsedString has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  static getFromArrayAndParsedString<T>(
    arrayProperty: string,
    stringProperty?: string,
    defaultValue?: T,
  ): (T | string)[] {
Severity: Minor
Found in api/src/utils/app.config.ts - About 35 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 intercept has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  async intercept(
    context: ExecutionContext,
    next: CallHandler,
  ): Promise<Observable<any>> {
    if (this.scenarioAcl.isUserAdmin()) {

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

  private async createSourcingLocationDTOFromData(
    sourcingLocationData: Record<string, any>,
    sourcingLocationGroupId?: string,
  ): Promise<CreateSourcingLocationDto> {
    const sourcingLocationDto: CreateSourcingLocationDto =
Severity: Minor
Found in api/src/modules/import-data/sourcing-data/dto-processor.service.ts - About 35 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 Ranking has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const Ranking: React.FC<RankingProps> = ({ ingredientId, onTradingFlowChange }) => {
  const [currentTradingFlow, setCurrentTradingFlow] = useState<CountryTrade | null>(null);
  const ingredient = useMemo<Ingredient>(
    () => INGREDIENTS.find((i) => i.id === ingredientId) || INGREDIENTS[0],
    [ingredientId],
Severity: Minor
Found in cookie-traceability/src/components/ranking/component.tsx - About 35 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 Header has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const Header: React.FC = () => {
  const [open, setOpen] = useState(false);

  const { scrollDirection } = useScrollDirection();
  const prevDirection = useRef<string | number>(0);
Severity: Minor
Found in marketing/src/containers/header/component.tsx - About 35 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 too many return statements within this function.
Open

  return param;
Severity: Major
Found in client/src/store/index.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return true;
    Severity: Major
    Found in cookie-traceability/src/lib/flowmap/data/FlowMapSelectors.ts - About 30 mins to fix

      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

      Severity
      Category
      Status
      Source
      Language