uncrustify: getting rid of "comment after function of size" (mod_add_long_function_closebrace_comment)

StackOverflow https://stackoverflow.com/questions/16262992

Question

I ran uncrustify with "comment after function of size" set to a very small value. Now practically every function has a comment like this:

-(void) createBackgroundGradient
{
    ...
} /* createBackgroundGradient */

I can't seem to find a way to remove this trailing function comment. Changing the value of the parameter to only add comments to functions of large size does not remove the already existing comment for smaller functions.

Is it even possible to remove the post-function comments with uncrustify? If so, what would a (safe) Xcode regex need to look like if I wanted to do a search & replace in all project files?

Was it helpful?

Solution

# If a function body exceeds the specified number of newlines and doesn't have a comment after
# the close brace, a comment will be added.

mod_add_long_function_closebrace_comment = 0

Just keep this guy 0.

As for removing, you'd have to use refactoring tools. I can show you how to do that in Vim:

:%s/^\s*}\zs\s*\/\*.*\*\///g

In general, using classical (Perl) regular expression syntax, I'd do the following:

  • Search: (^\s*})\s*\/\*.*\*\/\s*
  • Replace: \1

If capture groups (such as \1 above) are supported by XCode regular expression engine, then it should work just fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top