I have been investigating adding some rules and checks to CppCheck to check some rules relating to having correctly formatted comments in the right places in code. I tried to make it so that comments were not removed by simplecpp and the CppCheck preprocessor so I could add a new class of rules/checks, but found that I had to make more changes that I expected fairly deep in the codebase. Would you be interested in a pull request to enable this functionality?
The checks I am interested in adding are for rules like all 'magic numbers' must be followed by a comment that explains what the number is.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I guess you have seen that the comments are saved in the dump files? In the "raw" token list.
Would you be interested in a pull request to enable this functionality?
Feel free to publish your changes. However I can't guarantee I will merge it if there is no "use".
The checks I am interested in adding are for rules like all 'magic numbers' must be followed by a comment that explains what the number is.
That sounds like a good idea. However it might belong better in a addon than in core Cppcheck. But it depends on what the noise ratio and acceptance ratio for this rule would be. It's common practice that magic numbers are avoided. Do you know if some official coding lines say that comments should be used (that is not required but would help)?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I have been investigating adding some rules and checks to CppCheck to check some rules relating to having correctly formatted comments in the right places in code. I tried to make it so that comments were not removed by simplecpp and the CppCheck preprocessor so I could add a new class of rules/checks, but found that I had to make more changes that I expected fairly deep in the codebase. Would you be interested in a pull request to enable this functionality?
The checks I am interested in adding are for rules like all 'magic numbers' must be followed by a comment that explains what the number is.
I guess you have seen that the comments are saved in the dump files? In the "raw" token list.
Feel free to publish your changes. However I can't guarantee I will merge it if there is no "use".
That sounds like a good idea. However it might belong better in a addon than in core Cppcheck. But it depends on what the noise ratio and acceptance ratio for this rule would be. It's common practice that magic numbers are avoided. Do you know if some official coding lines say that comments should be used (that is not required but would help)?
The changes include some small changes to simplecpp. Should I include them in the pull request or make a separate one in that repo?
Good question. I guess that it would be easier to keep this together if there is a single PR in the cppcheck repo. So feel free to create a single PR.