On Feb 22, 2012, at 1:03 PM, Michael G Schwern via RT wrote:
Show quoted text
Well, I don't entirely agree with those statements. But I do agree that the Policy doesn't actually enforce the best-practice that Conway is espousing. And yes, I think we can do better here.
Show quoted text> While perlcritic is primarily a file-based beast, and only deals with
> reading the code, for this one to work it must look outside the file.
> Either for...
Looking for artifacts of a VCS system is good. But I think actually checking if the file is under version control is even better. Basically, do the moral equivalent of "svn stat $file" using the appropriate VCS tool. Either way, it implies that this Policy will only be applied to files that came directly from a VCS. This will throw a false violation if you run the Policy on the stuff in the blib/ directory (as Test::Perl::Critic does). I'm not sure how to get around that.
Show quoted text> As an alternative, rather than Perl::Critic trying to guess what VCS the
> project is using, the new RequireVCS policy would warn unless
> .perlcritic has been configured with what VCS is in use. Then it could
> choose an appropriate method of checking. It could also be configured
> with the path to the proper program to run, rather than grovelling up
> the directory tree looking for .blah directories.
Yes, this seems like the right thing to do. But it leads me to feel that such a Policy does not belong in the core. Presently, all the core policies are zero-conf. They all do something useful right out of the box (even if you don't agree with the default config). I would like to keep it that way.
Requiring configuration for some Policies is fine. But from a usability perspective, I feel it automatically relegates them to a non-core distribution, so novice users will typically not have access to this Policy. Unfortunate, but necessary I think.
Show quoted text> A resurrected RequireVcsKeywords would also key off this information
> (rather than having it told redundantly). It would then check for VCS
> keywords appropriately, which includes not requiring them at all if your
> VCS doesn't support them.
In the current architecture, each Policy is isolated and independent. They don't talk to each other and they don't share configuration information. So tying these Policies together directly will either be a hack, or we'll have to re-architect quite a bit.
Another approach would be to combine the Policies together. This obviously makes the Policy more complex, and again, it conflates multiple issues. But it might be a more natural solution, given the current architecture.
There might be other approaches. I'll have to think about it a bit.
-Jeff