How do I work with Java Models in Moose?

1. How do I filter out inner classes from the list of classes?

Enter the query:

  each name asNumber isZero


 each isAnonymousClass

2. How do I filter out test classes from the list of classes?

Enter the query:

  ('*Test*' match: each name) not 


 each isJUnit4TestCase

3. How do I set the model so that the source code is available in Moose?

  • Select the model. Then right-click to access the context menu and select Utilities -> set root folder. A window appears allowing you to browse your filesystem to select the appropriate folder containing the source code.

4. How to I calculate duplications for my classes?

  • Make sure the root folder for the source has been set.
  • Produce a list of classes using a query that you wish to analyze for duplications.
  • Select the class group by entering "true" as a query in the query pane.
  • Right-click on the selection to obtain the context menu. Then select Utilities -> Compute duplication. (The computation is quite slow so be prepared to wait a bit).

5. How to get a list of the large methods of the classes of a group of namespaces?

Query for a few namespaces that satisfy a particular query - e.g. all namespaces that contain Business Facade Layer classes:

 '*facade*’ match: each name  

In the Namespaces Evaluator pane:

 self allRecursiveClasses 

Then in the classes:

 each methods anySatisfy: [:a | a numberOfLinesOfCode > 20 ].