Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic tool for checking code conventions for C/C++ [closed]

We have students submit exercises in a course while they have to adhere to some code conventions. For example, functions names should be in camelCase. Function length should not exceed 50 lines (The tasks are simple enough to divide) etc. I'm looking for a tool that can automatically check that for C/C++ (Both are needed). That is, I would like the tool to complain when something is wrong so the student can fix it. So far I've been unable to find something that fits well. If the thing is open source and can be easily configured to our needs that will be o.k.

like image 343
Shiroko Avatar asked Jan 11 '12 21:01

Shiroko


People also ask

Which tool is used for automatic coding standard verification?

As the organization moves to an agile software development process that values the use of automation, an automated static analysis tool for C++ is necessary to identify standards violations.

Which is a type of C C++ static code analysis tool?

CppDepend is a commercial static code analysis tool for C++. It can complement other static code analysis tools quite easily as it focuses on analyzing and visualizing the code base architecture (for example, whether it is layered correctly, dependencies-wise), rather than on revealing errors.

Which tool is best suited for use by developers and provides static analysis on their code?

#1) PVS-Studio. Best for not only for finding typos, dead code, but also potential vulnerabilities. A SAST solution that supports integration into popular IDEs CI/CD and other platforms. PVS-Studio is a static code analyzer that detects errors in C, C++, C#, and Java code.


2 Answers

You can use the unix tool indent to force some C coding style.

See

man 1 indent

when it is installed.

like image 84
ouah Avatar answered Oct 14 '22 21:10

ouah


QA-CPP might help here. It's been over a year since I used it but you can configure it to do that sort of thing.

You might want to give the guys at Programming Research a call and check if you can do that.

However the question remains why? If my lecturer started berating me for code style over functionality I would think he had a screw loose. As someone one who has gone through the University system you should be preparing them for working in the real world - heaven knows the stuff I see coming through now leave a lot to be desired.

like image 38
graham.reeds Avatar answered Oct 14 '22 21:10

graham.reeds