Perl::C...leWiths(3)

πŸ“¦
version 1.05 Β· 2 versions
, in fedora 43

πŸ’– Perl::Critic::Policy::Moose::ProhibitMultipleWiths πŸ’–

okay bestie, so this page is all about Perl::Critic::Policy::Moose::ProhibitMultipleWiths (the man page header calls it Perl::C...leWiths(3) but that's just the terminal being ✨ dramatic ✨ with the truncation) β€” and it's giving Require role composition. πŸŽ€


✨ VERSION ✨

version 1.05 β€” yeah, she's been around a minute and she still slays. πŸ’…


🌸 DESCRIPTION 🌸

So, Moose::Roles? They're lowkey the answer to all those name conflicts that plague multiple inheritance and mix-ins. iconic behaviour, honestly. But here's the catch, bestie: to actually enjoy that protection, you have to compose your roles together. 😭

Roles do not generate conflicts if they're consumed individually. Which is exactly the problem β€” no conflict warning, no nothing, just vibes and chaos. πŸ’€

So the move? Pass all your roles to a single with statement. That's it, that's the whole assignment. 🫢

# ok
package Foo;

use Moose::Role;

with qw< Bar Baz >;
# not ok
package Foo;

use Moose::Role;

with 'Bar';
with 'Baz';

See how the second one is doing way too much with two separate with calls? Yeah. Not it. πŸ™ˆ


πŸ¦‹ AFFILIATION πŸ¦‹

This policy is part of Perl::Critic::Moose. She has a family, she's not out here alone. πŸ’œ


⭐ CONFIGURATION ⭐

There is a single option, "equivalent_modules". πŸ‘‘

This lets you specify modules that should be treated the same as Moose and Moose::Role, if β€” say β€” you were doing something with Moose::Exporter. Custom Moose-ish energy, we love to see it. 🌈

For example, if you were to have this in your .perlcriticrc file:

[Moose::ProhibitMultipleWiths]
equivalent_modules = MyCompany::Moose MooseX::NewThing

then the following code would result in a violation:

package Baz;

use MyCompany::Moose;

with 'Bing';
with 'Bong';
caught in 4K, no cap. that's a violation. 🚨

πŸ’Œ SUPPORT πŸ’Œ

Bugs may be submitted through the RT bug tracker <http://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Critic-Moose> (or bug-perl-critic-moose@rt.cpan.org <mailto:bug-perl-critic-moose@rt.cpan.org>).

I am also usually active on IRC as 'drolsky' on "irc://irc.perl.org". so like, come say hi, fr fr. 🫢


πŸ‘‘ AUTHORS πŸ‘‘

  • Elliot Shank <perl@galumph.com>
  • Dave Rolsky <autarch@urth.org>

legends, both of them. periodt. πŸ’…


This software is copyright (c) 2008 - 2016 by Elliot Shank.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


and that's the whole page, bestie! πŸ¦‹ this gem comes to you from User Contributed Perl Documentation, running on perl v5.42.0, dated 2025-07-25, and the man page signs off as Perl::C...leWiths(3). mwah πŸ’‹ go compose those roles together, ily, bye! βœ¨πŸ’–

πŸ“¦ where this page comes from