Eclipse - how to determine the number of methods in a Java application

I'm trying to do something weird, I'm trying to determine how many methods my Java application has.

This strange thing has a purpose, because I need to improve logging in the application, and for this I will need to revise each method and add a log, if it is absent, to update the log if it is already.

I participate in the assessment process, therefore, knowing how many methods the application will help me provide a high level assessment with a reasonable basis for this.

Then, here's the question, is there a way to find out how many methods my Java application has?

Thanks in advance.

Fer

PS: I use Eclipse

+6
source share
8 answers

Try using a static code analyzer; Source Monitor , for example, is a free SW and has the account you are looking for.

+2
source

Using Eclipse, you can do this:

  • Press Ctrl-H (Search), then select the "Java Search" tab (if it does not appear, click the "Configure ..." button in the lower left corner)
  • Put * in the search field
  • Select "Method" in the "Search" field.
  • Select "Ads" in the "Limit to" field
  • Select Sources in the Search In box
  • Select Workspace in the Scope field.
  • Click Search

After the search is completed, you will see the message "XXXX declarations in ..." in the search box and this will be your result.

Hope this helps!

+29
source

I would prefer to use Reflection .

  • Get the whole class from expected packages where logging is required
  • To summarize the whole method available for all of these classes
+4
source

Using sonar - http://www.sonarsource.org/ is a great tool for code analysis.

Or look here: What are some good plugins for parsing static code?

+2
source

If you intend to add a log for many methods, you might consider introducing an AOP solution. This will allow you to write sequential logs, simplify their support and not clutter up your code with templates. Google has many examples.

+2
source

Metrics is a good plugin for Eclipse: http://metrics.sourceforge.net/

Number of Methods (NOM): total number of methods defined in the selected area

+1
source

For a particular class, it’s easy to simply select all methods from the class structure panel in eclipse, then right-click and copy the full name into the editor of your choice, and then simply count the number of lines.

+1
source

Press CTRL + O in the corresponding Java class in the Eclipse IDE - you will get the number of methods in the corresponding Java class. You should now see the number of methods available in this class.

+1
source

Source: https://habr.com/ru/post/904094/


All Articles