Brian Laframboise
Brian Laframboise

Reputation: 5514

Simple way to detect unused properties keys?

Given a set of properties files and list of files which may reference keys in those properties files, what's the easiest way to determine which keys are unused?

Example:

Given a project with files

muppets.properties

kermit=Kermit the Frog
oscar=Oscar the Grouch

smurfs.properties

papa=Papa Smurf

and /WEB-INF/pages/template.jsp

Some jsp template displaying the key <bean:write bundle='muppets' key='kermit'/>.

then running program with inputs "*.properties" and "/WEB-INF/**/*.jsp" should report

Unused properties:

muppets.properties
oscar

smurfs.properties
papa

What's the simplest way to do this? Are there any open-source Java libraries that make this easy? The idea is to embed the solution inside an in-house Maven reporting plugin that would run when building a web app.

I'm aware that there will be false positives (key strings appearing in the files in a non-key context), but that's ok. Being able to find any unused keys would be helpful.

Edit: I'm seeking a standalone code-base solution.

Upvotes: 3

Views: 2882

Answers (2)

OscarRyz
OscarRyz

Reputation: 199333

IntelliJ IDEA has this functionality. Unfortunately is it used within the app and not as a Maven plugin.

Some of the modules in IDEA are open source. Many plugins are available to the community. Perhaps you could peek at their website to see if there is anything you can grab.

I hope this helps http://www.jetbrains.net/devnet/index.jspa

Upvotes: 1

msugar
msugar

Reputation: 1

I think that JInto can help you.

http://www.guh-software.de/jinto_en.html

Upvotes: 0

Related Questions