/libft_file_checker

Small tool to verify files of the libft project

Primary LanguagePython

42-tool

Description

This tool was developed to help 42 students to speed up boring checkings like missing files or wrong function prototypes in the first project of the Common Core, libft. At the time of the first launch (November 11th, 2022), the tool was built using the most up-to-date version of the subject found so far on intra.

This is great, you mind if I use your code?

You are free to fork the repository and study/modify/test the code on your own. However, I would really appreciate it if you could text me on Slack (ncarvalh) whenever you find a bug or you have a suggestion, so I can properly introduce hotfixes or deploy some quality-of-life patches that can benefit the 42 community in general.

Is there any software required?

If you're planning on running the tool in the 42 clusters, you can skip this section.

In order to correctly execute the tool, you must:

  • have Python installed;
  • have either Ubuntu or WSL on your computer;
  • install pip ONLY IF there is a missing package that you might need to install manually (text me, otherwise I won't know);

Great, I managed to do it! What's next?

1. Fork/download the code from the repository to any path of your choice in your computer (the best would be to sit right next to your libft folder, like described below)

2. If your directory tree looks like this...

	│
	├── 42-tool (this directory)
	├── libft 	(your repository)
	│
	...

then you can skip this step. Otherwise, you must change the "path" variable inside the utils.py file. It should look something like this:

	import os
	import copy
	import random
	import subprocess

	from colorama import Style
	from colorama import Fore

	# INSERT YOUR PATH HERE, INSIDE QUOTES
	path = '../libft/'

	...

3. If you reached this step, you can finally execute it! Because the 'brain' of the tool was built on Python, there is no need for compilation and binary files generation (unlike C). Just open a terminal inside this directory's folder and run the make command:

make

The Makefile was configured to pull updates from the repository, so its ok to take a while to display the menu. It should prompt you with something similar to this:

Main Menu
image

You should press the char that corresponds to the option you want to run and press ENTER when you're done.

Can you give me a quick tour about the features and how they work?

Sure!

1. Check for forbidden files

It prints out any extraneous files/folders your repository contains. Here's an example:

Good Example Bad Example
image image

2./3. Check filenames for Mandatory/Bonus files

It prints out the result of checking if every Mandatory/Bonus part file was delivered. Unless you chose the last option, you can chose to run this parts separately, since the Bonus part is optional. Here's an example of possible outputs:

Good Example Bad Example
image image

|

4. Run the Norminette

You all know her. You all know how she looks like. I don't think I need an image for this one (for now...).

5./6. Look for incorrect function prototypes in '.c'/'libft.h' files

Like 2 and 3, this two can be done separately, not because they are not mandatory (because both are), but mostly due to modularity. You don't need to go through all the correct parts if you want a specific one. Both files might generate a results.log file if there are mismatching prototypes. Here are the possible results for a prototype:

  • In '.c' files:
    • [CORRECT] - Your prototype matches the parser's
    • [MISSING] - The parser found the file, but not the prototype (this one is still in the works to improve)
    • [MISMATCHING] - The function name was found but the whole prototype doesn't match the expected one
    • [FILE NOT DELIVERED] - That one is pretty straight forward
  • In 'libft.h':
    • [CORRECT] - The same
    • [UNKNOWN] - It found a strange prototype
    • [MISMATCHING] - The same
    • [MISSING] - The same
    • [FILE NOT DELIVERED] - The same

NOTE: the variables in your prototypes should be named after the ones in the manual. Even a single different letter will trigger the MISMATCHING flag in the parsing of a prototype.

Parsing '.c' files Parsing 'libft.h' file
image image

7. Full run

Runs all of the above.

Will there be more features?

Definitely! I intend to integrate more functionalities as I implement them, like analysing what and how the Makefile is compiling, do unit tests, upgrade the current features, normalize the UI and, of course, integrate good suggestions. Everytime I release a new patch or hotfix, I'll be deploying a new release, so make sure you check it!

Author

Nuno Jesus, 42 Porto, ncarvalh