Repository: 42school/norminette

Issue #383: Exception when #include is not followed by a space
Created: 2023-06-23T09:44:00Z
Describe the bug
When the #include is not followed by a space norminette throws an exception
Erroneous code
Having a test.c file with #include<unistd.h> throws the following error:

Traceback (most recent call last):
File "/usr/local/bin/norminette", line 8, in 
sys.exit(main())
File "/usr/local/lib/python3.10/dist-packages/norminette/main.py", line 128, in main
registry.run(context, source)
File "/usr/local/lib/python3.10/dist-packages/norminette/registry.py", line 65, in run
ret, jump = self.run_rules(context, rule)
File "/usr/local/lib/python3.10/dist-packages/norminette/registry.py", line 43, in run_rules
self.run_rules(context, self.rules[r])
File "/usr/local/lib/python3.10/dist-packages/norminette/registry.py", line 32, in run_rules
rule.run(context)
File "/usr/local/lib/python3.10/dist-packages/norminette/rules/check_preprocessor_include.py", line 47, in run
while tkns[i].type != "NEWLINE" and i < len(tkns) - 1:
IndexError: list index out of range

Additional infos

OS: Ubuntu 22.04.1
python --version: 3.10.6
norminette -v: 3.3.52

Additional context
Add any other context about the problem here.

Duplicate issue #397: [CRASH] check_preprocessor_include
Created: 2023-06-29T13:09:43Z
Describe the bug
When you forget to put a space between #include and "lib.h" a crash occurs in the check_preprocessor_include.py
Erroneous code
Traceback (most recent call last):
  File "/home/zekao/miniconda3/bin/norminette", line 8, in <module>
    sys.exit(main())
  File "/home/zekao/miniconda3/lib/python3.9/site-packages/norminette/__main__.py", line 128, in main
    registry.run(context, source)
  File "/home/zekao/miniconda3/lib/python3.9/site-packages/norminette/registry.py", line 65, in run
    ret, jump = self.run_rules(context, rule)
  File "/home/zekao/miniconda3/lib/python3.9/site-packages/norminette/registry.py", line 43, in run_rules
    self.run_rules(context, self.rules[r])
  File "/home/zekao/miniconda3/lib/python3.9/site-packages/norminette/registry.py", line 32, in run_rules
    rule.run(context)
  File "/home/zekao/miniconda3/lib/python3.9/site-packages/norminette/rules/check_preprocessor_include.py", line 47, in run
    while tkns[i].type != "NEWLINE" and i < len(tkns) - 1:
IndexError: list index out of range
Additional infos

OS: Ubuntu 22.04.2 LTS
python --version: 3.9.12
norminette -v: norminette 3.3.52

/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   test.c                                             :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: emaugale <emaugale@student.42.fr>          +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2021/07/24 21:39:21 by emaugale          #+#    #+#             */
/*   Updated: 2023/06/29 15:02:03 by emaugale         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include"lib.h"

int	main(void)
{
	return (1);
}

Closing comment (2023-06-30T08:02:00Z): Duplicate of #383