|Perl Monk, Perl Meditation|
Check spelling in perl source code.by chrestomanci (Priest)
|on Sep 27, 2013 at 15:23 UTC||Need Help??|
chrestomanci has asked for the
wisdom of the Perl Monks concerning the following question:
Greetings wise brothers, I seek your wisdom in the matter of how fat fingers, mistakes and carelessness can corrupt our beautiful code.
I am looking for a way to spellcheck perl source code. If it can be done reliably enough then I would like to add it as a pre-commit hook to our source control, but even if that is not possible, it would be good to warn developers so that they can change things.
I have done an internet search and found modules such as Perl::Critic::Policy::Documentation::PodSpelling and Test::Spelling, which look useful, but they only check the spelling of POD documents not the rest of the source code.
What I would really like to do is to intelligently check the spelling on variable and method names as well. So that if someone names a scalar as $new_varable or $newVarable it will find the variable in the source, intelligently split the name on underscores and case changes, and spellcheck the parts. (And report that varable is wrong (it should have an i). I don't need a spellchecker to offer replacements, as my editor can usually do that once I isolate the error, but I do need a better way to find error.
The reason I am after such a tool is that developers will often search for methods or variables by name. So for example, a developer might be looking for the function to increase a variable, and miss it because it is named increease_varable()
Any suggestions? do such tools exist? I know that it is impossible to write a perfect tool of this nature, because only perl can parse perl, but something that does 90% would be a great deal better than nothing. Looking at perldebguts, I was wondering if you could hook the debugger to return all the names (variables, functions, globs etc) declared in a source file, and then parse them for possible errors.