I have been looking for this problem through google but it turns out I can not find a way to fix this problem. Actually I have a classic main
method in which I run a job, but sonarqube keeps repeating me there is an Uncommented main method found.
Here is the code :
/**
* Main : Run MapReduce job
*
* @param args
* arguments
*/
public static void main(String[] args) {
ExitManager exitManager = new ExitManager();
// run job
if (!runJob(args)) {
exitManager.exit(1);
}
}
I do not see any particular problem here, so where does this problem come from ? Do you have any idea how I can fix this ?
Thanks.
Uncommented main method is a CheckStyle warning that the main()
method is not commented-out. You are not supposed to have debug/test main()
methods in your code.
You can exclude your program entry point class using something like:
<module name="UncommentedMain">
<property name="excludedClasses" value="\.Main$"/>
</module>
See also http://checkstyle.sourceforge.net/config_misc.html#UncommentedMain
From the documentation:
Checks for uncommented main() methods.
Rationale: A
main()
method is often used for debugging purposes. When debugging is finished, developers often forget to remove the method, which changes the API and increases the size of the resulting class or JAR file. With the exception of the real program entry points, allmain()
methods should be removed or commented out of the sources.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With