Checking Code Quality

This guide covers how to check code quality using the python script provided.

The python script can be downloaded here: code_quality.py

To run: execute the script on command line with python3.7+ and provide the path to the folder you would like to check.

You may need to install the python library "regex" using the following command: pip3 install regex or pip install regex if the script is not able to install it for you. If running the program does not give any output, please uninstall and reinstall the regex library, as this can occur if you have an old version of the library.

Format of Execution:

python(or python3) code_quality.py path_to_folder 

Optional Flags: [-nn to disable numeric value check]

                [-nc to disable comment check] 

                [-ign_dirs dirName1 dirName2 ... to ignore certain folders] 

                [-ign_files fileName1 fileName2 ... to ignore certain files]

                [-long # to set long function line limit, default is 50]

Example:

python3 code_quality.py C:/Users/UserName/git > git.log

The above example will run on all projects contained in the git folder, and output to the file git.log in the same directory that the python script is being run from.

Example Output:

For each *.c file found that has at least 1 function in it, the path and filename for that file will be listed, followed by:

Comments, Numeric values, long functions, and possible global variables.

If no numeric values, long functions, or possible globals are found, they will not be listed. If the -nc flag is used when executing the python script, comments will be ignored and only files that have one of the other three elements will be listed.

Warning:

Running this script is not a substitute for checking the coding quality of your work yourself, and just because it does not catch some coding quality mistake in your code that does not guarantee the same error will be missed by the graders.

Basic Setup Guide

Open your terminal of choice on your operating system (Powershell recommended on Windows).

Check if python is installed by typing python, py, or python3. If none of these work, then you will need to install a version of python 3. On windows, you can do this from the Microsoft store quite easily.

Once you have python installed, navigate to the folder of the project you are planning to check by typing cd path. For example, cd C:\workspace10

Place the python script in that folder and run it by typing python code_quality.py .

> file.txt may be added (as in the example at the top of this page) to save the results to a file instead of showing it in the terminal.