From: Shawn M Moore Date: Tue, 28 Apr 2009 10:13:52 +0000 (-0400) Subject: Skeleton for ClassOverridesRole X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=042287b0ebb0be52677063e39cfb9ba5b5d2abd7;p=gitmo%2FPerl-Critic-Dynamic-Moose.git Skeleton for ClassOverridesRole --- diff --git a/lib/Perl/Critic/Policy/DynamicMoose/ClassOverridesRole.pm b/lib/Perl/Critic/Policy/DynamicMoose/ClassOverridesRole.pm new file mode 100644 index 0000000..361b55f --- /dev/null +++ b/lib/Perl/Critic/Policy/DynamicMoose/ClassOverridesRole.pm @@ -0,0 +1,49 @@ +package Perl::Critic::Policy::DynamicMoose::ClassOverridesRole; +use Moose; +extends 'Perl::Critic::Policy::DynamicMoose'; + +use Perl::Critic::Utils ':severities'; + +Readonly::Scalar my $EXPL => q{}; +sub default_severity { $SEVERITY_MEDIUM } + +sub violates_metaclass { + my $self = shift; + my $meta = shift; + + return; +} + +no Moose; + +1; + +__END__ + +=head1 NAME + +Perl::Critic::Policy::DynamicMoose::ClassOverridesRole + +=head1 DESCRIPTION + + +=head1 WARNING + +B Most L Policies (including all the ones that +ship with Perl::Critic> use pure static analysis -- they never compile nor +execute any of the code that they analyze. However, this policy is very +different. It actually attempts to compile your code and then compares the +subroutines mentioned in your code to those found in the symbol table. +Therefore you should B use this Policy on any code that you do not trust, +or may have undesirable side-effects at compile-time (such as connecting to the +network or mutating files). + +For this Policy to work, all the modules included in your code must be +installed locally, and must compile without error. + +=head1 AUTHOR + +Shawn M Moore, C + +=cut + diff --git a/t/DynamicMoose/ClassOverridesRole.run b/t/DynamicMoose/ClassOverridesRole.run new file mode 100644 index 0000000..d5d8a15 --- /dev/null +++ b/t/DynamicMoose/ClassOverridesRole.run @@ -0,0 +1,49 @@ +## name No collision +## failures 0 +## cut + +package Role; +use Moose::Role; + +sub role {} + +package Class; +use Moose; +with 'Role'; + +sub class {} + +#----------------------------------------------------------------------------- + +## name Name collision +## failures 1 +## cut + +package Role; +use Moose::Role; + +sub foo {} + +package Class; +use Moose; +with 'Role'; + +sub foo {} + +#----------------------------------------------------------------------------- + +## name Name collision with exclusion +## failures 0 +## cut + +package Role; +use Moose::Role; + +sub foo {} + +package Class; +use Moose; +with 'Role' => { excludes => 'foo' }; + +sub foo {} +