Giter Club home page Giter Club logo

c_check's Introduction

c_check can be used to inspect C programs in introductory programing courses for features that either,

  • a student should not be using generally (e.g. goto), or
  • are not permitted for a specific exercises (perhaps array)

It can also:

  • detect incorrect indenting
  • warn if integer constants are used for ASCII codes , e.g 10 instead of '\n'
  • warn if functions like getchar are assigned to an int

Examples

$ c_check.py --not-permitted=global_variable,goto,static_local_variable \
            --not-recommended=ternary \
            --where-text="in COMP1511" \
            --extra-text="See the COMP1511 style guide at https://example.com"  \
            --warning=assign_getchar_char,integer_ascii_code,indenting \
            example.c
example.c:3:2 error: goto statement used - this is not permitted in COMP1511
	goto a;
    ^~~~~~
See the COMP1511 style guide at https://example.com

Students would normally run c_check via a wrapper script with settings appropriate for their course (example wrapper script here), e.g:

$ 1511_c_check example.c
example.c:3:2 error: goto statement used - this is not permitted in COMP1511
	goto a;
    ^~~~~~
See the COMP1511 style guide at https://example.com

Checkers

Available checkers include:

array check if array used (for exercises where ararys are not permitted)
assign_getchar_char check for common bug of getchar/fgetc/getc being assigned to char variable, e.g char c = getchar();
break check if break used
comma check if comma operator used
continue check if continue used
do_while check if do while used
global_variable check global variables used
goto check if goto used
indenting check indenting consistent with functions, and tabs/spaces not mixed within function
integer_ascii_code check integer constants not used for ASCII codes e.g. 10 instead of '
'
multiple_malloc check if malloc is called in more than 1 location (for exercises where this is not permitted)
non_char_array check for use of array other than char array (for exercises where this is not permitted)
static_local_variable check for use of static local variables
string_library check for use of functions from string.h (for exercises where this is not permitted)
switch check if switch used
ternary check for use of the ?: operator
union check if union used

Author

Andrew Taylor ([email protected])

Except help_cs50.py is almost entirely from https://github.com/cs50/help50-server/blob/master/helpers/clang.py

License

GPLv3

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.