Giter VIP home page Giter VIP logo

normatrix's Introduction

NorMatrix

check some norm for you

PyPI version python-version

windows+ubuntu+macos;3.9,3.10 NorMatrix Check

Codacy Badge

GitHub repo size GitHub language count GitHub top language GitHub last commit

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 pipy

With Pipy

1

  • if you want some "stable" version:
pip install normatrix
  • if you want the most update to date version:
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 :

echo $SHELL

if you are using bash shell (the echo print /something/bash):

echo alias normatrix=\"python3 -m normatrix\" >> $HOME/.bashrc

else if you are using zsh shell (the echo print /something/like/zsh):

echo alias normatrix=\"python3 -m normatrix\" >> $HOME/.zshrc

else if you are using fish shell (the echo print /something/like/fish):

abbr --add 'normatrix' 'python3 -m normatrix'

else handle this yourself bruh;

3

to update it, you just have to run

pip install -U normatrix

4

to uninstall it (sad), run

pip uninstall normatrix

from source

From source

1

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 :

echo $SHELL

if you are using bash shell (the echo print /something/bash):

echo alias normatrix=\"$PWD/main.py\" >> $HOME/.bashrc

else if you are using zsh shell (the echo print /something/like/zsh):

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

git pull

4

to uninstall it (sad) Delete the folder

Current Checks

  • 80 cols per line
  • space/tab alone (in a line)/(at the end of line)
  • two newline at end of file
  • two newline between function (between all buf chhhtt)
  • libc function call (pr welcome to add some libc function always banned)
  • nested branch more than 3 branch
  • no more than 20 lines per function
  • comma with no space after
  • end of parenthesis with a open curly bracket next ){
  • star char * like this char* buf
  • preprocessors indentations (#if.., #endif)
  • multiple statements
  • 5 functions per file
  • filename of source code only snake_case
  • no line break at end of file
  • 5+5 7/9 that need a space (but some false positiv goes in)
  • no space after [ and space before ]
  • header
  • #define in .c
  • 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
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
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)

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)

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 are

    PATH_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

{
    "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)
{
    "no-banned": ["memset"]
}
  • to ban my_printf (because you dont want to use it)
{
    "banned": ["my_printf"]
}
  • to no-banne *.o file (because you dont need this warning)
{
    "no-extension": ["*.o"]
}
  • to banne *.c file (because you want c file banned)
{
    "extension": ["*.c"]
}
  • to enable preview check by default
{
    "enable-preview": true
}

by default there are somthing like this:

{
    "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 file

but 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

example example1

state : NorMatrix Check

(N.B. : this workflow pass well, but it will not if you copy the code below)

  1. in the repo root :
mkdir .github
mkdir .github/workflows
echo '
name: NorMatrix Check

on: [push]

jobs:
  norm:
    runs-on: ubuntu-latest

    steps:
    - 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
  1. you can push the modification to github

Contribute

[more information on CONTRIBUTNG.md]

Alternatives

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
Xavier Mitault
apps/github-actions/
apps/github-actions
Mizu/
Mizu
mE0w/
mE0w
Christophe
Christophe CHHOR

normatrix's People

Contributors

christophechr avatar github-actions[bot] avatar mizurigit avatar romainpanno avatar saverio976 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

normatrix's Issues

Don't detect too many lines

Bug description
Don't detect too many line in my script.
The fct is 23 lines long bug got

file [giantman/src/giantman.c] n°4/100...
 -> yes: giantman/src/giantman.c

To Reproduce
The too many lines fct :

int main(int argc, const char *argv[])
{
    int fd = -1;
    char *buffer = NULL;
    off_t size = 0;
    int errorh = -1;

    if (error_handling(argc, argv) != 0)
        return 84;
    size = get_file_size(argv[1]);
    if (size == -1)
        return 84;
    if ((buffer = (char *)malloc(sizeof(char) * size)) == NULL)
        return 84;
    if ((fd = open(argv[1], O_RDONLY)) <= 0)
        return 84;
    if (read(fd, buffer, size) <= 0) {
        close(fd);
        free(buffer);
        return 84;
    }
    close(fd);
    errorh = manage_compress(my_getnbr(argv[2]), buffer);
    free(buffer);
    return errorh;
}

Expected behavior
It should detect it and print error.

file [giantman/src/giantman.c] n°4/100...
 -> nope: giantman/src/giantman.c ...

Desktop (please complete the following information):

  • OS: Linux Mint 20.3 Cinnamon
  • Version last

get negative 0 result

Describe the bug
the result for 0 is "-0"
hmmm

To Reproduce
have no error

Expected behavior
result is "0" and not "-0"

Desktop (please complete the following information):

  • OS: linux mint

Additional context
vs code terminal

normatrix don't like too long header

Describe the bug
detect an error when header have more than one line of description.
normatrix don't like header

To Reproduce
have a header with a two line description. or a header that is 7 line len.

Expected behavior
don't detect an error

Desktop (please complete the following information):

  • OS: linux mint

Additional context
vs code

NorMatrix don't like backslash

Describe the bug
Return error when use '' in c scripts.

Screen
normatrix_don't_like_backslash

To Reproduce
Use '' to go to the next line => give "maybe too many branch ?" and give "two spaces alone" for the first occurrence.
normatrix_error_exemple

Expected behavior
No error or an info.

Desktop (please complete the following information):

  • OS: Linux mint

Additional context
used with a my_putstr() to have a larger text.

PNG files detected as executables

The bug
When NorMatrix check if executable is created, its detect *.png files as executables files.

To Reproduce

  1. Place a png file on a folder
  2. Launch NorMatrix on it.

Expected behavior
Maybe just ignore PNG files ? I don't know if png are able to cause issues for Marvin, maybe just check if its name is on snake_case

Desktop:

  • OS: GNU/LINUX - Pop!_OS
  • Version [21.10]

detect operator in strings

Describe the bug
Normatrix detect operator like '/' in strings declaration.

To Reproduce

static const char str_help[] = "USAGE\n./asm file_name[.s]\n

get :

sources/main.c:26: bad space for operator: /
 -> nope: sources/main.c (2)

Expected behavior
should detect nothing

Desktop:

  • OS: Linux Mint 20.3 Cinnamon
  • Version 5.2.7

don't support 2 size array

When see "char **str'' -> "bad space for operator: * "

To Reproduce

  • create a two size array with "**"

Expected behavior
It should not stop on this issue.

Desktop (please complete the following information):

  • OS: Linux Mint 20.3 Cinnamon
  • Version: 5.2.7

Additional context
Used in github action.

&& considered as `bad space for operator &`

Examples

1:

code:

matrix[i][j] = (l[j] >= '0' && l[j] <= '9') ? l[j] - 48 : l[j];

got:

bad space for operator & (            matrix = (l >= & l <= ) ? l - 48 : l;)

2:

code:

if (nb > 0 && nb <= 9) {

got:

bad space for operator & (    if (nb > 0& nb <= 9) {)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.