https://github.com/saverio976/normatrix
Python Script to check the Epitech Coding Style for the C Language
https://github.com/saverio976/normatrix
c-language epitech epitech-norme epitech-norme-checker norminette python python3
Last synced: 4 months ago
JSON representation
Python Script to check the Epitech Coding Style for the C Language
- Host: GitHub
- URL: https://github.com/saverio976/normatrix
- Owner: Saverio976
- License: mit
- Archived: true
- Created: 2021-10-31T23:35:16.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-31T10:30:07.000Z (over 2 years ago)
- Last Synced: 2024-10-29T09:10:10.396Z (7 months ago)
- Topics: c-language, epitech, epitech-norme, epitech-norme-checker, norminette, python, python3
- Language: Python
- Homepage: https://pypi.org/project/normatrix/
- Size: 768 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# NorMatrix
check some norm for you[](https://badge.fury.io/py/normatrix)

[](https://github.com/Saverio976/NorMatrix/actions/workflows/normatrix_check.yml)[](https://www.codacy.com/gh/Saverio976/NorMatrix/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Saverio976/NorMatrix&utm_campaign=Badge_Grade)



# Updates
- Project is moved to https://github.com/X-R-G-B/norma2
- not as good as this repo for now to detect errors, but pretty good good
- but updated with latest norm and new flag option (like explain a certain norm error (like C-01))## install
### with pipyWith Pipy
#### 1
- if you want some "stable" version:
```bash
pip install normatrix
```
- if you want the most update to date version:
```bash
pip install git+https://github.com/Saverio976/NorMatrix.git
```Now you can use it with `python3 -m normatrix` in your terminal
#### 2
And if you want to just write `normatrix` :
```bash
echo $SHELL
```
if you are using bash shell (the `echo` print `/something/bash`):
```bash
echo alias normatrix=\"python3 -m normatrix\" >> $HOME/.bashrc
```
else if you are using zsh shell (the `echo` print `/something/like/zsh`):
```bash
echo alias normatrix=\"python3 -m normatrix\" >> $HOME/.zshrc
```
else if you are using fish shell (the `echo` print `/something/like/fish`):
```bash
abbr --add 'normatrix' 'python3 -m normatrix'
```
else handle this yourself bruh;#### 3
to update it, you just have to run
```bash
pip install -U normatrix
```#### 4
to uninstall it (sad), run
```bash
pip uninstall normatrix
```### from source
From source
#### 1
```bash
git clone https://github.com/Saverio976/NorMatrix.git
cd NorMatrix
```
Now you can use it with `./path/to/folder/NorMatrix/main.py` in your terminal#### 2
And if you want to just write `normatrix` :
```bash
echo $SHELL
```
if you are using bash shell (the `echo` print `/something/bash`):
```bash
echo alias normatrix=\"$PWD/main.py\" >> $HOME/.bashrc
```
else if you are using zsh shell (the `echo` print `/something/like/zsh`):
```bash
echo alias normatrix=\"$PWD/main.py\" >> $HOME/.zshrc
```
else handle this yourself bruh;
#### 3
to update it, just go where you have cloned normatrix
run
```bash
git pull
```#### 4
to uninstall it (sad)
Delete the folder## Current Checks
- [x] 80 cols per line
- [x] space/tab alone (in a line)/(at the end of line)
- [x] two newline at end of file
- [x] two newline between function (between all buf chhhtt)
- [x] libc function call (pr welcome to add some libc function always banned)
- [x] nested branch more than 3 branch
- [x] no more than 20 lines per function
- [x] comma with no space after
- [x] end of parenthesis with a open curly bracket next `){`
- [x] star char `*` like this `char* buf`
- [x] preprocessors indentations (`#if..`, `#endif`)
- [x] multiple statements
- [x] 5 functions per file
- [x] filename of source code only snake\_case
- [x] no line break at end of file
- [x] 5+5 7/9 that need a space (but some false positiv goes in)
- [x] no space after [ and space before ]
- [x] header
- [x] #define in .c
- [x] make + check exe if the compiler add some banned function
- [ ] ...## doc
### (if you use pipy) python -m normatrix(if you use pipy) python -m normatrix
```bash
usage: python -m normatrix [-h] [--no-operators-pluggin] [--preview] [--conf] [--only-errors] [--no-fclean] [--link-line] [--tests-run]
[--output format]
[paths ...]The C Epitech Coding Style Norm Checker
positional arguments:
paths list of path to check (default: the current working directory)options:
-h, --help show this help message and exit
--no-operators-pluggin
remove the operators pluggin (because it print some false positiv for now)
--preview add some plugin that are added recently
--conf [deprecated][now it check always for the file] tells if you have a .normatrix config file
--only-errors print only bad files with errors
--no-fclean if you want normatrix dont do a "make fclean" at the end
--link-line to have the "link" to the file (in vscode terminal you can click it and it will open the file at the line of the error)
--tests-run run the unit tests for normatrix
--output format tell which output format to use [html, md, term_color, term_rich]; for html the file is normatrix-result.htlm; for md the
file is normatrix-result.md
```### (only from source) main.py
(only from source) main.py
```bash
usage: ./main.py [-h] [--no-operators-pluggin] [--preview] [--conf] [--only-errors] [--no-fclean] [--link-line] [--tests-run]
[--output format]
[paths ...]The C Epitech Coding Style Norm Checker
positional arguments:
paths list of path to check (default: the current working directory)options:
-h, --help show this help message and exit
--no-operators-pluggin
remove the operators pluggin (because it print some false positiv for now)
--preview add some plugin that are added recently
--conf [deprecated][now it check always for the file] tells if you have a .normatrix config file
--only-errors print only bad files with errors
--no-fclean if you want normatrix dont do a "make fclean" at the end
--link-line to have the "link" to the file (in vscode terminal you can click it and it will open the file at the line of the error)
--tests-run run the unit tests for normatrix
--output format tell which output format to use [html, md, term_color, term_rich]; for html the file is normatrix-result.htlm; for md the
file is normatrix-result.md
```### (only from source) exec.sh
(only from source) exec.sh
(this file exists only to keep compatibility to older version)
```bash
usage: ./main.py [-h] [--no-operators-pluggin] [--preview] [--conf] [--only-errors] [--no-fclean] [--link-line] [--tests-run]
[--output format]
[paths ...]The C Epitech Coding Style Norm Checker
positional arguments:
paths list of path to check (default: the current working directory)options:
-h, --help show this help message and exit
--no-operators-pluggin
remove the operators pluggin (because it print some false positiv for now)
--preview add some plugin that are added recently
--conf [deprecated][now it check always for the file] tells if you have a .normatrix config file
--only-errors print only bad files with errors
--no-fclean if you want normatrix dont do a "make fclean" at the end
--link-line to have the "link" to the file (in vscode terminal you can click it and it will open the file at the line of the error)
--tests-run run the unit tests for normatrix
--output format tell which output format to use [html, md, term_color, term_rich]; for html the file is normatrix-result.htlm; for md the
file is normatrix-result.md
```### (only from source) Makefile
(only from source) Makefile (deprecated)
(this file exists only to keep compatibility to older version)
(if you can, move to another choice)
```bash
USAGE:
make -C path/to/NorMatrix PATH_CHECK=$PWD
DESCRIPTION:
check the norm! in the current working directory
(call main.py)
ARGS:
-C path/to/NorMatrix run the makefile that is in path/to/NorMatrix
instead of the one where you arePATH_CHECK=$PWD check the norm in your current working
directory
```### configuration
you can now configure what functions are banned, and what are not,
you can now configure what extension file are banned, and what are not,all you have to do is put a file `.normatrix.json` where you execute `normatrix`
example with nothing banned and no preview (preview = not stable check) check
`.normatrix.json`
```json
{
"banned": [],
"no-banned": [],
"extension": [],
"no-extension": [],
"enable-preview": false
}
```just add inside `[]` the string of what you want
**other explanation with example**
other explanation with example
- to no-banne memset (because you can use it)
```json
{
"no-banned": ["memset"]
}
```
- to ban my_printf (because you dont want to use it)
```json
{
"banned": ["my_printf"]
}
```
- to no-banne \*.o file (because you dont need this warning)
```json
{
"no-extension": ["*.o"]
}
```
- to banne \*.c file (because you want c file banned)
```json
{
"extension": ["*.c"]
}
```
- to enable preview check by default
```json
{
"enable-preview": true
}
```by default there are somthing like this:
```json
{
"banned": ["printf", "memset", "strcpy", "strcat", "calloc"],
"no-banned": [],
"extension": ["*.a", "*.o", "*.so", ".gch", "*~", "*#", "*.d"],
"no-extension": [],
"enable-preview": false
}
```
this configuration will be added even if you add a `.normatrix.json` filebut if you want to remove `*.o`, just add it to the `no-extension`
or you can put `*.o` in a `.gitignore`
it will remove it from the default
## Run as a **github workflow**
this is not the latest normatrix but :
link : [link](https://github.com/Saverio976/NorMatrix/runs/6242624947?check_suite_focus=true)

state : [](https://github.com/Saverio976/NorMatrix/actions/workflows/normatrix_check.yml)
(N.B. : this workflow pass well, but it will not if you copy the code below)
1. **in the repo root :**
```bash
mkdir .github
mkdir .github/workflows
echo '
name: NorMatrix Checkon: [push]
jobs:
norm:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v2- name: set up python
uses: actions/setup-python@v2
with:
python-version: '3.9'- name: clone NorMatrix
run: pip install git+https://github.com/Saverio976/NorMatrix.git- name: NorMatrix
run: python3 -m normatrix --only-errors
' > .github/workflows/normatrix_check.yml
```
2. **you can push the modification to github**## Contribute
***[more information on [CONTRIBUTNG.md](https://github.com/Saverio976/NorMatrix/blob/main/CONTRIBUTING.md)]***## Alternatives
- [crNormz](https://github.com/CustomEntity/crNormz)
- [Abricot-Norminette](https://github.com/Just1truc/Abricot-Norminette)
- [jankun_norme](https://github.com/LeoSarochar/jankun_norme)
- [Bubulle-Norminette](https://github.com/aureliancnx/Bubulle-Norminette)
- [NormEZ](https://github.com/ronanboiteau/NormEZ)## Thanks
- chempa for his sample of file that dont follow the epitech norm
- and invisble testers that says **"bha baah normatrix have a bug"**## Contributors
Xavier Mitault
apps/github-actions
Mizu
mE0w
Christophe CHHOR