CPAN Release of TooMuchCode 0.17

Perl::Critic::TooMuchCode is a set of policy addons that generally checks for dead code or redundant code.

I feel grateful that this small project starts to draw some attention and endorsement and now it is receiving pull-requests from the Perl/CPAN c…


This content originally appeared on DEV Community and was authored by Kang-min Liu

Perl::Critic::TooMuchCode is a set of policy addons that generally checks for dead code or redundant code.

I feel grateful that this small project starts to draw some attention and endorsement and now it is receiving pull-requests from the Perl/CPAN community.

In version 0.17 we improved the policy ProhibitDuplicateLiteral and now it we can whitelist strings and numbers in configurations. If you somehow really need to use number 42 and "forty two" literally in the code many times, you list them in .perlcriticrc:

[TooMuchCode::ProhibitDuplicateLiteral]
whitelist = "forty two" 42

Thanks to @ferki from project Rex!

Rex is an automation framework, or remote-execution framework. In a sense, similar to Ansible. It's a simple way of telling machine what to do, with some code named Rexfile -- a task manifest. which is also perl code. Within which you'd repeat some strings literally such as:

service 'apache2',  ensure => 'started';
service 'mysql',    ensure => 'started';
service 'memcached, ensure => 'started';

... and that is OK. Because those manifests should be direct instead of indirect/abstract with the use of variables / constants to just hold the string 'started'. Doing such is an unnecessary level of indirection since the purpose of task manifests is to tell machine what to do and if human readers needs to read twice before they can understand what it really means, the is a problem.

Well, apparently in the context of coding Rexfile, some repetition are allowed. In general, perhaps repetition are OK in any DSL code. DSL itself already reduce some repetition by hiding the details and DSL keywords tends to be high-level constructs that are designed to be easily understandable for human readers. Repetition of DSL keywords almost never leads to be unreadable or "bad small".

I might have repeated the word "repetition" too many times.

Originally posted at: gugod's blog -- CPAN Release of TooMuchCode 0.17


This content originally appeared on DEV Community and was authored by Kang-min Liu


Print Share Comment Cite Upload Translate Updates
APA

Kang-min Liu | Sciencx (2021-09-20T23:05:15+00:00) CPAN Release of TooMuchCode 0.17. Retrieved from https://www.scien.cx/2021/09/20/cpan-release-of-toomuchcode-0-17/

MLA
" » CPAN Release of TooMuchCode 0.17." Kang-min Liu | Sciencx - Monday September 20, 2021, https://www.scien.cx/2021/09/20/cpan-release-of-toomuchcode-0-17/
HARVARD
Kang-min Liu | Sciencx Monday September 20, 2021 » CPAN Release of TooMuchCode 0.17., viewed ,<https://www.scien.cx/2021/09/20/cpan-release-of-toomuchcode-0-17/>
VANCOUVER
Kang-min Liu | Sciencx - » CPAN Release of TooMuchCode 0.17. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/09/20/cpan-release-of-toomuchcode-0-17/
CHICAGO
" » CPAN Release of TooMuchCode 0.17." Kang-min Liu | Sciencx - Accessed . https://www.scien.cx/2021/09/20/cpan-release-of-toomuchcode-0-17/
IEEE
" » CPAN Release of TooMuchCode 0.17." Kang-min Liu | Sciencx [Online]. Available: https://www.scien.cx/2021/09/20/cpan-release-of-toomuchcode-0-17/. [Accessed: ]
rf:citation
» CPAN Release of TooMuchCode 0.17 | Kang-min Liu | Sciencx | https://www.scien.cx/2021/09/20/cpan-release-of-toomuchcode-0-17/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.