space after pointer, but the variable isn't a pointer
andreyvdl opened this issue · 1 comments
andreyvdl commented
Describe the bug
The norminette detects a line with multiplication as a pointer being de-referenced
Erroneous code
float cost_y_ray_distance(float *x, float *y, float tangent, float rayAng)
{
float off[2];
float ray[2];
if (rayAng > M_PI && rayAng < 2 * M_PI)
{
ray[H] = ((int)(g_player_y / SIZE) * SIZE) - 0.0001;
ray[W] = (g_player_y - ray[H]) * tangent + g_player_x;
off[H] = -SIZE;
off[W] = -off[H] * tangent;
}
if (rayAng < M_PI && rayAng < 3 * M_PI / 2)
{
ray[H] = ((int)(g_player_y / SIZE) * SIZE) + SIZE;
ray[W] = (g_player_y - ray[H]) * tangent + g_player_x;
off[H] = SIZE;
off[W] = -off[H] * tangent;
}
if (rayAng == 0 || rayAng == (float)M_PI)
{
ray[W] = g_player_x;
ray[H] = g_player_y;
}
update_distance(x, y, ray, off);
return (pythagoras(g_player_x, g_player_y, ray[W], ray[H]));
}
Additional infos
- OS: Ubuntu 20.04.6 LTS
- python3 --version: 3.8.10
- norminette -v: 3.3.52
Additional context
this is how the norminette is detecting
cub.c - IsAssignation In "ControlStructure" from "Function" line 196":
<TAB> <TAB> <IDENTIFIER=ray> <LBRACKET> <IDENTIFIER=H> <RBRACKET> <SPACE> <ASSIGN> <SPACE> <LPARENTHESIS> <LPARENTHESIS> <INT> <RPARENTHESIS> <LPARENTHESIS> <IDENTIFIER=g_player_y> <SPACE> <DIV> <SPACE> <IDENTIFIER=SIZE> <RPARENTHESIS> <SPACE> <MULT> <SPACE> <IDENTIFIER=SIZE> <RPARENTHESIS> <SPACE> <MINUS> <SPACE> <CONSTANT=0.0001> <SEMI_COLON> <NEWLINE>
...
Error: SPC_AFTER_POINTER (line: 196, col: 44): space after pointer
Error: SPC_AFTER_POINTER (line: 203, col: 44): space after pointer
Error: TOO_MANY_FUNCS (line: 217, col: 1): Too many functions in file
Error: SPC_AFTER_POINTER (line: 224, col: 44): space after pointer
Error: SPC_AFTER_POINTER (line: 231, col: 44): space after pointer
edit: i pasted the wrong lines
andreyvdl commented
For more context a friend of mine tried some way to solve this:
ray[H] = (int)g_player_y / SIZE * SIZE - 0.0001;
ray[H] = ((int)g_player_y / SIZE * SIZE) - 0.0001;
ray[H] = ((int)((g_player_y / SIZE)) * SIZE) - 0.0001;
All these solutions make the norm stop recognizing * SIZE
as a pointer.
I choose the third because the global is a double and i need to divide the value by SIZE before converting to int.
edit: typo