42School / norminette

Official 42 norminette
MIT License
944 stars 139 forks source link

incorrect TOO_MANY_TAB #327

Open mjy9088 opened 2 years ago

mjy9088 commented 2 years ago

Describe the bug

incorrect TOO_MANY_TAB error

Erroneous code

/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_simple_map_dynamic_get.c                        :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: Juyeong Maing <jmaing@student.42seoul.kr>  +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2022/06/06 13:23:42 by Juyeong Maing     #+#    #+#             */
/*   Updated: 2022/06/06 13:33:10 by Juyeong Maing    ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "ft_simple_map_internal.h"

bool    ft_simple_map_dynamic_get(
    t_ft_simple_map_dynamic *self,
    const void *key,
    size_t key_length,
    void **out
)
{
    if (!key_length)
    {
        *out = self->value;
        return (!*out);
    }
    if (!self->array[*((unsigned char *)key)])
        return (true);
    return (
        ft_simple_map_dynamic_get(
            self->array[*((unsigned char *)key)],
            &((unsigned char *)key)[1],
            key_length - 1,
            out
        )
    );
}
src/ft_simple_map_dynamic_get.c: Error!
Error: TOO_MANY_TAB         (line:  33, col:  13):      Extra tabs for indent level
Error: TOO_MANY_TAB         (line:  34, col:  13):      Extra tabs for indent level
Error: TOO_MANY_TAB         (line:  35, col:   9):      Extra tabs for indent level

Additional infos

Additional context

norminette doesn't complain with code below:

    return (
        ft_simple_map_dynamic_get(
            self->array[*((unsigned char *)key)],
            &((unsigned char *)key)[1],
        key_length - 1,
        out
    )
    );

This bug can be circumvented by using (less readable) pointer arithmetic way

    return (
        ft_simple_map_dynamic_get(
            self->array[*((unsigned char *)key)],
            ((unsigned char *)key) + 1,
            key_length - 1,
            out
        )
    );
matthieu42Network commented 1 year ago

duplicate #277