Doxygen : Display warning for undocumented method - documentation

i've activated warnings with doxygen
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = YES
But undocumented methods like this one:
void AnimationManager::setAnimationTimeStep( double timeStep )
{
...
}
Do not throw any warning during doxygen generation.
Is there any way to display warning in this situation ?
Same problem with undocumented return , for example
/**
* #brief brief description
*/
bool AnimationManager::hasAnimationTimeStep( )
{
...
}
Does not throw warning for undocumented return

When you are missing warnings that you would otherwise expect, check whether EXTRACT_ALL is set to YES.
From the commented version of the doxyfile:
# Note: This will also disable the warnings about undocumented members that are
# normally produced when WARNINGS is set to YES.
Using EXTRACT ALL can be useful for a first pass or to extract something from a non-doxygenned source, but in general it's a good idea to aim to be able to turn this off and thus be able to get the warnings that refine the parts that you actually need documented.

Related

Kotlinpoet: Ommitting redundant `public` modifier from generated types and properties

Is there any way to omit the redundant public modifier from types and properties generated via
KotlinPoet's TypeSpec.Builder and PropertySpec.Builder respectively?
Egor's answer above is the correct one. There is no way to omit redundant public modifiers in KotlinPoet, and there is good reason for that.
However, all those (unnecessary in my case) warnings were getting to my nerves and I had to find some way to get rid of them. What I finally came up with, is to suppress them in KotlinPoet-generated files.
Here's an extension for FileSpec.Builder that enables you to suppress warnings for a particular generated file.
internal fun FileSpec.Builder.suppressWarningTypes(vararg types: String) {
if (types.isEmpty()) {
return
}
val format = "%S,".repeat(types.count()).trimEnd(',')
addAnnotation(
AnnotationSpec.builder(ClassName("", "Suppress"))
.addMember(format, *types)
.build()
)
}
And here's an example of how to use it to get rid of the redundant visibility modifiers warning in generated files:
val fileBuilder = FileSpec.builder(myPackageName, myClassName)
fileBuilder.suppressWarningTypes("RedundantVisibilityModifier")
The extension also supports suppressing more than one warning types:
fileBuilder.suppressWarningTypes("RedundantVisibilityModifier", "USELESS_CAST")
Please note that I'm in no way suggesting that you should get rid of ALL the warnings that bother you in your generated code! Use this code carefully!
No, and no plans to support such functionality. If it's important for your use case to not have explicit public modifiers, a good solution would be to post-process the output with a script that removes them.

How to get Xcode to generate warning (or error) on Mismatched Return Type?

I just made a code change in the type for a method's return type and was counting on the compiler to show warnings which would allow me to find and fix wherever the mismatch now occurs. But no warnings. In my Settings I discovered that "Mismatched Return Type" was already "Yes" for all build types, so I decided to change it to "Yes (treat as error)" and did a rebuild. Still no indication in build results.
I then changed "Treat Warnings as Errors" to "Yes" and that produced a few helpful error messages, but no mismatch warnings. Perhaps I do not understand something about the compiler and Objective-C return types, but it seems that a bool should not be acceptable when my method specifies that is should return an NSNumber*.
Here is my code:
+(NSNumber*) compilerCompletelyFineWithThis
{
if ([m_session tryThis])
{
return [m_session goGetSumthin];
}
else
return false;
}
The docs suggest that Mismatched Return Type is associated with GCC_WARN_ABOUT_RETURN_TYPE, but it is not clear what rules this enforces.
In the pic below of the warnings section(s) of my Build Settings, notice the relevant settings. I have "Treat Warnings as Errors" and "Mismatched Return Type" turned on for all my builds.
Is there a way to get Xcode to let me know when I am violating this kind of contract between a method definition and the calling code?
Sad news… the problem here is not with the “Mismatched Return Type” warning/error setting.
The problem is that false is actually a #define for 0. You can find the definition in stdbool.h, hidden away at this path in Xcode 8.3.3:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.1.0/include/stdbool.h
Since it's a preprocessor define, it gets changed from false to 0 before the semantic analysis part of the compiler sees it.
In C, you're allowed to use a bare literal 0 as a null pointer. So in your case, false is treated as a null pointer to NSNumber and is a legal return value.
Even if you use the preferred Objective-C boolean NO, that alone won't fix the problem. NO is a #define for __objc_no (see /usr/include/objc/objc.h), which is a clang extension that effectively acts as a literal 0 (but which allows the compiler uses to convert #YES and #NO to the proper singletons).
To get a warning, you need to take three steps:
Add -Wnon-literal-null-conversion to your “Other C Flags” build setting.
Return NO instead of false.
Declare your function to return _Nonnull.
Result:
+(NSNumber * _Nonnull) compilerCompletelyFineWithThis {
return NO;
// error: Expression which evaluates to zero treated as a null pointer constant of type 'NSNumber * _Nonnull'
}
Starting in Xcode 9, you can turn on the “Implicit Non-Literal Null Conversions” build setting instead of modifying “Other C Flags”.

What does "forceCompile" mean on YII when you use Less?

I have this:
'components'=>array(
'less'=>array(
'class'=>'ext.less.components.LessCompiler',
'forceCompile'=> true, //YII_DEBUG, // indicates whether to force compiling
//'compress'=>false, // indicates whether to compress compiled CSS
//'debug'=>false, // indicates whether to enable compiler debugging mode
'paths'=>array(
'less/style.less'=>'css/style.css',
),
),
If I enable forceCompile my site is extremely slow. I would imagine because it regenerates the css on each page load. My question is around disabling it. If I disable it:
Will any changes I make to style.less not reflect in the browser?
If so, what is the point of Less? Surely it can't actually be used in production then? Or do you disable forceCompile so it only generates it once?
Any clarity on forceCompile would be highly appreciated!
(And yes, I looked all of for a clear explanation... best I could find was this).
First let me tell you what is the point of less:
less is a meta language, so in general terms using less helps you write easily maintainable css, although the "language" used is less syntax. As a common example, you can define variables in less that are compiled to css values according to the other statements in your less file. Or you can use mixins, nesting, inheritance concepts like you would in most other languages that support OOP.
So you write understandable, readable pseudo/meta css code that is converted to actual css upon compilation.
Now the extension:
Even if you disable forceCompile, the changes made in style.less should reflect, because the extension checks if the file was modified (the following lines from LessCompiler.php should convince you about that):
if ($this->forceCompile || $this->hasChanges())
$this->compileAll();
// ...
/**
* Returns whether any of files configured to be compiled has changed.
* #return boolean the result.
*/
protected function hasChanges() {
// ...
$compiled = $this->getLastModified($destination);
// ...
$modified = $this->getLastModified($dir);
// ...
}
/**
* Returns the last modified for a specific path.
* #param string $path the path.
* #return integer the last modified (as a timestamp).
*/
protected function getLastModified($path){
//...
}
So forceCompile will always compile the file(s) you specify in paths, and you should not enable it in production. The hasChanges call should take care of less files that have been modified, and compile them, which as you see above is automatically done by the extension.

How to make your code not compilable if its format does not math some rules?

How to make your code not compilable if its format does not match some rules?
For example (C# language):
if (a < b)
{
// <-- build error with message "empty line"
k = j + h;
}
or
public void Method(int a, int name) // <-- build error with message "parameter name 'a' is too short"
{
//...
}
If you're looking specifically for C# style-checking, have you tried stylecop?
For a comprehensive list of style-checkers, wikipedia is your friend.
Unless the compiler has specific flags to reject certain types of syntax, you can't make the compiler do that. But you can add a code analysis script that analyzes the source code prior to compiling. You can implement all kinds of coding style rules in that script and it will reject the source code before actually compiling it.
You could have your version control system reject a checkin if it doesn't conform to standards.

gcc warning" 'will be initialized after'

I am getting a lot of these warnings from 3rd party code that I cannot modify.
Is there a way to disable this warning or at least disable it for certain areas (like #pragma push/pop in VC++)?
Example:
list.h:1122: warning: `list<LogOutput*, allocator<LogOutput*> >::node_alloc_' will be initialized after
list.h:1117: warning: `allocator<LogOutput*> list<LogOutput*, allocator<LogOutput*> >::alloc_'
Make sure the members appear in the initializer list in the same order as they appear in the class
Class C {
int a;
int b;
C():b(1),a(2){} //warning, should be C():a(2),b(1)
}
or you can turn -Wno-reorder
You can disable it with -Wno-reorder.
For those using QT having this error, add this to .pro file
QMAKE_CXXFLAGS_WARN_ON += -Wno-reorder
use -Wno-reorder (man gcc is your friend :) )
Class C {
int a;
int b;
C():b(1),a(2){} //warning, should be C():a(2),b(1)
}
the order is important because if a is initialized before b , and a is depend on b. undefined behavior will appear.
If you're seeing errors from library headers and you're using GCC, then you can disable warnings by including the headers using -isystem instead of -I.
Similar features exist in clang.
If you're using CMake, you can specify SYSTEM for include_directories.
The order of initialization doesn’t matter. All fields are initialized in the order of their definition in their class/struct. But if the order in initialization list is different gcc/g++ generate this warning. Only change the initialization order to avoid this warning. But you can't define field using in initialization before its construct. It will be a runtime error. So you change the order of definition. Be careful and keep attention!