8

I am using IntelliJ IDEA.

How I can know how many methods a class has? Are there any plugins to see metrics concerning the number of methods?

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
Miuler
  • 473
  • 1
  • 5
  • 13

1 Answers1

9

Try the MetricsReloaded plug-in.

Help | Find Action | Calculate Metrics.

Create a new empty profile with CSO enabled — Class metrics, Class size (operations):

CSO

Run the profile, it will show the number of methods per class:

Result

You may also want to enable ISO (Interface size) metric.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • 1
    Sorry, but I fail to see a feature in the plugin for counting methods in a class. Where do I look? – Kimball Robinson Sep 07 '17 at 20:26
  • Just Follow the instructions inside the plugin page. Then go to class matrix tab. then you can see the method count. – Lasitha Benaragama Dec 12 '17 at 13:19
  • For future reference: Go to help -> find action -> calculate metrics. To add the method count for a specific class, click the "..." to the right of the selector. Then you find "Interface metrics" or "Class metrics" and select what you want. That might help out some people, but for me it was still very buggy. It wasn't saving all the options that I selected and I never could get the "method count" to come up. – retodaredevil Jul 16 '19 at 23:41
  • MetricsReloaded counts lines of code and files. It does not have metrics for method/member/function counting. – Rjak Jul 17 '19 at 21:42
  • @Rjak thanks for downvoting without doing any research or reading any comments. MetricsReloaded plug-in [does allow to calculate the number of methods](https://i.imgur.com/FOsvW06.png). – CrazyCoder Jul 17 '19 at 21:48
  • @CrazyCoder I have the plugin installed now and there is no Class metrics section. I've played with it for awhile and cannot see it anywhere. Changed my vote since the screencaps show the feature, so maybe our company has an out-of-date version on our proxy. – Rjak Jul 17 '19 at 23:41
  • @CrazyCoder I just installed the plugin on my personal machine directly connected to the internet and the only categories I can choose from when I follow your instructions are "Project metrics", "File type metrics", and "Module metrics". Let me know if you have any idea why, otherwise I feel downvoting this answer is justified. – Rjak Jul 17 '19 at 23:59
  • @Rjak what IDE and plug-in versions do you have? My screenshots are from IntelliJ IDEA 2019.1.3 version and [MetricsReloaded 1.8 plug-in](https://i.imgur.com/wCCTpsz.png). – CrazyCoder Jul 18 '19 at 00:02
  • @CrazyCoder PyCharm 2019.1.1. + MetricsReloaded 1.8 at work and PyCharm CE 2018.1 + MetricsReloaded 1.8 on my personal machine. Thanks very much for your understanding, man! – Rjak Jul 18 '19 at 21:33
  • @Rjak Class metrics is the Java specific feature, it's not supported for Python. Notice that this question is tagged with `#intellij-idea` and has IntelliJ IDEA in the title and in the body. – CrazyCoder Jul 18 '19 at 21:34
  • The Latest MR plugin menu is changed invoke it from Analyse--> Calculate Metrics menu Item – Raja Nagendra Kumar Feb 22 '21 at 05:43
  • I want to calculate total method in interface and select interface metric -> interface size(operations). But it doesn't give correct counts. – Abe Sep 26 '22 at 16:41