Tool to verify that each public class has javadoc comment - intellij-idea

Please propose some tool to verify that each public class and member has javadoc comment. I'm using IDEA to edit source, but haven't found a options to make javadoc essential.
Thank you very much.

IntelliJ IDEA can checkt it for you. You have to enable Javadoc inspections.
You can set various parameters. Like check only public classes, members and methods.

A tool such as checkstyle do exactly that, among many other checks. You can use it to produce a full report with many different checks for your codebase.
It is common to use it along with bytecode based analysis tools, such as PMD or findbugs, that are used to detect some coding errors, such as dead code, erroneous null checks, and many more.

Related

How to add an ABAPDoc for a method that is an enhancement of a standard class?

I have extended a class by one method, using the Enhancement Framework.
Now, my problem is that I want to add ABAPDoc to it but cannot find any way to do it!
The code in the Enhancement Include section seems to be editable in no way.
Is there any way to do it at all? I tried also from ADT in Eclipse but this calls the SAP GUI anyway.
What are you trying to do is indeed impossible.
The enhancement include is a technical object and it cannot be edited from the tab you highlighted, it is auto-generated as you changing pre- and post-methods.
What this tab shows is not an include itself, but the placement of the enh. include within the parent object
If you want to change the method comment from enhancement, you should go to Technical details tab and click on changed object, or just go to the class in SE24 and press to pre/post exit button, and you will end up in the same include:
You can write the ABAPDoc-syntaxed comment, but for me it didn't work, and Eclipse didn't recognized my comment written in SAPGui, maybe you will be luckier.
ABAPDoc team describes this piece in a fuzzy manner, it may be an expected behavior:
This ABAPDoc is only available to ADT and not SE80? I can not use it in SAP GUI development?
You can also write it in the source code and you will get also warnings when you execute a check, but there is no dedicated tools support like source code element information or quick assist (Ctrl+1)
To your principal question, ABAPDoc is a two-way road when viewing: the ABAPDocs can be viewed both from the Eclipse and SE80, and they are automatically showed in SE80 description fields (but only if they are declared synchronized).
But it seems to be a one-way road for edit: they can be created only in ADT Eclipse to be fully compatible. If the object cannot be opened in Eclipse natively like your enhancement you are out of the luck.
I put seems because I am not 100% sure. Maybe on later systems it was fixed, but on my 750 they are not recognized by Eclipse for enhanced methods.
The only reliable way of "editing" via SE80 is writing the comments to descriptions and then importing these SE80 descriptions into ABAPDoc in Eclipse
which is ridiculous in context of your question, so there is no way for you.

Disable automatically-generated comments in classes (backend editor)

Currently, I am "forced" to develop my reports with SE80 / SE24, etc. and I can't use eclipse. There I've seen that if you have the "Source Code-Based" view in Z-Classes, above every method the signature is shown as a comment. See in the following picture:
Well, I know that those comments are not really in the source code, but shown anyway (generated somehow).
Do you know a way how to disable those "comments"?
I find them unnecessary and I am losing the overview over the class. And instead of a 27-row implementation part of a class I've got an 88-row-long implementation part.
These signature comments are automatically generated by the SAP GUI based class editor reached through transactions SE24 and SE80.
Use the ABAP Development Tools to avoid them.
There's no way to disable those comments. I genereally prefer the form editor when forced to use SE80, I think it gives a better overview. The best would be if you were allowed to use Eclipse, but politics can be difficult to change.

IntelliJ Idea: How to create a custom inspection rule

I'm looking for the way to create inspection to warn about large non-javadoc comments in code. I didn't found any suitable common inspection to do this. It looks like I should create a custom inspection rule. Does anybody know how to do it?
As far as I know, there are two ways to create your own code inspection in IntelliJ IDEA:
(simple but limited way) Creating custom inspection based on "search templates".
(more complex and more powerfull way) Developing an IDEA-plugin (here are the guidlines) using your own InspectionToolProvider implementation as "application-component". Also you may use sources of my inspections-plugin as the starting point.
See http://confluence.jetbrains.com/display/IDEADEV/Developing+Custom+Language+Plugins+for+IntelliJ+IDEA#DevelopingCustomLanguagePluginsforIntelliJIDEA-CodeInspectionsandIntentions. You can look at Open API and Plugin Development forum for assistance.

Pointcut for usage of operator "==" with specific types

is it possible to write an AspectJ pointcut that matches the usage of a specific operator with a specific type?
Some background information: I'm working on a project where we have to use a legacy Java library (pre 5.0, before the enum keyword) which comes with several "pseudo-enum" types, i.e. normal Java classes that define static constants of its own type. Those "feel" very much like enums, but using them like enums can result in an error. Therefore I'd like AspectJ to mark uses of == with objects of one of these types as an error, if that is possible. I have googled this and consulted the normally very helpful book AspectJ in action, but so far without success. Any help is appreciated.
== is not the same as equals(), and is implemented by the JVM, and as far as I can tell cannot be modified by aspectj. Also, I don't think that AspectJ is the correct tool for this job.
A better approach would be to implement a Checkstyle rule or similar for your project to allow you indicate these points. You could have them as errors or warnings. See Writing Checks for Checkstyle for more information.
This would require some coding, but so would the aspectJ solution.
Checkstyle has an eclipse plugin as well as a maven plugin, so you could have these errors appearing as you work in the IDE.

Have JUnit fail tests that don't actually run an assertion

My team is working on educating some of our developers about testing. They understand why to write tests and are on board that they should write tests, but are falling a little short on writing good tests.
I just saw a commit like this
public void SomeTest{
#Test
public void testSomething{
System.out.println(new mySomething.getData());
}
So they were at least making sure their code gave them the expected output by looking.
It will be a bit before we can really sell the idea of code reviews. In the mean time I was considering having JUnit fail any tests that do not have actual assertXXX or fail statements in them. I would then like to have that failure message say something like "Your tests should use assertions and actually examine the output!".
I fully expect this to lead to calls like assertTrue(1 == 1);. We're working on the team buy in for proper testing and code reviews, are there any technical mechanisms we can use to make life easier for the developers that already get it?? What about technical mechanisms to help the new guys understand?
I think you should consider organizational changes: mentoring, training, code reviews.
The tools can only help you if you're using them in good faith with a base understanding of the goals. If one of these is missing they won't help you.
Humans are just to intelligent to do dump things or work around metrics. I think your assessment is not correct that "they" are on board if they can't write a single useful test. Automatic tools are simply not the correct tools at this stage. You can't learn by being told by a program what to do next.
You can use some static code analyzer.
I use PMD which includes a JUnit rule set. There are a lot of IDE plugins which will mark rule violations in the IDE. You can configure the rule sets to your needs.
You will also profit from the other rule sets - which will warn you on code style / best practice violations (although you have to decide sometimes if the tool or you are the fool :-)).
to answer the stated question for future viewers.
JUnit uses reflection to run tested function if any Exception, Error throws -> test fails, otherwise succeed. Assert class is just a utils class.