Perl-Critic-Pulp-97/0002755000175000017500000000000013552456764012145 5ustar ggggPerl-Critic-Pulp-97/COPYING0000644000175000017500000010437410641206144013164 0ustar gggg GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . Perl-Critic-Pulp-97/Changes0000644000175000017500000003063113552456746013441 0ustar ggggCopyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019 Kevin Ryde This file is part of Perl-Critic-Pulp. Perl-Critic-Pulp is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. Perl-Critic-Pulp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Perl-Critic-Pulp. If not, see . Version 97, October 2019 - RequireFinalSemicolon allow hashref in arrayref (which PPI 1.270 says code block), as reported by Andy Lester RT#130725 Version 96, December 2017 - ProhibitUnknownBackslash allow for non-ascii in strings, as reported by Mark Fowler RT#123922 Version 95, October 2017 - RequireFinalSemicolon also sort{} blocks are an expression Version 94, June 2017 - ProhibitUnknownBackslash \N also Perl 5.16, as reported by Ed Davis RT#122064 Version 93, April 2017 - some doubtfulness in Makefile.PL meta bits Version 92, November 2016 - ProhibitPOSIXimport oops, don't use // operator, per paul RT#118959 Version 91, November 2016 - RequireFinalCut allow no blank line before =cut, as reported by Andy Lester RT#118722 - RequireLinkedURLs allow example.com Version 90, March 2015 - PerlMinimumVersionAndWhy actually check Modern::Perl - ProhibitNullStatements beware of extra stuff after try/catch Version 89, January 2015 - PerlMinimumVersionAndWhy experiment Modern::Perl meaning 5.10, as proposed by Ed Avis RT#100290 - RequireFinalSemicolon recognise try/catch of Try.pm, TryCatch.pm and Syntax::Feature::Try, as proposed by Ed Avis RT#100291. Various List::Util functions as expression blocks. - RequireTrailingCommaAtNewline exception for single here-documents, as proposed by Ed Avis RT#100292 - ProhibitNullStatements report null ; on try/catch, and look inside try/catch/finally blocks Version 88, November 2014 - ConstantBeforeLt oops again, PPI incompatibility too much, must do and depend on its 1.220 Version 87, November 2014 - ConstantBeforeLt really allow for PPI Version 86, November 2014 - ConstantBeforeLt allow for PPI incompatible change to ->prototype() Version 85, May 2014 - oops forgot Pod::Escapes in PREREQ_PM, per Petr Pisar RT#95440 Version 84, May 2014 - new Documentation::RequireFilenameMarkup Version 83, May 2014 - PerlMinimumVersionAndWhy new 5.10 -e -x stacked filetest per Kent Fredric RT#95208 Version 82, April 2014 - ProhibitAdjacentLinks, ProhibitLinkToSelf, ProhibitParagraphTwoDots, ProhibitUnbalancedParens, ProhibitVerbatimMarkup, RequireLinkedURLs check =begin blocks only for POD-type ":" - ProhibitBadAproposMarkup check =begin :man and :roff only - ProhibitDuplicateSeeAlso ignore all =begin blocks Version 81, April 2014 - ProhibitAdjacentLinks fix warnings when internal and external links adjacent, as reported by Mike O'Regan RT#94318 - ConstantPragmaHash and ConstantLeadingUnderscore pass ->content to version.pm as it enquires too much into a PPI object ref, per RT#92100 dmacks and ppisar Version 80, July 2013 - new policy Documentation::ProhibitParagraphEndComma - tests UnexpandedSpecialLiteral.t don't exercise __PACKAGE__ => across newline since that might be going to change in Perl 5.20, as reported by Reini Urban RT#87307 Version 79, March 2013 - fix ProhibitFatCommaNewline load version.pm for perl 5.8, as reported by paul RT#83990 Version 78, March 2013 - new policies CodeLayout::ProhibitIfIfSameLine, CodeLayout::ProhibitFatCommaNewline Version 77, February 2013 - new policy Documentation::ProhibitDuplicateHeadings - fix POD parse losing violations across =cut gaps Version 76, January 2013 - RequireNumericVersion explicit check for exponential strings "1e6" Version 75, November 2012 - ProhibitEmptyCommas fix for [{%a},{}] reported by Mike O'Regan RT#81390 Version 74, October 2012 - tests RequireNumericVersion skip version.pm 1e6 uncertain quite yet Version 73, June 2012 - tests fix for File::Temp in perl pre-5.10 Version 72, June 2012 - TextDomainPlaceholders fix #line regexp plain \2 for perl before 5.10 Version 71, June 2012 - RequireLinkedURLs - skip "=begin html" etc blocks - RequireFinalCut - cut not required if only =begin foo/=end foo block Version 70, May 2012 - new policy Documentation::RequireFinalCut Version 69, January 2012 - new policy ValuesAndExpressions::ProhibitDuplicateHashKeys - PerlMinimumVersionAndWhy - new keys @array, values @array and each @array are 5.12 - new eval '#line' with #line the very first thing is 5.8 - Perl::Critic::Pulp::Utils new elem_is_comma_operator() Version 68, January 2012 - RequireNumericVersion - recognise fully-qualified $Foo::VERSION - recognise "$VERSION = eval $VERSION" trick Version 67, December 2011 - RequireTrailingCommaAtNewline allow "return(123 newline );" Version 66, December 2011 - new policy Documentation::ProhibitDuplicateSeeAlso Version 65, September 2011 - PerlMinimumVersionAndWhy - new UNIVERSAL.pm methods in 5.004 and 5.10 - new "Foo->$method" no-args without parens is 5.6 Version 64, August 2011 - fix ProhibitLinkToSelf warnings on no L<> display part Version 63, August 2011 - new policy Documentation::ProhibitLinkToSelf Version 62, July 2011 - Makefile.PL depends PPI 1.212 for literal() Version 61, June 2011 - new policies ProhibitArrayAssignAref, RequireTrailingCommaAtNewline, ProhibitUnbalancedParens Version 60, May 2011 - PerlMinimumVersionAndWhy new 5.6 open(my $fh,...) Version 59, May 2011 - tests don't die on a deliberately induced version.pm warning Version 58, May 2011 - new policy Documentation::ProhibitParagraphTwoDots Version 57, May 2011 - ProhibitUnknownBackslash - allow \: etc stopping interpolation - \N only when "use charnames" in scope Version 56, April 2011 - new policy Documentation::ProhibitAdjacentLinks - PerlMinimumVersionAndWhy new 5.6 syswrite() length optional Version 55, April 2011 - PerlMinimumVersionAndWhy add 5.8 pack() "[123]" brackets Version 54, April 2011 - PerlMinimumVersionAndWhy - new check 5.005 for "my (undef,$x)", - fix for "delete $array[0]{'key'}" is hash not array - document 5.8 for "=>" across newline - document 5.004 for "$coderef->()" call and "sysseek()" func Version 53, April 2011 - new policy Documentation::RequireLinkedURLs Version 52, April 2011 - new policy Compatibility::ConstantLeadingUnderscore - Perl::Critic::Pulp::Utils new elem_in_BEGIN() Version 51, April 2011 - depend on Pod::MinimumVersion 50 for fix to =item C<< >> detection Version 50, March 2011 - fix Compatibility::PodMinimumVersion to use its documented "above_version", as reported by Mark Gardner - fix Perl::Critic::Pulp::Utils parameter_parse_version() to store with __set_parameter_value(), so field "_foo" not "foo" Version 49, March 2011 - split Pod::MinimumVersion to its own distribution Version 48, March 2011 - PerlMinimumVersionAndWhy some bits now in Perl::MinimumVersion itself Version 47, February 2011 - fix Makefile.PL for perl 5.6 - UnexpandedSpecialLiteral allow fat comma after newline - PerlMinimumVersionAndWhy report pragmas too Version 46, January 2011 - new policy ValuesAndExpressions::RequireNumericVersion Version 45, December 2010 - oops, tests really fix ProhibitVerbatimMarkup.t Version 44, December 2010 - tests fix ProhibitVerbatimMarkup.t some version number checks Version 43, September 2010 - test manifest only as an author test - tests drop backslash of more wide chars which bomb on 5.8.x, maybe Version 42, September 2010 - tests avoid warnings from Pod::Parser 1.37 on empty =encoding - tests and docs Perl::Critic 1.110 for annotations past __END__ Version 41, July 2010 - TextDomainPlaceholders allow literal number for __xn() count Version 40, July 2010 - new policy Modules::ProhibitModuleShebang Version 39, July 2010 - PerlMinimumVersionAndWhy add - 0b110011 binary literals new in 5.006 - new policy Documentation::ProhibitVerbatimMarkup Version 38, June 2010 - new policy CodeLayout::RequireFinalSemicolon Version 37, May 2010 - tests don't try wide chars in PPI input string, doesn't work in 5.8.6 and not sure if it's meant to Version 36, May 2010 - PerlMinimumVersionAndWhy add - "foreach my $foo" lexical loop variable new in 5.004 - "$coderef->()" call new in 5.004 Version 35, April 2010 - PerlMinimumVersionAndWhy add - special __PACKAGE__ new in 5.004 - "use VERSION" or "use MODULE VERSION" new in 5.004 Version 34, April 2010 - new policy ValuesAndExpressions::ProhibitBarewordDoubleColon - PerlMinimumVersionAndWhy new option skip_checks Version 33, April 2010 - ProhibitBadAproposMarkup and Pod::MinimumVersion quietly ignore POD parse errors Version 32, March 2010 - PerlMinimumVersionAndWhy add - exists() and delete() subs and arrays new in 5.006 - Foo::Bar:: double-colon bareword new in 5.005 Version 31, February 2010 - ProhibitUnknownBackslash fix for interpolated "$#array" Version 30, January 2010 - PerlMinimumVersionAndWhy new pack/unpack format string checks Version 29, January 2010 - fix dependency, P::C 1.084 for highest_explicit_perl_version() Version 28, January 2010 - new policy Compatibility::ProhibitUnixDevNull Version 27, December 2009 - ProhibitUnknownBackslash also \c control chars Version 26, December 2009 - new policy ValuesAndExpressions::ProhibitUnknownBackslash Version 25, December 2009 - new policy ValuesAndExpressions::ProhibitFiletest_f Version 24, December 2009 - new policy Documentation::ProhibitBadAproposMarkup Version 23, November 2009 - PodMinimumVersion 5.004 for =for, =begin, =end Version 22, September 2009 - new policy Modules::ProhibitPOSIXimport - TextDomainPlaceholders -- allow non-ascii keys Version 21, August 2009 - PodMinimumVersion -- update the location offset hack Version 20, August 2009 - PerlMinimumVersionAndWhy -- add report qr//m needs 5.10 - fix some "use" module version cases - ProhibitNullStatements -- workaround incompatible changes in PPI 1.205 Version 19, June 2009 - new policy Compatibility::PerlMinimumVersionAndWhy - new policy Compatibility::PodMinimumVersion Version 18, June 2009 - new policy Compatibility::Gtk2Constants - TextDomainPlaceholders -- check __px() and __npx(), and try to notice a missing count arg in __nx(), __xn() and __npx() Version 17, May 2009 - TextDomainUnused -- recognise __p() etc new in libintl-perl 1.17, as advised by Guido Flohr Version 16, April 2009 - new policy Modules::ProhibitUseQuotedVersion Version 15, March 2009 - new policy Miscellanea::TextDomainUnused Version 14, January 2009 - ConstantPragmaHash -- fix for document with no includes at all Version 13, January 2009 - ConstantPragmaHash -- fix location reported Version 12, January 2009 - new policy Compatibility::ConstantPragmaHash Version 11, December 2008 - oops, in the tests PPI 1.203 doesn't like an empty document Version 10, December 2008 - new policy Documentation::RequireEndBeforeLastPod Version 9, December 2008 - new policy ValuesAndExpressions::ProhibitEmptyCommas Version 8, October 2008 - UnexpandedSpecialLiteral -- rename from LiteralSpecialLiteral, for clarity Version 7, August 2008 - new policy LiteralSpecialLiteral Version 6, August 2008 - new policy Miscellanea::TextDomainPlaceholders Version 5, July 2008 - new policy ValuesAndExpressions::NotWithCompare Version 4, July 2008 - another go at the CPAN indexing Version 3, July 2008 - fixes for CPAN indexing Version 2, July 2008 - new toplevel module Perl::Critic::Pulp - ConstantBeforeLt -- depends on prototyping, not perl version Version 1, June 2008 - the first version, with ConstantBeforeLt and ProhibitNullStatements Perl-Critic-Pulp-97/xtools/0002755000175000017500000000000013552456763013474 5ustar ggggPerl-Critic-Pulp-97/xtools/my-wunused.sh0000755000175000017500000000313013433430641016124 0ustar gggg#!/bin/sh # my-wunused.sh -- run warnings::unused on dist files # Copyright 2009, 2010, 2011, 2012, 2013, 2015, 2019 Kevin Ryde # my-wunused.sh is shared by several distributions. # # my-wunused.sh is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any later # version. # # my-wunused.sh is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . set -e set -x EXE_FILES=`sed -n 's/^EXE_FILES = \(.*\)/\1/p' Makefile` TO_INST_PM=`find lib -name \*.pm` LINT_FILES="Makefile.PL $EXE_FILES $TO_INST_PM" if test -e "t/*.t"; then LINT_FILES="$LINT_FILES t/*.t" fi if test -e "xt/*.t"; then LINT_FILES="$LINT_FILES xt/*.t" fi for i in t xt examples devel; do if test -e "$i/*.pl"; then LINT_FILES="$LINT_FILES $i/*.pl" fi if test -e "$i/*.pm"; then LINT_FILES="$LINT_FILES $i/*.pm" fi done echo "$LINT_FILES" for i in $LINT_FILES; do # warnings::unused broken by perl 5.14, so use 5.10 for checks perl -I /usr/share/perl5 -Mwarnings::unused=-global -I lib -c $i # # full path name or else the "require" looks through @INC # echo "\"$i\"" # perl -e 'use Test::More tests=>1; use Test::Vars; Test::Vars::vars_ok($ARGV[0])' "`pwd`/$i" done Perl-Critic-Pulp-97/xtools/my-diff-prev.sh0000755000175000017500000000300611776230514016323 0ustar gggg#!/bin/sh # my-diff-prev.sh -- diff against previous version # Copyright 2009, 2010, 2011, 2012 Kevin Ryde # my-diff-prev.sh is shared by several distributions. # # my-diff-prev.sh is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any later # version. # # my-diff-prev.sh is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . set -e set -x DISTNAME=`sed -n 's/^DISTNAME = \(.*\)/\1/p' Makefile` if test -z "$DISTNAME"; then echo "DISTNAME not found" exit 1 fi VERSION=`sed -n 's/^VERSION = \(.*\)/\1/p' Makefile` if test -z "$VERSION"; then echo "VERSION not found" exit 1 fi case $VERSION in 3.*) PREV_VERSION=3.018000 ;; 1.*) PREV_VERSION=1.16 ;; *) PREV_VERSION="`expr $VERSION - 1`" ;; esac if test -z "$VERSION"; then echo "PREV_VERSION not established" exit 1 fi rm -rf diff.tmp mkdir -p diff.tmp (cd diff.tmp; tar xfz ../$DISTNAME-$PREV_VERSION.tar.gz tar xfz ../$DISTNAME-$VERSION.tar.gz diff -ur $DISTNAME-$PREV_VERSION \ $DISTNAME-$VERSION \ >tree.diff || true ) ${PAGER:-more} diff.tmp/tree.diff || true rm -rf diff.tmp exit 0 Perl-Critic-Pulp-97/xtools/my-check-file-part-of.sh0000644000175000017500000000172311714421457020002 0ustar gggg#!/bin/sh # my-check-file-is-part-of.sh -- grep for spelling errors # Copyright 2009, 2010, 2011, 2012 Kevin Ryde # my-check-file-is-part-of.sh is shared by several distributions. # # my-check-file-is-part-of.sh is free software; you can redistribute it # and/or modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 3, or (at your # option) any later version. # # my-check-file-is-part-of.sh is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . exit 0 set -e set -x # $(MY_EXTRA_FILE_PART_OF) if grep --text 'This file is'' part of ' -r . | egrep -iv '$DISTNAME' then false else true fi Perl-Critic-Pulp-97/xtools/my-tags.sh0000644000175000017500000000200311714065142015363 0ustar gggg#!/bin/sh # my-tags.sh -- make tags # Copyright 2009, 2010, 2011, 2012 Kevin Ryde # my-tags.sh is shared by several distributions. # # my-tags.sh is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any later # version. # # my-tags.sh is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . set -e set -x # in a hash-style multi-const this "use constant" pattern only picks up the # first constant, unfortunately, but it's better than nothing etags \ --regex='{perl}/use[ \t]+constant\(::defer\)?[ \t]+\({[ \t]*\)?\([A-Za-z_][^ \t=,;]+\)/\3/' \ `find lib -type f` Perl-Critic-Pulp-97/xtools/my-check-spelling.sh0000755000175000017500000000376513532576741017354 0ustar gggg#!/bin/sh # my-check-spelling.sh -- grep for spelling errors # Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017, 2018, 2019 Kevin Ryde # my-check-spelling.sh is shared by several distributions. # # my-check-spelling.sh is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any later # version. # # my-check-spelling.sh is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . set -e # set -x # | tee /dev/stdout # -name samp -prune \ # -o -name formats -prune \ # -o -name "*~" -prune \ # -o -name "*.tar.gz" -prune \ # -o -name "*.deb" -prune \ # -o # -o -name dist-deb -prune \ # | egrep -v '(Makefile|dist-deb)' \ # --colour=always if find . -name my-check-spelling.sh -prune \ -o -type f -print0 \ | xargs -0 egrep -nHi 'simlar|roughtly|randomes|silbing|minmal|wiht|\bits the\b|\bint he\b|withtout|occured|exmaple|weiner|rigth|peroid|Manhatten|occuring|optino|recurrance|nineth|\bon on\b|\bto to\b|tranpose|adjustement|glpyh|rectanglar|availabe|grabing|cusor|refering|writeable|nineth|\bommitt?ed|omited|[$][rd]elf|requrie|noticable|continous|existant|explict|agument|destionation|\bthe the\b|\bfor for\b|\bare have\b|\bare are\b|\bwith with\b|\bin in\b|\b[tw]hen then\b|\bnote sure\b|\bnote yet\b|correspondance|sprial|wholely|satisif|\bteh\b|\btje\b|\btained\b|zip.com.au' then echo '(word)' exit 1 fi if find . -name my-check-spelling.sh -prune \ -o -name \*.gz -prune \ -o -type f -print0 \ | xargs -0 egrep -nH '\bov\b|\bTH[a-ce-z]' then echo '(ov or TH)' exit 1 fi exit 0 Perl-Critic-Pulp-97/xtools/my-kwalitee.sh0000755000175000017500000000214611775434756016267 0ustar gggg#!/bin/sh # my-kwalitee.sh -- run cpants_lint kwalitee checker # Copyright 2009, 2010, 2011, 2012 Kevin Ryde # my-kwalitee.sh is shared by several distributions. # # my-kwalitee.sh is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any later # version. # # my-kwalitee.sh is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . # Module::CPANTS::Analyse set -e set -x DISTVNAME=`sed -n 's/^DISTVNAME = \(.*\)/\1/p' Makefile` if test -z "$DISTVNAME"; then echo "DISTVNAME not found" exit 1 fi if [ -e ~/bin/my-gpg-agent-daemon ]; then eval `my-gpg-agent-daemon` echo "gpg-agent $GPG_AGENT_INFO" fi TGZ="$DISTVNAME.tar.gz" make "$TGZ" cpants_lint "$TGZ" Perl-Critic-Pulp-97/xtools/my-pc.sh0000755000175000017500000000324312666236402015047 0ustar gggg#!/bin/sh # my-pc.sh -- run cpants_lint kwalitee checker # Copyright 2009, 2010, 2011, 2012, 2013, 2016 Kevin Ryde # my-pc.sh is shared by several distributions. # # my-pc.sh is free software; you can redistribute it # and/or modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 3, or (at your # option) any later version. # # my-pc.sh is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . set -x # PERLRUNINST=`sed -n 's/^PERLRUNINST = \(.*\)/\1/p' Makefile` # if test -z "$PERLRUNINST"; then # echo "PERLRUNINST not found" # exit 1 # fi EXE_FILES=`sed -n 's/^EXE_FILES = \(.*\)/\1/p' Makefile` TO_INST_PM=`find lib -name \*.pm` LINT_FILES="Makefile.PL $EXE_FILES $TO_INST_PM" if test -e "t/*.t"; then LINT_FILES="$LINT_FILES t/*.t" fi if test -e "xt/*.t"; then LINT_FILES="$LINT_FILES xt/*.t" fi for i in t xt examples devel; do if test -e "$i/*.pl"; then LINT_FILES="$LINT_FILES $i/*.pl" fi if test -e "$i/*.pm"; then LINT_FILES="$LINT_FILES $i/*.pm" fi done # perl -e 'use Test::Vars; all_vars_ok()' # MyMakeMakerExtras_Pod_Coverage perl -e 'use Pod::Coverage package => $class' podlinkcheck -I lib `ls $LINT_FILES | grep -v '\.bash$$|\.desktop$$\.png$$|\.xpm$$'` podchecker -nowarnings `ls $LINT_FILES | grep -v '\.bash$$|\.desktop$$\.png$$|\.xpm$$'` perlcritic $LINT_FILES Perl-Critic-Pulp-97/xtools/my-deb.sh0000755000175000017500000001101513525170710015165 0ustar gggg#!/bin/sh # my-deb.sh -- make .deb # Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2017, 2018, 2019 Kevin Ryde # my-deb.sh is shared by several distributions. # # my-deb.sh is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any later # version. # # my-deb.sh is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . # warnings::unused broken by perl 5.14, so use 5.10 for checks set -e set -x DISTNAME=`sed -n 's/^DISTNAME = \(.*\)/\1/p' Makefile` if test -z "$DISTNAME"; then echo "DISTNAME not found" exit 1 fi echo "DISTNAME $DISTNAME" VERSION=`sed -n 's/^VERSION = \(.*\)/\1/p' Makefile` if test -z "$VERSION"; then echo "VERSION not found" exit 1 fi echo "VERSION $VERSION" DISTVNAME=`sed -n 's/^DISTVNAME = \(.*\)/\1/p' Makefile` if test -z "$DISTVNAME"; then echo "DISTVNAME not found" exit 1 fi DISTVNAME=`echo "$DISTVNAME" | sed "s/[$][(]VERSION[)]/$VERSION/"` DISTVNAME=`echo "$DISTVNAME" | sed "s/[$][(]DISTNAME[)]/$DISTNAME/"` echo "DISTVNAME $DISTVNAME" XS_FILES=`sed -n 's/^XS_FILES = \(.*\)/\1/p' Makefile` EXE_FILES=`sed -n 's/^EXE_FILES = \(.*\)/\1/p' Makefile` if test "$DISTNAME" = pngtextadd then DPKG_ARCH=`dpkg --print-architecture` elif test -n "$XS_FILES" then DPKG_ARCH=`dpkg --print-architecture` else DPKG_ARCH=all fi echo "DPKG_ARCH $DPKG_ARCH" # programs named after the dist, libraries named with "lib" # gtk2-ex-splash and wx-perl-podbrowser programs are lib too though DEBNAME=`echo $DISTNAME | tr A-Z a-z` DEBNAME=`echo $DEBNAME | sed 's/app-//'` IS_PERL_LIB=0 if test -f Makefile.PL; then # Perl modules IS_PERL_LIB=1 fi if test -n "$EXE_FILES"; then # Perl programs IS_PERL_LIB=0 fi case $DISTNAME in # these have EXE_FILES programs but still named lib...-perl Gtk2-Ex-Splash|Wx-Perl-PodBrowser) IS_PERL_LIB=1 ;; esac if test $IS_PERL_LIB = 1; then DEBNAME="lib${DEBNAME}-perl" fi echo "DEBNAME $DEBNAME" DEBVNAME="${DEBNAME}_$VERSION-0.1" DEBFILE="${DEBVNAME}_$DPKG_ARCH.deb" echo "DEBVNAME $DEBVNAME" echo "DEBFILE $DEBFILE" # ExtUtils::MakeMaker 6.42 of perl 5.10.0 makes "$(DISTVNAME).tar.gz" depend # on "$(DISTVNAME)" distdir directory, which is always non-existent after a # successful dist build, so the .tar.gz is always rebuilt. # # So although the .deb depends on the .tar.gz don't express that here or it # rebuilds the .tar.gz every time. # # The right rule for the .tar.gz would be to depend on the files which go # into it of course ... # # DISPLAY is unset for making a deb since under fakeroot gtk stuff may try # to read config files like ~/.pangorc from root's home dir /root/.pangorc, # and that dir will be unreadable by ordinary users (normally), provoking # warnings and possible failures from nowarnings(). # test -f $DISTVNAME.tar.gz || make $DISTVNAME.tar.gz debver="`dpkg-parsechangelog -c1 | sed -n -r -e 's/^Version: (.*)-[0-9.]+$/\1/p'`" echo "debver $debver", want $VERSION test "$debver" = "$VERSION" rm -rf $DISTVNAME tar xfz $DISTVNAME.tar.gz unset DISPLAY; export DISPLAY cd $DISTVNAME if test -d examples; then if ! grep _examples debian/rules; then echo "examples directory not in debian/rules" fi fi dpkg-checkbuilddeps debian/control fakeroot debian/rules binary cd .. rm -rf $DISTVNAME #------------------------------------------------------------------------------ # source .dsc cp $DISTVNAME.tar.gz ${DEBNAME}_$VERSION.orig.tar.gz tar xfz ${DEBNAME}_$VERSION.orig.tar.gz if test "$DISTVNAME" != "$DEBNAME-$VERSION"; then mv -T $DISTVNAME $DEBNAME-$VERSION fi dpkg-source -b $DEBNAME-$VERSION ${DEBNAME}_$VERSION.orig.tar.gz rm -rf $DEBNAME-$VERSION #------------------------------------------------------------------------------ # lintian .deb and source lintian -I -i \ --suppress-tags new-package-should-close-itp-bug,desktop-entry-contains-encoding-key,command-in-menu-file-and-desktop-file,emacsen-common-without-dh-elpa,bugs-field-does-not-refer-to-debian-infrastructure \ $DEBFILE lintian -I -i \ --suppress-tags maintainer-upload-has-incorrect-version-number,changelog-should-mention-nmu,empty-debian-diff,debian-rules-uses-deprecated-makefile,testsuite-autopkgtest-missing *.dsc exit 0 Perl-Critic-Pulp-97/xtools/my-manifest.sh0000755000175000017500000000165211764227757016270 0ustar gggg#!/bin/sh # my-manifest.sh -- update MANIFEST file # Copyright 2009, 2010, 2011, 2012 Kevin Ryde # my-manifest.sh is shared by several distributions. # # my-manifest.sh is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any later # version. # # my-manifest.sh is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . set -e if [ -e MANIFEST ]; then mv MANIFEST MANIFEST.old || true fi touch SIGNATURE ( make manifest 2>&1; diff -u MANIFEST.old MANIFEST ) | ${PAGER:-more} Perl-Critic-Pulp-97/xtools/my-check-copyright-years.sh0000755000175000017500000000504513360263206020645 0ustar gggg#!/bin/sh # my-check-copyright-years.sh -- check copyright years in dist # Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2017, 2018 Kevin Ryde # my-check-copyright-years.sh is shared by several distributions. # # my-check-copyright-years.sh is free software; you can redistribute it # and/or modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 3, or (at your # option) any later version. # # my-check-copyright-years.sh is distributed in the hope that it will be # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . set -e # die on error set -x # echo # find files in the dist with mod times this year, but without this year in # the copyright line if test -z "$DISTVNAME"; then DISTVNAME=`sed -n 's/^DISTVNAME = \(.*\)/\1/p' Makefile` fi case $DISTVNAME in *\$*) DISTVNAME=`make echo-DISTVNAME` ;; esac if test -z "$DISTVNAME"; then echo "DISTVNAME not set and not in Makefile" exit 1 fi TARGZ="$DISTVNAME.tar.gz" if test -e "$TARGZ"; then :; else pwd echo "TARGZ $TARGZ not found" exit 1 fi MY_HIDE= year=`date +%Y` result=0 # files with dates $year tar tvfz $TARGZ \ | egrep "$year-|debian/copyright" \ | sed "s:^.*$DISTVNAME/::" \ | { while read i do # echo "consider $i" GREP=grep case $i in \ '' | */ \ | ppport.h \ | debian/changelog | debian/doc-base \ | debian/compat | debian/emacsen-compat | debian/source/format \ | debian/patches/*.diff \ | COPYING | MANIFEST* | SIGNATURE | META.yml | META.json \ | version.texi | */version.texi \ | *utf16* | examples/rs''s2lea''fnode.conf \ | */MathI''mage/ln2.gz | */MathI''mage/pi.gz \ | *.mo | *.locatedb* | t/samp.* \ | t/empty.dat | t/*.xpm | t/*.xbm | t/*.jpg | t/*.gif \ | t/*.g${MY_HIDE}d \ | tools/*-oeis-samples.gp \ | test-oeis-samples.gp \ | tools/configurations-gfs-generated.gp \ | devel/configurations-t-generated.gp \ | test-symbols.txt | test-funcs.txt \ | devel/minimal-domsets-max-even2.c \ | */_whizzy*) continue ;; *.gz) GREP=zgrep esac; \ if test -e "$srcdir/$i" then f="$srcdir/$i" else f="$i" fi if $GREP -q -e "Copyright.*$year" $f then :; else echo "$i:1: this file" grep Copyright $f result=1 fi done } exit $result Perl-Critic-Pulp-97/xt/0002755000175000017500000000000013552456763012577 5ustar ggggPerl-Critic-Pulp-97/xt/0-Test-ConsistentVersion.t0000644000175000017500000000225311655356324017527 0ustar gggg#!/usr/bin/perl -w # 0-Test-ConsistentVersion.t -- run Test::ConsistentVersion if available # Copyright 2011 Kevin Ryde # 0-Test-ConsistentVersion.t is shared by several distributions. # # 0-Test-ConsistentVersion.t is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # 0-Test-ConsistentVersion.t is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . use 5.004; use strict; use Test::More; eval { require Test::ConsistentVersion } or plan skip_all => "due to Test::ConsistentVersion not available -- $@"; Test::ConsistentVersion::check_consistent_versions (no_readme => 1, # no version number in my READMEs no_pod => 1, # no version number in my docs, at the moment ); # ! -e 'README'); exit 0; Perl-Critic-Pulp-97/xt/0-Test-Synopsis.t0000755000175000017500000000176411655356314015667 0ustar gggg#!/usr/bin/perl -w # 0-Test-Synopsis.t -- run Test::Synopsis if available # Copyright 2009, 2010, 2011 Kevin Ryde # 0-Test-Synopsis.t is shared by several distributions. # # 0-Test-Synopsis.t is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any later # version. # # 0-Test-Synopsis.t is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . use 5.004; use strict; use Test::More; eval 'use Test::Synopsis; 1' or plan skip_all => "due to Test::Synopsis not available -- $@"; ## no critic (ProhibitCallsToUndeclaredSubs) all_synopsis_ok(); exit 0; Perl-Critic-Pulp-97/xt/0-no-debug-left-on.t0000755000175000017500000000701613166050667016162 0ustar gggg#!/usr/bin/perl -w # 0-no-debug-left-on.t -- check no Smart::Comments left on # Copyright 2011, 2012, 2017 Kevin Ryde # 0-no-debug-left-on.t is shared by several distributions. # # 0-no-debug-left-on.t is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # 0-no-debug-left-on.t is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . # cf Test::NoSmartComments which uses Module::ScanDeps. require 5; use strict; Test::NoDebugLeftOn->Test_More(verbose => 0); exit 0; package Test::NoDebugLeftOn; use strict; use ExtUtils::Manifest; sub Test_More { my ($class, %options) = @_; require Test::More; Test::More::plan (tests => 1); Test::More::ok ($class->check (diag => \&Test::More::diag, %options)); 1; } sub check { my ($class, %options) = @_; my $diag = $options{'diag'}; if (! -e 'Makefile.PL') { &$diag ('skip, no Makefile.PL so not ExtUtils::MakeMaker'); return 1; } my $href = ExtUtils::Manifest::maniread(); my @files = keys %$href; my $good = 1; my @perl_files = grep {m{ ^lib/ |^(lib|examples|x?t)/.*\.(p[lm]|t)$ |^Makefile.PL$ |^[^/]+$ }x } @files; my $filename; foreach $filename (@perl_files) { if ($options{'verbose'}) { &$diag ("perl file ",$filename); } if (! open FH, "< $filename") { &$diag ("Oops, cannot open $filename: $!"); $good = 0; next; } while () { if (/^__END__/) { last; } # only a DEBUG=> non-zero number is bad, so an expression can copy a # debug from another package if (/(DEBUG\s*=>\s*[1-9][0-9]*)/ || /^[ \t]*((use|no) (Smart|Devel)::Comments)/ ) { print STDERR "\n$filename:$.: leftover: $_\n"; $good = 0; } # no "use lib ... devel", except in xt/*.t unless ($filename =~ /\bxt\b/) { if (/^[ \t]*(use lib\b.*devel.*)/) { print STDERR "\n$filename:$.: leftover: $_\n"; $good = 0; } } } if (! close FH) { &$diag ("Oops, error closing $filename: $!"); $good = 0; next; } } my @C_files = grep {m{ # toplevel or lib .c and .xs files ^[^/]*\.([ch]|xs)$ |^(lib|examples|x?t)/.*\.([ch]|xs)$ }x } @files; foreach $filename (@C_files) { if ($options{'verbose'}) { &$diag ("C/XS file ",$filename); } if (! open FH, "< $filename") { &$diag ("Oops, cannot open $filename: $!"); $good = 0; next; } while () { if (/^#\s*define\s+DEBUG\s+[1-9]/ ) { print STDERR "\n$filename:$.: leftover: $_\n"; $good = 0; } } if (! close FH) { &$diag ("Oops, error closing $filename: $!"); $good = 0; next; } } &$diag ("checked ",scalar(@perl_files)," perl files, ", scalar(@C_files)," C/XS files\n"); return $good; } Perl-Critic-Pulp-97/xt/0-file-is-part-of.t0000644000175000017500000000622212536755447016021 0ustar gggg#!/usr/bin/perl -w # Copyright 2011, 2012, 2013, 2015 Kevin Ryde # 0-file-is-part-of.t is shared by several distributions. # # 0-file-is-part-of.t is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # 0-file-is-part-of.t is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . require 5; use strict; use Test::More tests => 1; use lib 't'; use MyTestHelpers; BEGIN { MyTestHelpers::nowarnings(); } ok (Test::FileIsPartOfDist->check(verbose=>1), 'Test::FileIsPartOfDist'); exit 0; package Test::FileIsPartOfDist; BEGIN { require 5 } use strict; use ExtUtils::Manifest; use File::Slurp; # uncomment this to run the ### lines # use Smart::Comments; sub import { my $class = shift; my $arg; foreach $arg (@_) { if ($arg eq '-test') { require Test; Test::plan(tests=>1); is ($class->check, 1, 'Test::FileIsPartOfDist'); } } return 1; } sub new { my $class = shift; return bless { @_ }, $class; } sub check { my $class = shift; my $self = $class->new(@_); my $manifest = ExtUtils::Manifest::maniread(); if (! $manifest) { $self->diag("no MANIFEST perhaps"); return 0; } my @filenames = keys %$manifest; my $distname = $self->makefile_distname; if (! defined $distname) { $self->diag("Oops, DISTNAME not found in Makefile"); return 0; } if ($self->{'verbose'}) { $self->diag("DISTNAME $distname"); } my $good = 1; my $filename; foreach $filename (@filenames) { if (! $self->check_file_is_part_of($filename,$distname)) { $good = 0; } } return $good; } sub makefile_distname { my ($self) = @_; my $filename = "Makefile"; my $content = File::Slurp::read_file ($filename); if (! defined $content) { $self->diag("Cannot read $filename: $!"); return undef; } my $distname; if ($content =~ /^DISTNAME\s*=\s*([^#\n]*)/m) { $distname = $1; $distname =~ s/\s+$//; ### $distname if ($distname eq 'App-Chart') { $distname = 'Chart'; } # hack } return $distname; } sub check_file_is_part_of { my ($self, $filename, $distname) = @_; my $content = File::Slurp::read_file ($filename); if (! defined $content) { $self->diag("Cannot read $filename: $!"); return 0; } $content =~ /([T]his file is part of[^\n]*)/i or return 1; my $got = $1; if ($got =~ /[T]his file is part of \Q$distname\E\b/i) { return 1; } $self->diag("$filename: $got"); $self->diag("expected DISTNAME: $distname"); return 0; } sub diag { my $self = shift; my $func = $self->{'diag_func'} || eval { Test::More->can('diag') } || \&_diag; &$func(@_); } sub _diag { my $msg = join('', map {defined($_)?$_:'[undef]'} @_)."\n"; $msg =~ s/^/# /mg; print STDERR $msg; } Perl-Critic-Pulp-97/xt/0-Test-DistManifest.t0000755000175000017500000000231111655356331016416 0ustar gggg#!/usr/bin/perl -w # 0-Test-DistManifest.t -- run Test::DistManifest if available # Copyright 2009, 2010, 2011 Kevin Ryde # 0-Test-DistManifest.t is shared by several distributions. # # 0-Test-DistManifest.t is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # 0-Test-DistManifest.t is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . use 5.004; use strict; use Test::More; # This is only an author test really and it only really does much in a # working directory where newly added files will exist. In a dist dir # something would have to be badly wrong for the manifest to be off. eval { require Test::DistManifest } or plan skip_all => "due to Test::DistManifest not available -- $@"; Test::DistManifest::manifest_ok(); exit 0; Perl-Critic-Pulp-97/xt/0-Test-YAML-Meta.t0000755000175000017500000000346113046214104015444 0ustar gggg#!/usr/bin/perl -w # 0-Test-YAML-Meta.t -- run Test::CPAN::Meta::YAML if available # Copyright 2009, 2010, 2011, 2013, 2014, 2017 Kevin Ryde # 0-Test-YAML-Meta.t is shared by several distributions. # # 0-Test-YAML-Meta.t is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any later # version. # # 0-Test-YAML-Meta.t is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . use 5.004; use strict; use Test::More; my $meta_filename = 'META.yml'; unless (-e $meta_filename) { plan skip_all => "$meta_filename doesn't exist -- assume this is a working directory not a dist"; } plan tests => 3; SKIP: { eval { require CPAN::Meta::Validator; 1 } or skip "due to CPAN::Meta::Validator not available -- $@"; eval { require YAML; 1 } or skip "due to YAML module not available -- $@", 1; diag "CPAN::Meta::Validator version ", CPAN::Meta::Validator->VERSION; my $struct = YAML::LoadFile ($meta_filename); my $cmv = CPAN::Meta::Validator->new($struct); ok ($cmv->is_valid); if (! $cmv->is_valid) { diag "CPAN::Meta::Validator errors:"; foreach ($cmv->errors) { diag $_; } } } { # Test::CPAN::Meta::YAML version 0.15 for upper case "optional_features" names # eval 'use Test::CPAN::Meta::YAML 0.15; 1' or plan skip_all => "due to Test::CPAN::Meta::YAML 0.15 not available -- $@"; Test::CPAN::Meta::YAML::meta_spec_ok('META.yml'); } exit 0; Perl-Critic-Pulp-97/xt/0-META-read.t0000755000175000017500000001071512136177162014553 0ustar gggg#!/usr/bin/perl -w # 0-META-read.t -- check META.yml can be read by various YAML modules # Copyright 2009, 2010, 2011, 2012, 2013 Kevin Ryde # 0-META-read.t is shared among several distributions. # # 0-META-read.t is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation; either version 3, or (at your option) any later # version. # # 0-META-read.t is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . use 5.005; use strict; use Test::More; use lib 't'; use MyTestHelpers; BEGIN { MyTestHelpers::nowarnings(); } # When some of META.yml is generated by explicit text in Makefile.PL it can # be easy to make a mistake in the syntax, or indentation, etc, so the idea # here is to check it's readable from some of the YAML readers. # # The various readers differ in how strictly they look at the syntax. # There's no attempt here to say one of them is best or tightest or # whatever, just see that they all work. # # See 0-Test-YAML-Meta.t for Test::YAML::Meta which looks into field # contents, as well as maybe the YAML formatting. my $meta_filename; # allow for ancient perl, maybe eval { require FindBin; 1 } # new in 5.004 or plan skip_all => "FindBin not available -- $@"; eval { require File::Spec; 1 } # new in 5.005 or plan skip_all => "File::Spec not available -- $@"; diag "FindBin $FindBin::Bin"; $meta_filename = File::Spec->catfile ($FindBin::Bin, File::Spec->updir, 'META.yml'); -e $meta_filename or plan skip_all => "$meta_filename doesn't exist -- assume this is a working directory not a dist"; plan tests => 5; SKIP: { eval { require YAML; 1 } or skip "due to YAML module not available -- $@", 1; my $ok = eval { YAML::LoadFile ($meta_filename); 1 } or diag "YAML::LoadFile() error -- $@"; ok ($ok, "Read $meta_filename with YAML module"); } # YAML 0.68 is in fact YAML::Old, or something weird -- don't think they can # load together # # SKIP: { # eval { require YAML::Old; 1 } # or skip 'due to YAML::Old not available -- $@', 1; # # eval { YAML::Old::LoadFile ($meta_filename) }; # is ($@, '', # "Read $meta_filename with YAML::Old"); # } SKIP: { eval { require YAML::Syck; 1 } or skip "due to YAML::Syck not available -- $@", 1; my $ok = eval { YAML::Syck::LoadFile ($meta_filename); 1 } or diag "YAML::Syck::LoadFile() error -- $@"; ok ($ok, "Read $meta_filename with YAML::Syck"); } SKIP: { eval { require YAML::Tiny; 1 } or skip "due to YAML::Tiny not available -- $@", 1; my $ok = eval { YAML::Tiny->read ($meta_filename); 1 } or diag "YAML::Tiny->read() error -- $@"; ok ($ok, "Read $meta_filename with YAML::Tiny"); } SKIP: { eval { require YAML::XS; 1 } or skip "due to YAML::XS not available -- $@", 1; my $ok = eval { YAML::XS::LoadFile ($meta_filename); 1 } or diag "YAML::XS::LoadFile() error -- $@"; ok ($ok, "Read $meta_filename with YAML::XS"); } # Parse::CPAN::Meta describes itself for use on "typical" META.yml, so not # sure if demanding it works will more exercise its subset of yaml than the # correctness of our META.yml. At any rate might like to know if it fails, # so as to avoid tricky yaml for everyone's benefit, maybe. # SKIP: { eval { require Parse::CPAN::Meta; 1 } or skip "due to Parse::CPAN::Meta not available -- $@", 1; my $ok = eval { Parse::CPAN::Meta::LoadFile ($meta_filename); 1 } or diag "Parse::CPAN::Meta::LoadFile() error -- $@"; ok ($ok, "Read $meta_filename with Parse::CPAN::Meta::LoadFile"); } # Data::YAML::Reader 0.06 doesn't like header "--- #YAML:1.0" with the # # part produced by other YAML writers, so skip for now # # SKIP: { # eval { require Data::YAML::Reader; 1 } # or skip 'due to Data::YAML::Reader not available -- $@', 1; # # my $reader = Data::YAML::Reader->new; # open my $fh, '<', $meta_filename # or die "Cannot open $meta_filename"; # my $str = do { local $/=undef; <$fh> }; # close $fh or die; # # # if ($str !~ /\.\.\.$/) { # # $str .= "..."; # # } # my @lines = split /\n/, $str; # push @lines, "..."; # use Data::Dumper; # print Dumper(\@lines); # # # { local $,="\n"; print @lines,"\n"; } exit 0; Perl-Critic-Pulp-97/xt/policy-lists.t0000644000175000017500000000470012111612241015365 0ustar gggg#!/usr/bin/perl -w # Copyright 2013 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any later # version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # Check that the supported fields described in each pod matches what the # code says. use 5.005; use strict; use FindBin; use ExtUtils::Manifest; use List::Util 'max'; use File::Spec; use Test::More; use lib 't','xt'; use MyTestHelpers; BEGIN { MyTestHelpers::nowarnings() } # uncomment this to run the ### lines # use Smart::Comments; plan tests => 1; my $toplevel_dir = File::Spec->catdir ($FindBin::Bin, File::Spec->updir); my $manifest_file = File::Spec->catfile ($toplevel_dir, 'MANIFEST'); my $manifest = ExtUtils::Manifest::maniread ($manifest_file); my @lib_policies = map {m{^lib/Perl/Critic/Policy/(.+)\.pm$} ? $1 : ()} keys %$manifest; foreach (@lib_policies) { s{/}{::} } @lib_policies = sort @lib_policies; ### @lib_policies diag "module policies count ",scalar(@lib_policies); #------------------------------------------------------------------------------ { open FH, 'lib/Perl/Critic/Pulp.pm' or die $!; my $content = do { local $/; }; # slurp close FH or die; # ### $content { $content =~ /=for my_pod policy_list begin(.*)=for my_pod policy_list end/s or die "pulp_list not matched, content:\n",$content; my $pulp_list = $1; my @pulp_list; while ($pulp_list =~ /^=item L<([^|]+)/mg) { push @pulp_list, $1; } @pulp_list = sort @pulp_list; ### @pulp_list diag "pulp list count ",scalar(@pulp_list); my $s = join(', ',@pulp_list); my $l = join(', ',@lib_policies); is ($s, $l, 'Pulp.pm policy list'); my $j = "$s\n$l"; $j =~ /^(.*)(.*)\n\1(.*)/ or die; my $sd = $2; my $ld = $3; if ($sd) { diag "pulp list: ",$sd; diag "modules: ",$ld; } } } #------------------------------------------------------------------------------ exit 0; Perl-Critic-Pulp-97/xt/0-Test-Pod.t0000755000175000017500000000175111655356337014563 0ustar gggg#!/usr/bin/perl -w # 0-Test-Pod.t -- run Test::Pod if available # Copyright 2009, 2010, 2011 Kevin Ryde # 0-Test-Pod.t is shared by several distributions. # # 0-Test-Pod.t is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the Free # Software Foundation; either version 3, or (at your option) any later # version. # # 0-Test-Pod.t is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . use 5.004; use strict; use Test::More; # all_pod_files_ok() is new in Test::Pod 1.00 # eval 'use Test::Pod 1.00; 1' or plan skip_all => "due to Test::Pod 1.00 not available -- $@"; Test::Pod::all_pod_files_ok(); exit 0; Perl-Critic-Pulp-97/Makefile.PL0000755000175000017500000001126713074053433014110 0ustar gggg#!/usr/bin/perl -w # Copyright 2008, 2009, 2010, 2011, 2012, 2014, 2015, 2017 Kevin Ryde # This file is part of Perl-Critic-Pulp. # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use 5.006; use strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile (NAME => 'Perl::Critic::Pulp', ABSTRACT => 'Some add-on policies for Perl::Critic.', VERSION_FROM => 'lib/Perl/Critic/Pulp.pm', AUTHOR => 'Kevin Ryde ', LICENSE => 'gpl_3', SIGN => 1, MIN_PERL_VERSION => '5.006', PREREQ_PM => { # 1.220 for its incompatible PPI::Statement::Sub->prototype() 'PPI' => '1.220', 'PPI::Document' => 0, # actually PPI::Dumper only used in the .t scripts if # there's an error ... 'PPI::Dumper' => 0, # 1.082 or some such for new style parameter specs # 1.084 for highest_explicit_perl_version() method 'Perl::Critic' => '1.084', # parts of Perl::Critic, used so name them explicitly 'Perl::Critic::Policy' => '1.084', # Utils 1.100 for precedence_of() supporting -f etc filetests 'Perl::Critic::Utils' => '1.100', 'Perl::Critic::Utils::PPI' => 0, 'Perl::Critic::Violation' => 0, # Required by Perl::Critic itself anyway. # 1.02 for avoiding leaks in perl 5.8, probably # something newer has more merit though 'IO::String' => '1.02', # Also used by Perl::Critic itself. Maybe should # require 0.24 for various XS bugfixes. 'List::MoreUtils' => '0.24', # 0.24 for stack growing, maybe # Could make this optional, but it doesn't drag in anything # outrageous. 'Pod::MinimumVersion' => 50, # v.50 fix text in =item etc # Builtin in recent perl anyway. 'List::Util' => 0, 'Test::More' => 0, 'Scalar::Util' => 0, # Required by Perl::Critic itself anyway, # and comes with perl 5.10 anyway too. 'version' => 0, 'Pod::Escapes' => 0, 'Pod::Parser' => 0, 'Pod::ParseLink' => 0, }, META_MERGE => { 'meta-spec' => { version => 2 }, resources => { homepage => 'http://user42.tuxfamily.org/perl-critic-pulp/index.html', license => 'http://www.gnu.org/licenses/gpl.html', }, # don't index "package Perl::MinimumVersion" additions there no_index => { package => [ 'Perl::MinimumVersion' ], directory=>['devel','xt'], }, recommends => { 'Perl::MinimumVersion' => 0, }, prereqs => { test => { suggests => { 'Perl::MinimumVersion' => 0, }, }, }, optional_features => { maximum_policies => { description => 'Have the policies check as much as possible.', prereqs => { runtime => { requires => { 'Perl::MinimumVersion' => 0, }, }, }, }, }, }, ); # maximum_devel => # { description => 'Stuff used variously for development.', # requires => { 'PPI::Document' => 0, # 'Perl::MinimumVersion' => 0, # 'Encode' => 0, # 'Perl6::Slurp' => 0, # 'Regexp::Common' => 0, # 'Devel::Mallinfo' => 0, # 'IO::Uncompress::AnyInflate' => 0, # 'lib::abs' => 0, # 'IO::String' => 0, # 'Digest::MD5' => 0, # 'I18N::Langinfo' => 0, # 'Locale::TextDomain' => 0, # 'File::Locate' => 0, # # 'File::Locate::Iterator' => 0, # mine # # parts of File::Locate::Iterator # 'Iterator::Simple' => 0, # 'Iterator::Simple::Locate' => 0, # }, # }, Perl-Critic-Pulp-97/devel/0002755000175000017500000000000013552456763013243 5ustar ggggPerl-Critic-Pulp-97/devel/grep-fat-comma.pl0000644000175000017500000000432512326663420016365 0ustar gggg#!/usr/bin/perl -w # Copyright 2009, 2010, 2011, 2013, 2014 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # cf # egrep -nH -ire '[^[a-z-]-[a-ln-z0-9][a-z0-9]*::' /usr/share/perl/5.10 # /usr/share/perl/5.14/Math/Complex.pm:712: -CORE::exp(CORE::log(-$z)/3) : # /usr/share/perl/5.14/Math/Complex.pm:1043: my $v = -CORE::log($alpha + CORE::sqrt($alpha*$alpha-1)); # cf \c control characters in lower case # XML::RSS::TimingBot \cm\cj use 5.005; use strict; use warnings; use Perl::Critic::Utils 'is_perl_builtin'; use lib::abs '.'; use MyLocatePerl; use MyStuff; # uncomment this to run the ### lines # use Smart::Comments; my $verbose = 0; my $l = MyLocatePerl->new; while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } # if ($str =~ /^__END__/m) { # substr ($str, $-[0], length($str), ''); # } # strip comments # $str =~ s/#.*//mg; while ($str =~ /((^|[^>A-Za-z])(\w+) ([ \t]*(\#[^\n]*)?\n)+ [ \t]*=> )/sgx) { my $whole = $1; my $word = $3; next unless is_perl_builtin(_sans_dash($word)); my $pos_end = pos($str); my $pos = $pos_end - length($whole) + 1; my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); my $l1 = MyStuff::line_at_pos($str, $pos); my $l2 = MyStuff::line_at_pos($str, $pos_end); ### $l1 # substr($s,0,$col) =~ /q[qx]|"/ or next; print "$filename:$line:$col:\n $l1 $l2"; } } sub _sans_dash { my ($str) = @_; $str =~ s/^-//; return $str; } exit 0; __END__ print # foo => '123', -caller # jkdf => '123', Perl-Critic-Pulp-97/devel/notwithcompare.pl0000755000175000017500000000272711424406722016636 0ustar gggg#!/usr/bin/perl -w # Copyright 2008, 2009, 2010 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use strict; use warnings; use Data::Dumper; { sub func1 { print "func1 $_[0]\n" } sub func2 ($) { print "func2 $_[0]\n" } my $x = 0; if (! func1 $x != 123) { print "yes\n"; } else { print "no\n"; } if (! func2 $x != 123) { print "yes\n"; } else { print "no\n"; } exit 0; } { my $x = 'b'; if (! $x eq 'a') { print "yes\n"; } else { print "no\n"; } } { my $attribs = 1; my $x = !( $attribs & 1 ) << 1; $x = !( $attribs & 1 ); $x = $x << 1; # $attribs = 0; # $x = $attribs & 1; # $x = ($x) << 1; print Dumper($x); } # use Test::More tests => 1; # Test::More::eq_array(123, 456); # Test::More::is_deeply([123], [456]); { my $x = 'a'; if (! $x =~ /b/) { print "yes\n"; } else { print "no\n"; } } # ! $x + $y == 1 exit 0; Perl-Critic-Pulp-97/devel/grep-duplicate-use.pl0000644000175000017500000000454112277565746017306 0ustar gggg#!/usr/bin/perl -w # Copyright 2013, 2014 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # Usage: perl grep-duplicate-use.pl # use 5.010; use strict; use lib::abs '.'; use MyLocatePerl; use MyStuff; use MyStuff; # uncomment this to run the ### lines #use Smart::Comments; my $verbose = 0; my $l = MyLocatePerl->new (exclude_t => 1, under_directory => '/usr/share/perl5', # under_directory => '/usr/share/perl/5.14/', # under_directory => "$ENV{HOME}/p/", # under_directory => "/usr/share/perl5/Wx/DemoHints/", ); my $count; { while (my ($filename, $content) = $l->next) { file ($filename, $content); } exit 0; } sub file { my ($filename, $str) = @_; if ($verbose) { print "$filename\n"; } # ([A-Za-z0-9_:]*)/mg) { # [ \t]* my %seen; my $package = 'main'; while ($str =~ /^(__END__)|^(use|no|package)[ \t\r\n]+([^;]*)/mg) { last if $1; my $type = $2; my $module = $3; my $pos = pos($str)-length($module); $module =~ s/[ \t\r\n]+/ /g; $module =~ s/^[ \t\r\n]+//g; $module =~ s/[ \t\r\n]+$//g; # next if $module eq 'integer'; # pragma if ($type eq 'package') { $package = $module; next; } if ($type eq 'no') { delete $seen{$package}->{$module}; # = 'pragma'; next; } if ($seen{$package}->{$module}) { if ($seen{$package}->{$module} eq 'pragma') { next; } my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); print "$filename:$line:$col: (package $package)\n", MyStuff::line_at_pos($str, $pos); } else { $seen{$package}->{$module} = 1; } } } exit 0; Perl-Critic-Pulp-97/devel/grep-pod-verbatim-unindent.pl0000644000175000017500000000504712326663443020743 0ustar gggg#!/usr/bin/perl -w # Copyright 2009, 2010, 2011, 2014 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # various # some DB<1> debugger prompts use 5.005; use strict; use warnings; use Perl6::Slurp; use lib::abs '.'; use MyLocatePerl; use MyStuff; use FindBin; my $script_filename = File::Spec->catfile ($FindBin::Bin, $FindBin::Script); # uncomment this to run the ### lines #use Smart::Comments; my $verbose = 0; my $parser = MyParser->new; $parser->errorsub(sub{1}); # no error prints $parser->parse_from_file ($script_filename); #exit 0; my $l = MyLocatePerl->new (include_pod => 1, exclude_t => 1); while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } if ($str =~ /^__END__/m) { substr ($str, $-[0], length($str), ''); } $parser->parse_from_string ($str, $filename); } package MyParser; use strict; use warnings; use base 'Pod::Parser'; sub parse_from_string { my ($self, $str, $filename) = @_; require IO::String; my $fh = IO::String->new ($str); $self->{_INFILE} = $filename; return $self->parse_from_filehandle ($fh); } sub command { my ($self, $command) = @_; if ($command eq 'begin') { $self->{'in_begin'} = 1; } elsif ($command eq 'end') { $self->{'in_begin'} = 0; } return ''; } sub verbatim { my ($self, $text, $linenum, $paraobj) = @_; ### verbatim: $text return if $self->{'in_begin'}; if ($text =~ /\n=[^\n]*/g) { my $pos = pos($text); my $initial = substr($text,0,$pos); my $filename = $self->{_INFILE}; print "$filename:$linenum:1: verbatim runs over directive:\n$initial\n"; } if ($text =~ /\n\S[^\n]*/g) { my $pos = pos($text); my $initial = substr($text,0,$pos); my $filename = $self->{_INFILE}; print "$filename:$linenum:1: unindented verbatim:\n$initial\n"; } } sub textblock { my ($self, $text, $linenum, $paraobj) = @_; return ''; } exit 0; =pod fjksds djksf =cut Perl-Critic-Pulp-97/devel/grep-condsub.pl0000644000175000017500000000322312060735311016144 0ustar gggg#!/usr/bin/perl -w # Copyright 2009, 2010, 2012 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use 5.006; use strict; use warnings; use Regexp::Common 'comment'; use lib::abs '.'; use MyLocatePerl; use MyStuff; use Text::Tabs (); my $verbose = 0; my $l = MyLocatePerl->new; while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } if ($str =~ /^__END__/m) { substr ($str, $-[0], length($str), ''); } # strip comments $str =~ s/$RE{comment}{Perl}//og; while ($str =~ /^([ \t])+(sub [[:alnum:]]|\b(BEGIN|END|CHECK|INIT)\b)/mg) { my $pos = pos($str); my ($indent) = Text::Tabs::expand ($1); $indent = length ($indent); my $before = substr ($str, 0, $pos); $indent--; $before =~ /^ {0,$indent}(if|unless)\b/m or next; my $before_pos = $-[0]; my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); print "$filename:$line:$col:\n", MyStuff::line_at_pos($str, $before_pos), MyStuff::line_at_pos($str, $pos); } } exit 0; Perl-Critic-Pulp-97/devel/version_check.pl0000644000175000017500000000200411571602261016375 0ustar gggg#!/usr/bin/perl -w # Copyright 2010, 2011 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use strict; use warnings; use lib '.'; use lib 'devel'; use version_check 1.1; { my $v = version_check->VERSION; print "ref: ",ref $v,"\n"; } { my $ret = version_check->VERSION('0'); print "ret $ret\n"; } { my $ret = version_check->VERSION('0'); print "ret $ret\n"; } print "done\n"; Perl-Critic-Pulp-97/devel/MyStuff.pm0000644000175000017500000000656111606171461015167 0ustar gggg# Copyright 2009, 2011 Kevin Ryde. # MyStuff.pm is shared by various distributions. # # MyStuff.pm is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any later # version. # # MyStuff.pm is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . package MyStuff; use 5.010; use strict; use warnings; use Text::Tabs; #my $verbose = 0; sub line_at_pos { my ($str, $pos) = @_; my $start = (rindex ($str, "\n", $pos) || -1) + 1; my $end = (index ($str, "\n", $pos) || length($str)-1) + 1; return substr($str, $start, $end - $start); } sub pos_to_line_and_column { my ($str, $pos) = @_; $str = substr ($str, 0, $pos); my $nlpos = rindex ($str, "\n"); my $lastline = substr ($str, $nlpos+1); $lastline = Text::Tabs::expand ($lastline); my $colnum = 1 + length ($lastline); my $linenum = 1 + scalar($str =~ tr/\n//); return ($linenum, $colnum); } package Iterator::Simple::FileUniq; sub new { my ($class, $it) = (shift, shift); my $fu = FileUniq->new (@_); return Iterator::Simple::iterator (sub { my $filename; while (defined (my $filename = $it->next)) { last if $fu->uniq ($filename); } }); } package Locator; sub new { my ($class, @args) = @_; open my $fh, '-|', 'locate', '-0', '--', @args or die; return bless { fh => $fh, }, $class; } sub next { my ($self) = @_; my $fh = $self->{'fh'}; my $filename; { local $/ = "\0"; $filename = <$fh>; if (defined $filename) { chomp $filename; } } return $filename; } package Locator::BinScripts; sub new { my ($class, $type) = @_; return bless { 'type' => $type, 'locator' => Locator->new ('/bin/*', '/usr/bin/*', '/usr/local/bin/*', '/usr/local/bin2/*', ) }, $class; } sub next { my ($self) = @_; my $type = $self->{'type'}; for (;;) { my $filename = $self->{'locator'}->next // return undef; my ($fh, $buf); if (open($fh,'<',$filename) && read($fh,$buf,80) && $buf =~ m{^#![a-z0-9/]*/$type([ \t]|$)}) { return $filename; } } } package Locator::Concat; sub new { my ($class, @locators) = @_; return bless { 'locators' => \@locators }, $class; } sub next { my ($self) = @_; my $locators = $self->{'locators'}; for (;;) { @$locators or return undef; my $filename = $locators->[0]->next; if (defined $filename) { return $filename; } shift @$locators; } } 1; __END__ my @files = split /\n/, `locate \*.t \*.pm \*.pl`; @files = grep {-f $_} @files; @files = uniq_by_func (\&stat_dev_ino, @files); sub uniq_by_func { my $func = shift; my %seen; return grep { $seen{$func->($_)}++ == 0 } @_; } sub stat_dev_ino { my ($filename) = @_; my ($dev, $ino) = stat ($filename); return "$dev,$ino"; } print "look at ",scalar(@files)," files\n"; Perl-Critic-Pulp-97/devel/posix-size.pl0000644000175000017500000000547611424406722015706 0ustar gggg#!/usr/bin/perl -w # Copyright 2009, 2010 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use strict; use warnings; use Devel::Mallinfo; use POSIX; package Foo; package Bar; package Quux; my ($x, $y); my $n = 0; sub packname { ++$n; return "Pack$n" } foreach (1 .. 10) { my $package = packname(); eval "package $package;our \$VERSION = 1"; $x = Devel::Mallinfo::mallinfo()->{'uordblks'}; eval "package $package;use POSIX"; $y = Devel::Mallinfo::mallinfo()->{'uordblks'}; print "$package adds @{[$y-$x]}\n"; } foreach (1 .. 10) { my $package = packname(); eval "package $package;our \$VERSION = 1"; $x = Devel::Mallinfo::mallinfo()->{'uordblks'}; eval "package $package;use POSIX ()"; $y = Devel::Mallinfo::mallinfo()->{'uordblks'}; print "$package adds @{[$y-$x]}\n"; } package Bar; use constant FOO => 123; BEGIN { print $x = Devel::Mallinfo::mallinfo()->{'uordblks'},"\n"; } use POSIX; BEGIN { print $y = Devel::Mallinfo::mallinfo()->{'uordblks'},"\n"; } BEGIN { print __PACKAGE__." adds ", $y-$x,"\n"; } print "Bar count ",scalar(keys %Bar::),"\n"; #{ local $, = "\n"; print keys %Bar::,"\n"; } package Quux; BEGIN { print $x = Devel::Mallinfo::mallinfo()->{'uordblks'},"\n"; } use POSIX; BEGIN { print $y = Devel::Mallinfo::mallinfo()->{'uordblks'},"\n"; } BEGIN { print __PACKAGE__." adds ", $y-$x,"\n"; } print "Quux count ",scalar(keys %Quux::),"\n"; package Four; use constant FOO => 123; BEGIN { print $x = Devel::Mallinfo::mallinfo()->{'uordblks'},"\n"; } use POSIX qw(dup); BEGIN { print $y = Devel::Mallinfo::mallinfo()->{'uordblks'},"\n"; } BEGIN { print __PACKAGE__." adds ", $y-$x,"\n"; } package Five; use constant FOO => 123; BEGIN { print $x = Devel::Mallinfo::mallinfo()->{'uordblks'},"\n"; } use POSIX (); BEGIN { print $y = Devel::Mallinfo::mallinfo()->{'uordblks'},"\n"; } BEGIN { print __PACKAGE__." adds ", $y-$x,"\n"; } package Six; use constant FOO => 123; BEGIN { print $x = Devel::Mallinfo::mallinfo()->{'uordblks'},"\n"; } use POSIX qw(dup EBADF); BEGIN { print $y = Devel::Mallinfo::mallinfo()->{'uordblks'},"\n"; } BEGIN { print __PACKAGE__." adds ", $y-$x,"\n"; } print "POSIX EXPORT ",scalar(@POSIX::EXPORT),"\n"; #{ local $, = "\n"; print keys %Bar::,"\n"; } exit 0; Perl-Critic-Pulp-97/devel/version.pl0000644000175000017500000000265211672322722015254 0ustar gggg#!/usr/bin/perl -w # Copyright 2010, 2011 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use strict; use warnings; # uncomment this to run the ### lines use Smart::Comments; use Test::Without::Module 'version::vxs'; use blib "$ENV{HOME}/perl/version/version-0.88/blib"; # use version::vxs; # use version::vpp; my $vpp = version::vpp->VERSION; ### $vpp { require version; print "version.pm ", version->VERSION, "\n"; # my $v = version->new('1.234.567'); my $v = version->new('1e6'); print "v $v\n"; print "done\n"; exit 0; } { use Perl::Critic::Utils 1.0; use Perl::Critic::Utils 1.0 'precedence_of'; print Perl::Critic::Utils->VERSION,"\n"; exit 0; } { my $x = '1e6'; print ($x > 2); exit 0; } { require AptPkg::Policy; print AptPkg::Policy->VERSION,"\n"; exit 0; } Perl-Critic-Pulp-97/devel/grep-pod-final-cut.pl0000644000175000017500000000571413015435020017153 0ustar gggg#!/usr/bin/perl -w # Copyright 2009, 2010, 2012, 2014, 2016 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # Look for __END__ without a pod =cut before it # # /usr/share/perl/5.24/ExtUtils/MM_BeOS.pm # /usr/share/perl/5.24/IPC/Cmd.pm use 5.005; use strict; use warnings; use Perl6::Slurp; use FindBin; use lib::abs '.'; use MyLocatePerl; use MyStuff; # uncomment this to run the ### lines use Smart::Comments; my $verbose = 1; my $count_all = 0; my $count_pod = 0; my $count_code = 0; my $count_cut = 0; my $count_nocut = 0; { my $filename = File::Spec->catfile ($FindBin::Bin, $FindBin::Script); my $str = Perl6::Slurp::slurp($filename); my_grep ($filename, $str); } { my $filename = '/usr/share/perl/5.14/ExtUtils/MM_BeOS.pm'; my $str = Perl6::Slurp::slurp($filename); my_grep ($filename, $str); } { my $l = MyLocatePerl->new (exclude_t => 1, # under_directory => '/usr/share/perl5', under_directory => '/usr/share/perl/5.14/', ); while (my ($filename, $str) = $l->next) { my_grep ($filename, $str); } } sub last_pod_command { my ($str) = @_; my $pos = length($str); for (;;) { $pos = rindex($str, "\n=", $pos-1); if ($pos < 0) { last; } pos($str) = $pos + 1; if ($str =~ /\G(=[a-z]+)/mg) { return ($pos, $1); } # some "==" or "=>", not a pod directive, keep looking } if ($str =~ /^(=[a-z]+)/) { return (0, $1); } return; } sub my_grep { my ($filename, $str) = @_; $count_all++; my ($podpos, $command) = last_pod_command ($str) or return; $count_pod++; if ($verbose) { my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $podpos); print "$filename:$line: $command\n"; } pos($str) = $podpos; my $endpodpos = index ($str, "\n\n", $podpos); if ($endpodpos < 0) { $endpodpos = length($str); } if ($command ne '=cut') { $count_nocut++; return; } my $trailing = substr($str, $endpodpos); if ($trailing =~ /\S/) { if ($verbose) { print " code after pod\n"; } # code after pod $count_code++; return; } $count_cut++; } print "total $count_all\n"; print "contains pod $count_pod\n"; print "end non-cut $count_nocut\n"; print "end with code $count_code\n"; print "end with cut $count_cut\n"; exit 0; =pod __END__ Perl-Critic-Pulp-97/devel/churn-unbalanced.pl0000644000175000017500000000313111571547354017001 0ustar gggg#!/usr/bin/perl -w # Copyright 2009, 2010, 2011 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use 5.005; use strict; use warnings; use lib::abs '.', 'lib'; use MyLocatePerl; use MyStuff; use Perl::Critic::Policy::Documentation::ProhibitUnbalancedParens; # uncomment this to run the ### lines #use Smart::Comments; my $verbose = 0; { package MyParser; use base 'Perl::Critic::Pulp::PodParser::ProhibitUnbalancedParens'; sub violation_at_linenum_and_textpos { my ($self, $message, $linenum, $str, $pos) = @_; my $filename = $self->{'filename'}; my ($pos_linenum, $column) = MyStuff::pos_to_line_and_column($str,$pos); $linenum += $pos_linenum - 1; print "$filename:$linenum:$column: $message\n"; } } my $parser = MyParser->new; my $l = MyLocatePerl->new (exclude_t => 1); while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } $parser->{'filename'} = $filename; $parser->parse_from_file ($filename); } exit 0; Perl-Critic-Pulp-97/devel/const-noproto.pl0000644000175000017500000000170411424406724016410 0ustar gggg#!/usr/bin/perl -w # Copyright 2008, 2009, 2010 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use strict; use warnings; use Data::Dumper; use Socket; my $p = prototype('Socket::SOCK_DGRAM'); print "SOCK_DGRAM ",Dumper($p); sub FOO { return 123; } # bad # if (FOO < 456) { print "yes\n"; } else { print "no\n"; } exit 0 Perl-Critic-Pulp-97/devel/grep-pod-gt.pl0000644000175000017500000000660212326663661015722 0ustar gggg#!/usr/bin/perl -w # Copyright 2009, 2010, 2013, 2014 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # /usr/share/perl/5.10.1/Dumpvalue.pm -> # /usr/share/perl/5.10.1/Test/Builder/Tester.pm C<> use 5.005; use strict; use warnings; use Perl6::Slurp; use lib::abs '.'; use MyLocatePerl; use MyStuff; my $verbose = 0; my $l = MyLocatePerl->new (under_directory => '/usr/share/perl5', # under_directory => '/usr/share/perl/5.14/', ); while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } if ($str =~ /^__END__/m) { substr ($str, $-[0], length($str), ''); } my $parser = MyParser->new; $parser->errorsub(sub{1}); # no error prints $parser->parse_from_string ($str, $filename); } package MyParser; use strict; use warnings; use base 'Pod::Parser'; sub parse_from_string { my ($self, $str, $filename) = @_; require IO::String; my $fh = IO::String->new ($str); $self->{_INFILE} = $filename; return $self->parse_from_filehandle ($fh); } sub command { return ''; } sub verbatim { return ''; } sub textblock { my ($self, $text, $linenum, $paraobj) = @_; ### textblock # while ($text =~ /->[^[:space:]]/g) { # my $pos = pos($text); # my ($line, $col) = MyStuff::pos_to_line_and_column ($text, $pos); # $line += $linenum - 1; # # my $filename = $self->{_INFILE}; # print "$filename:$line:$col: bad -> markup\n", # MyStuff::line_at_pos($text, $pos); # } # return ''; my $tree = $self->parse_text ($text, $linenum); my @pending = reverse $tree->children; my $prev = ''; my $next = ''; for ( ; @pending; $prev = $next) { $next = pop @pending; if (ref $next && $next->isa('Pod::ParseTree')) { push @pending, reverse $next->children; next; } next if ref $next; { while ($next =~ /([IBCLFSX]<<+[^ \n])/g) { my $bad = $1; my $filename = $self->output_file; print "$filename:$linenum:1: no space after << markup\n$bad\n"; } } { ref $prev or next; $prev->isa('Pod::InteriorSequence') or next; my $prev_text = $prev->raw_text; $prev_text =~ /->$/ or next; $next =~ /^[_[:alpha:]]/ or next; my ($filename, $line) = $prev->file_line; my $pos = length($prev_text); my ($offset_line, $col) = MyStuff::pos_to_line_and_column ($prev_text, $pos); $line += $offset_line - 1; $col = 1; # col not right if $prev not at start of line my $str = $prev_text . $next; print "$filename:$line:$col: probable unescaped -> markup\n", MyStuff::line_at_pos($str, $pos); print "prev ",$prev_text,"\n"; print "next ",$next,"\n"; } } return ''; } exit 0; Perl-Critic-Pulp-97/devel/MyLocatePerl.pm0000644000175000017500000000767112214704771016137 0ustar gggg# Copyright 2009, 2010, 2011, 2012, 2013 Kevin Ryde. # MyLocatePerl.pm is shared by various distributions. # # MyLocatePerl.pm is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any later # version. # # MyLocatePerl.pm is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . package MyLocatePerl; use 5.006; use strict; use warnings; use base 'File::Locate::Iterator'; use FindBin; use File::Slurp 'slurp'; use IO::File; use IO::Uncompress::AnyInflate; use MyUniqByInode; use MyUniqByMD5; # uncomment this to run the ### lines # use Smart::Comments; # glob => '/usr/share/perl5/Debconf/FrontEnd/*' my $compressed_re = qr/\.gz$/; sub new { my ($class, %options) = @_; my @suffixes = ('t','pm','pl','PL'); if (delete $options{'include_pod'}) { push @suffixes, 'pod'; } if (delete $options{'exclude_t'}) { @suffixes = grep {$_ ne 't'} @suffixes; } if (delete $options{'only_t'}) { @suffixes = ('t'); } my $suffixes = join('|',@suffixes); my $suffixes_re = qr/\.($suffixes)($compressed_re)?$/; ### $suffixes ### $suffixes_re my $locate_regexp = $suffixes_re; if (defined (my $under_directory = $options{'under_directory'})) { unless ($under_directory =~ m{/$}) { $under_directory .= '/'; } $locate_regexp = qr/^\Q$under_directory\E.*$suffixes_re/; } ### $locate_regexp my $self = $class->SUPER::new ( # globs => ['/bin/*', # '/usr/bin/*', # '/usr/local/bin/*', # '/usr/local/bin2/*'], regexp => $locate_regexp, %options); $self->{'uniq_ino'} = MyUniqByInode->new; $self->{'uniq_md5'} = MyUniqByMD5->new; $self->{'my_suffixes_re'} = $suffixes_re; return $self; } sub next { my ($self) = @_; unless ($self->{'done_script'}) { $self->{'done_script'} = 1; my $filename = File::Spec->catfile ($FindBin::Bin, $FindBin::Script); ### $filename my $content = slurp($filename); return ($filename, $content); } for (;;) { defined(my $filename = $self->SUPER::next) or return; ### consider: $filename next if $filename =~ m{/blib/}; next if $filename =~ m{/DateTime/TimeZone/}; # data .pm's next if $filename =~ m{/Date/Manip/TZ/}; # data .pm's next if $filename =~ m{/Date/Manip/Offset/}; # data .pm's next if $filename =~ m{/Text/Unidecode/}; # data .pm's next if $filename =~ m{/junk.pl}; my $io; if ($filename =~ $compressed_re) { $io = IO::Uncompress::AnyInflate->new ($filename); } else { $io = IO::File->new ($filename, 'r'); } $io or next; $self->{'uniq_ino'}->uniq($filename) or next; # or $io ??? my $content = _slurp_if_perl ($self, $filename, $io); ### content: $content && "ok" next if ! defined $content; $self->{'uniq_md5'}->uniq_str($content) or next; ### return: $filename return ($filename, $content); } } sub _slurp_if_perl { my ($self, $filename, $io) = @_; ### slurp: "$io" my $first = ''; if ($filename !~ $self->{'my_suffixes_re'}) { # file in /bin etc must have #!.../perl $io->read($first, 128) or return; ### first part: $first if ($first !~ m{^#!([^\r\n]*/|[ \t]*)perl[ \t\r\n]}) { ### no #!perl return; } } my $rest = do { local $/; $io->getline }; # slurp if (! defined $rest) { ### read error: $! return; } return $first . $rest; } 1; __END__ Perl-Critic-Pulp-97/devel/grep-qw.pl0000644000175000017500000000276011570053417015150 0ustar gggg#!/usr/bin/perl -w # Copyright 2011 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use 5.005; use strict; use warnings; use lib::abs '.'; use MyLocatePerl; use MyStuff; # uncomment this to run the ### lines #use Smart::Comments; my $verbose = 0; my $l = MyLocatePerl->new; OUTER: while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } while ($str =~ m% qw( \([^)]*\) |\[[^]]*\] |\{[^}]*\} ) %gx ) { my $qw = substr($1,1,-1); my $qwpos = pos($str)-length($1); while ($qw =~ /['"]/g) { my $pos = $qwpos + pos($qw)-1; my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); print "$filename:$line:$col:\n", MyStuff::line_at_pos($str, $pos); } } } exit 0; Perl-Critic-Pulp-97/devel/grep-pod-section-end-comma.pl0000644000175000017500000001362612174316203020602 0ustar gggg#!/usr/bin/perl -w # Copyright 2012, 2013 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # Usage: perl grep-pod-section-end-comma.pl # # Search for POD paragraphs ending with a comma. use strict; use warnings; use FindBin; use Perl6::Slurp; use lib::abs '.'; use MyLocatePerl; use MyStuff; # uncomment this to run the ### lines # use Smart::Comments; my $verbose = 0; my $l = MyLocatePerl->new (include_pod => 1, under_directory => '/usr/share/perl5'); my $filename; # { # $filename = "$FindBin::Bin/$FindBin::Script"; # if ($verbose) { print "look at $filename\n"; } # my $str = Perl6::Slurp::slurp ($filename); # my $p = MyParser->new; # $p->parse_from_string ($str); # } my $count = 0; while (($filename, my $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } my $p = MyParser->new; $p->parse_from_string ($str); $p->check_last(); $count++; } print "total $count\n"; exit 0; package MyParser; use base 'Perl::Critic::Pulp::PodParser'; sub new { my $class = shift; ### new() ... return $class->SUPER::new (last_text => '', last_command => '', @_); } sub command { my ($self, $command, $text, $linenum, $paraobj) = @_; ### command(): $command if ($command eq 'for' || $command eq 'pod') { ### ignore ... return; } # my $this_level = $command_level{$command} || 0; # my $prev_level = $command_level{$self->{'last_command'}} || 0; if ($command eq 'item' && $self->{'last_command'} eq 'item') { } elsif ($command eq 'over' || $command eq 'back') { } else { $self->check_last; } $self->{'last_text'} = ''; $self->{'last_command'} = $command; } sub textblock { my ($self, $text, $linenum, $paraobj) = @_; ### textblock(): $text $self->check_last; if (! defined $text) { $text = ''; } $self->{'last_linenum'} = $linenum; $self->{'last_text'} = $text; } sub verbatim { my ($self, $text, $linenum, $paraobj) = @_; ### verbatim() ... $self->{'last_text'} = ''; } sub check_last { my ($self) = @_; ### check_last(): $self->{'last_text'} if ($self->{'last_text'} =~ /,\s*$/s) { print "$filename:$self->{'last_linenum'}:1: end comma\n"; $self->{'last_text'} = ''; } } =pod =head1 ONE Using pages like, =for Finance_Quote_Grab symbols MNG =over 4 blah =back =head1 TWO This one bad, This one ok. =head2 This one ok, =cut =pod verbatim para Blah. =cut # Old stuff for comma following L<> link. # sub new { # my $class = shift; # my $self = $class->SUPER::new (last => '', # @_); # $self->parseopts(-process_cut_cmd => 1); # return $self; # } # # sub parse_from_filehandle { # my $self = shift; # $self->SUPER::parse_from_filehandle(@_); # $self->comma_violation_maybe; # } # # sub comma_violation_maybe { # my ($self) = @_; # if ($self->{'last'} eq 'L-comma') { # $self->violation_at_linenum_and_textpos # ("Comma after L<> at end of section, should it be a full stop, or removed?", # $self->{'saw_comma_linenum'}, # $self->{'saw_comma_text'}, # $self->{'saw_comma_textpos'}); # } # } # # my %command_non_text = (for => 1, # begin => 1, # end => 1, # cut => 1); # # sub command { # my ($self, $command, $text, $linenum, $paraobj) = @_; # ### $command # ### last: $self->{'last'} # # ### $text # # if ($command_non_text{$command}) { # # skip directives # return ''; # } # # if (# before =over is ok # $command eq 'over' # # # in between successive =item is ok # || ($command eq 'item' && $self->{'last'} eq '=item')) { # # } else { # # before =head or =cut is bad # $self->comma_violation_maybe; # } # # $self->{'last'} = ''; # return ''; # } # # sub verbatim { # my ($self) = @_; # ### verbatim # $self->{'last'} = ''; # return ''; # } # # sub textblock { # my ($self, $text, $linenum, $pod_para) = @_; # ### textblock # ### $text # $self->{'saw_comma_linenum'} = $linenum; # $self->{'saw_comma_text'} = $text; # $self->parse_text({-expand_seq => 'textblock_seq', # -expand_text => 'textblock_text' }, # $text, $linenum); # ### last now: $self->{'last'} # return ''; # } # sub textblock_seq { # my ($self, $seq) = @_; # ### seqsubr: $seq # my $cmd = $seq->cmd_name; # if ($cmd eq 'L') { # if ($self->{'last'} eq 'L') { # $self->violation_at_linenum_and_textpos # ("Missing comma between L<> sequences", # $self->{'saw_comma_linenum'}, # '', 0); # } # $self->{'last'} = 'L'; # # } elsif ($cmd eq 'X') { # # ignore X<> # # } else { # # other like C<> as text # ### raw_text: $seq->raw_text # $self->textblock_text ($seq->raw_text, $seq); # } # return; # } # sub textblock_text { # my ($self, $text, $textnode) = @_; # ### textsubr: $text # ### $textnode # if ($text =~ /^(\s.*),\s*$/) { # if ($self->{'last'} eq 'L') { # $self->{'last'} = 'L-comma'; # $self->{'saw_comma_textpos'} = length($text) - length($1); # return; # } # } # if ($text !~ /^\s.*$/) { # $self->{'last'} = ''; # } # ### last now: $self->{'last'} # return; # } Perl-Critic-Pulp-97/devel/grep-rootdir.pl0000644000175000017500000000242512326663661016211 0ustar gggg#!/usr/bin/perl -w # Copyright 2009, 2010, 2012, 2014 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use strict; use warnings; use Perl6::Slurp; use lib::abs '.'; use MyLocatePerl; use MyStuff; my $verbose = 0; my $l = MyLocatePerl->new; while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } pos($str) = 0; while ($str =~ m{(join\s*\(\s*)? ("/"|'/') }gsx) { next if defined $1; my $pos = pos($str); my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); print "$filename:$line:$col: root dir /\n", MyStuff::line_at_pos($str, $pos); } } exit 0; Perl-Critic-Pulp-97/devel/grep-pod-para-dots.pl0000644000175000017500000000402712206610450017162 0ustar gggg#!/usr/bin/perl -w # Copyright 2009, 2010, 2011, 2013 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use strict; use warnings; use Perl6::Slurp; use lib::abs '.'; use MyLocatePerl; use MyStuff; my $verbose = 0; my $l = MyLocatePerl->new (include_pod => 1, exclude_t => 1); my $p = MyParser->new; my $count = 0; my $filename; # $SIG{__WARN__} = sub { # my ($str) = @_; # print STDERR "$filename:1:\n"; # warn $str; # re-throw # }; while (($filename, my $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } $p->parse_from_string ($str, $filename); } print "total $count\n"; exit 0; package MyParser; use base 'Perl::Critic::Pulp::PodParser'; sub command { my $self = shift; return $self->command_as_textblock(@_); } sub textblock { my ($self, $text, $linenum, $paraobj) = @_; # Pod::ParseLink for display part of L<> # ,. probably wrong # if ($text =~ /[^.],\.\s*$/sg) { print "$filename:$linenum: end with comma dot\n"; $count++; } # # ,. probably wrong # # ;. doubtful, but maybe some code or :-;. smiley # # ;. doubtful, but maybe some code # # # if ($text =~ /[^.]\.\.\s*$/sg) { # print "$filename:$linenum: end with dots\n"; # $count++; # } # $[. is ok # :-(. sad face # !. not too bad # # # if ($text =~ /[,;\\!?({[<]\.\s*$/sg) { # print "$filename:$linenum: end with dots\n"; # $count++; # } } Perl-Critic-Pulp-97/devel/grep-use-quoted.pl0000644000175000017500000000325211424406722016610 0ustar gggg#!/usr/bin/perl -w # Copyright 2008, 2009, 2010 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # Look for "use" statements with quoted version numbers, like # # use Foo '1.5'; # use 5.006; use strict; use warnings; use Perl6::Slurp; my @files = ($0, split /\n/, `locate \\*.t \\*.pm \\*.pl`); print scalar(@files),"\n"; foreach my $filename (@files) { my $str = eval { Perl6::Slurp::slurp ($filename) } || do { # print "Cannot read $filename: $!\n"; next; }; while ($str =~ /((use|no)[ \t]+ [A-Za-z0-9_:]+[ \t]+ (['"]|qq?.?]) (v?[0-9][0-9._e]*) ['"}][ \t]* ;.* # [^-a-zA-Z.$:][^\n]* )/gx) { my $line = $1; my $pos = pos($str); # $3 =~ /[0-9]/ or next; # not '..' for use lib etc my $tmp = substr ($str, 0, $pos); my $count = ($tmp =~ tr/\n//) + 1; print "$filename:$count:1: $line\n"; } } __END__ use foo '123'; use Foo::Bar '123'; { no Foo::Bar '123'; } use foo 'v1.5'; Perl-Critic-Pulp-97/devel/parse-backslash.pl0000644000175000017500000000167211577246535016646 0ustar gggg#!/usr/bin/perl -w # Copyright 2011 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # use strict; my $char = '"'; my $search = qr/^(.*?(?. use strict; use warnings; use Regexp::Common 'comment'; use lib::abs '.'; use MyLocatePerl; use MyStuff; my $verbose = 0; my $l = MyLocatePerl->new (regexp => qr/\.pm$/); while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } # strip comments $str =~ s/$RE{comment}{Perl}//og; pos($str) = 0; # $str =~ /\$VERSION\s*=\s* # ('[^']*?[^'0-9.] # |"[^"]*?[^"0-9.] # |q\([^)]*?[^)0-9.] # |q\{[^}]*?[^}0-9.] # # # qw$...$ ok # # qv() version module ok # |q[^vw({] # ) # /gx # or next; # my $pos = pos($str); # my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); # print "$filename:$line:$col: non-numeric VERSION string\n", # MyStuff::line_at_pos($str,$pos); $str =~ /[^A-Za-z_]VERSION\s+(>[^>]|<|[!=]=)/g or next; my $pos = pos($str); my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); print "$filename:$line:$col: explicit VERSION compare\n", MyStuff::line_at_pos($str,$pos); } exit 0; Perl-Critic-Pulp-97/devel/gettext.pl0000644000175000017500000000177611424406724015261 0ustar gggg#!/usr/bin/perl -w # Copyright 2008, 2009, 2010 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use strict; use warnings; use Locale::TextDomain; print __x(<<'HERE', bar => 123); foo $a {xbar} HERE print Locale::TextDomain::__x('foo {bar}'); print __x('foo {bar}'); print __x('foo {bar} {zz}', bar => 123, zz => 456); print __x('foo ' . '{bar}', bar => 123, zz => 456); exit 0; Perl-Critic-Pulp-97/devel/const-post.pl0000644000175000017500000000412111424406724015671 0ustar gggg#!/usr/bin/perl -w # Copyright 2008, 2009, 2010 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . #use warnings; print "FOO\n"; (FOO < 456); if (FOO < 200) { print "yes\n"; } else { print "no\n"; } if (FOO < 100) { print "yes\n"; } else { print "no\n"; } use constant FOO => 123; if (FOO < 200) { print "yes\n"; } else { print "no\n"; } if (FOO < 100) { print "yes\n"; } else { print "no\n"; } print "BAR\n"; #sub BAR { return 123; } print "",BAR,"\n"; if (BAR < -1) { print "yes\n"; } else { print "no\n"; } print "QUUX\n"; if (QUUX < 200) { print "yes\n"; } else { print "no\n"; } if (QUUX < 100) { print "yes\n"; } else { print "no\n"; } #BEGIN { *QUUX = sub { return 123; }; } if (QUUX < 200) { print "yes\n"; } else { print "no\n"; } if (QUUX < 100) { print "yes\n"; } else { print "no\n"; } use strict; use warnings; print "XYZZY\n"; BEGIN { # sub XYZZY { return 150; } # if (XYZZY < 300) { print "yes\n"; } else { print "no\n"; } # if (XYZZY < 200) { print "yes\n"; } else { print "no\n"; } # if (XYZZY < 100) { print "yes\n"; } else { print "no\n"; } } if (XYZZY < 300) { print "yes\n"; } else { print "no\n"; } if (XYZZY < 200) { print "yes\n"; } else { print "no\n"; } if (XYZZY < 100) { print "yes\n"; } else { print "no\n"; } use constant XYZZY => 250; # use constant XYZZY => 150; if (XYZZY < 300) { print "yes\n"; } else { print "no\n"; } if (XYZZY < 200) { print "yes\n"; } else { print "no\n"; } if (XYZZY < 100) { print "yes\n"; } else { print "no\n"; } exit 0 Perl-Critic-Pulp-97/devel/grep-hash-keys.pl0000644000175000017500000001161011660644134016411 0ustar gggg#!/usr/bin/perl -w # Copyright 2011 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # @foo{1..10} hash slice keys # use 5.006; use strict; use Getopt::Long; use Perl::Critic; use Perl::Critic::Utils; use Perl::Critic::Violation; use PPI::Document; use Perl6::Slurp; use lib::abs '.'; use MyLocatePerl; # uncomment this to run the ### lines #use Smart::Comments; my %zzz; my $zzz = {}; my %dup = ( x => 1, , %zzz, %$zzz, x => 2); my $verbose = 0; my $l = MyLocatePerl->new (exclude_t => 1); my $count; { my $filename = 'devel/grep-hash-keys.pl'; my $content = eval { Perl6::Slurp::slurp ($filename) } || next; file ($filename, $content); } { while (my ($filename, $content) = $l->next) { file ($filename, $content); } exit 0; } { my $filename = '/usr/share/perl5/CPAN/Meta/Validator.pm'; my $content = eval { Perl6::Slurp::slurp ($filename) } || next; file ($filename, $content); exit 0; } sub file { my ($filename, $content) = @_; if ($verbose) { print "$filename\n"; } my $doc = PPI::Document->new (\$content); if (! $doc) { print "$filename:1: cannot parse: $PPI::Document::errstr\n"; return; } $count = 0; $doc->find_first (sub { my ($doc, $elem) = @_; examine($elem, $filename); return 0; }); if ($verbose) { print " looked at $count\n"; } } sub examine { my ($elem, $filename) = @_; if ($elem->isa('PPI::Structure::Constructor')) { return if (substr($elem,0,1) eq '['); my $prev = $elem->sprevious_sibling; return if ($prev && $prev->isa('PPI::Token::Word') && $prev eq 'do'); } elsif ($elem->isa('PPI::Structure::List')) { my $prev = $elem->sprevious_sibling || return; return unless $prev->isa('PPI::Token::Operator') && $prev eq '='; ### elem: "$elem" $prev = $prev->sprevious_sibling || return; while ($prev->isa('PPI::Structure::Subscript')) { $prev = $prev->sprevious_sibling || return; } ### prev: (ref $prev)." $prev" ### symbol: $prev->symbol_type return unless ($prev->isa('PPI::Token::Symbol') && $prev->symbol_type eq '%'); } else { return; } ### examine: (ref $elem)." $elem" $elem = $elem->schild(0) || return; if ($elem->isa('PPI::Statement::Expression')) { $elem = $elem->schild(0) || return; } $count++; my @nodes = _elem_and_ssiblings ($elem); my @arefs = Perl::Critic::Utils::split_nodes_on_comma(@nodes); ### @nodes ### @arefs # ignore empty commas @arefs = grep {defined} @arefs; my %seen; for (;;) { my $aref = shift @arefs || return; # key my $value_aref = shift @arefs; # value ### key: $aref ### value: $value_aref $elem = $aref->[0]; ### key: (ref $elem)." $elem" # %$foo is an even number of things if ($elem->isa('PPI::Token::Cast') && $elem eq '%') { unshift @arefs, $value_aref; next; } my $str; if (@$aref == 1) { # %foo is an even number of things if ($elem->isa('PPI::Token::Symbol') && $elem->symbol_type eq '%') { unshift @arefs, $value_aref; next; } if ($elem->isa('PPI::Token::Word')) { $str = $elem; } elsif ($elem->isa('PPI::Token::Quote')) { $str = $elem->string; } } ### $str if (defined $str && $seen{$str}++) { my $linenum = $elem->line_number; print "$filename:$linenum: duplicate key $str\n"; } } } sub _elem_and_ssiblings { my ($elem) = @_; my @ret; while ($elem) { push @ret, $elem; $elem = $elem->snext_sibling; } return @ret; } sub elem_is_comma_operator { my ($elem) = @_; return ($elem->isa('PPI::Token::Operator') && $Perl::Critic::Pulp::Utils::COMMA{$elem}); } exit 0; # my $comma = $elem->snext_sibling; # if ($comma && ! elem_is_comma_operator($comma)) { # my $linenum = $comma->line_number; # print "$filename:$linenum: stop at unknown comma $comma\n"; # return; # } # # $elem = $comma || return; # do { # $elem = $elem->snext_sibling || return; # ### value: (ref $elem)." $elem" # } until (elem_is_comma_operator($elem)); # $elem = $elem->snext_sibling || return; Perl-Critic-Pulp-97/devel/grep-pod-blankline.pl0000644000175000017500000000341512326663661017246 0ustar gggg#!/usr/bin/perl -w # Copyright 2009, 2010, 2012, 2014 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # Look for a =command not preceded by a blank line. # # cf Pod::Checker # # /usr/lib/perl/5.10.1/Compress/Zlib.pm # /usr/share/perl/5.10.1/ExtUtils/ParseXS.pm use 5.005; use strict; use warnings; use Perl6::Slurp; use lib::abs '.'; use MyLocatePerl; use MyStuff; my $verbose = 0; my $l = MyLocatePerl->new (exclude_t => 1, include_pod => 1); while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } next if ($filename =~ /\/doc\.pl$/); next if ($filename =~ /\/junk\.pl$/); # if ($str =~ /^__END__/m) { # substr ($str, $-[0], length($str), ''); # } while ($str =~ /(([^\n]+)\n=([a-z][a-z0-9]*)[^\n]*)/sg) { my $bad = $1; my $pre = $2; my $cmd = $3; my $pos = pos($str) - length($bad) + length($pre) + 1; next if ($cmd eq 'cut'); next if ($cmd eq 'pod'); next if $pre =~ /^\s*$/; # whitespace-only ok my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); print "$filename:$line:$col: no blank before\n$bad\n"; } } exit 0; Perl-Critic-Pulp-97/devel/grep-use-posix.pl0000644000175000017500000000301712452076564016461 0ustar gggg#!/usr/bin/perl -w # Copyright 2008, 2009, 2010, 2015 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # Look for "use POSIX" statements with full import, like # # use POSIX; # # or # # use POSIX 1.10; # use 5.006; use strict; use warnings; use Perl6::Slurp; use File::Locate::Iterator; use FindBin; my $progname = $FindBin::Script; my $verbose = 0; my $it = File::Locate::Iterator->new (globs => [# '*.t', '*.pm', # '*.pl', ]); print "$progname\n"; my $count = 0; while (defined (my $filename = $it->next)) { open my $in, '<', $filename or next; if ($verbose) { print "$filename\n"; } $count++; while (<$in>) { if (/use POSIX(;|\s+[0-9])/) { print "$filename:$.:1:\n $_"; } } close $in or die; } print "count $count\n"; exit 0; Perl-Critic-Pulp-97/devel/grep-pod-leadingwhite.pl0000644000175000017500000000454211752575461017757 0ustar gggg#!/usr/bin/perl -w # Copyright 2012 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use strict; use warnings; use Perl6::Slurp; use FindBin; use lib::abs '.'; use MyLocatePerl; use MyStuff; # uncomment this to run the ### lines #use Smart::Comments; my $verbose = 0; my $p = MyParser->new; my $count = 0; my $filename; { $filename = File::Spec->catfile ($FindBin::Bin, $FindBin::Script); my $str = Perl6::Slurp::slurp($filename); my_grep ($filename, $str); } { my $l = MyLocatePerl->new (include_pod => 1, exclude_t => 1); while (($filename, my $str) = $l->next) { my_grep ($filename, $str); } } sub my_grep { my ($filename, $str) = @_; if ($verbose) { print "parse $filename\n"; } $p->parse_from_string ($str, $filename); } print "total $count\n"; exit 0; package MyParser; use base 'Perl::Critic::Pulp::PodParser'; sub begin_pod { my ($self) = @_; $self->{'in_begin'} = 0; } sub command { my $self = shift; my ($command, $text, $linenum, $paraobj) = @_; ### command: $command ### $text $self->{'in_begin'} = ($command eq 'begin'); return ''; } sub textblock { my ($self, $text, $linenum, $paraobj) = @_; ### $text return if $self->{'in_begin'}; while ($text =~ m{^\s+(?!$)}mg) { my $pos = pos($text); my ($line_offset, $col) = MyStuff::pos_to_line_and_column ($text, $pos); $linenum += $line_offset - 1; print "$filename:$linenum:$col: leading whitespace in text para\n", MyStuff::line_at_pos($text, $pos); $count++; } return ''; } =pod =head1 HELLO Blah fjdks fjksd jfksd fjkds jfksd jfksd jfksd jfksd jfks dfjks djkf sdjkf sdkjf sdkf jsdk fjskd fjksd blah Blah fjdks fjksd jfksd fjkds jfksd jfksd jfksd jfksd jfks dfjks djkf sdjkf Perl-Critic-Pulp-97/devel/qrm.pl0000755000175000017500000000160111424406722014360 0ustar gggg#!/usr/bin/perl -w # Copyright 2008, 2009, 2010 Kevin Ryde # Perl-Critic-Pulp is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any later # version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use 5.005; $str = "w\nx\ny"; $re = qr/^x$/m; print "$re\n"; if ($str =~ /^x$/m) {print "matches\n";} else {print "no match\n";} if ($str =~ $re) {print "matches\n";} else {print "no match\n";} exit 0; Perl-Critic-Pulp-97/devel/string-format.pl0000644000175000017500000000331613044467216016364 0ustar gggg#!/usr/bin/perl -w # Copyright 2008, 2009, 2010, 2017 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use 5.006; use strict; use warnings; use Devel::StackTrace; use Perl::Critic; $|=1; my $critic = Perl::Critic->new; # (-verbose => "%f:%l:%c:\n %P\n %m\n %r\n"); # '-profile' => '', # '-single-policy' => 'ProhibitBadAproposMarkup'); # print "Policies:\n"; # foreach my $p ($critic->policies) { # print " ",$p->get_short_name,"\n"; # } my $filename = '../r5/tools/MyR5Dragon.pm'; $filename = '/tmp/x.pl'; $filename = '/so/pc/bug-string-format/foo.pl'; my @violations; print "critique:\n"; @violations = $critic->critique ($filename); $SIG{__WARN__} = sub { print "---------\n"; print @_; print Devel::StackTrace->new->as_string; print "---------\n"; }; print "violations:\n"; Perl::Critic::Violation::set_format("%f:%l:%c:\n %P\n %m\n %r\n"); foreach my $violation (@violations) { print $violation; print "source: ",$violation->source//'[undef]',"\n"; } if (my $exception = Perl::Critic::Exception::Parse->caught) { print "Caught exception in \"$filename\": $exception\n"; } Perl-Critic-Pulp-97/devel/grep-eval-line.pl0000644000175000017500000000323711710705640016373 0ustar gggg#!/usr/bin/perl -w # Copyright 2011, 2012 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # Usage: perl grep-ampersand-call.pl # # Look for &foo calls, without parens. # use 5.010; use strict; use lib::abs '.'; use MyLocatePerl; use MyStuff; # uncomment this to run the ### lines #use Smart::Comments; sub foo {} &foo; my $verbose = 0; my $l = MyLocatePerl->new; my $count; { my $filename = 'devel/grep-ampersand-call.pl'; my $content = eval { Perl6::Slurp::slurp ($filename) } || next; file ($filename, $content); } { while (my ($filename, $content) = $l->next) { file ($filename, $content); } exit 0; } sub file { my ($filename, $str) = @_; if ($verbose) { print "$filename\n"; } if ($str =~ /^__END__/m) { substr ($str, $-[0], length($str), ''); } while ($str =~ /\beval(\s*[\'\"]|\s+q.)#[ \t]*line/sgo) { my $pos = pos($str); my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); print "$filename:$line:$col: eval #line\n", MyStuff::line_at_pos($str, $pos); } } exit 0; Perl-Critic-Pulp-97/devel/grep-import-tag.pl0000644000175000017500000000413411440577652016611 0ustar gggg#!/usr/bin/perl -w # Copyright 2010 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use strict; use warnings; use Perl6::Slurp; use lib::abs '.'; use MyLocatePerl; use MyStuff; my $verbose = 0; my $l = MyLocatePerl->new; while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } while ($str =~ /\n[ \t\r\n]*use [ \t\r\n]+ ([^ \t\r\n;]+) [ \t\r\n]+ (qw[ \t\r\n]*+.[ \t\r\n]*+|['"]) ([^:!]) [^;]* ['" \t\r\n][:!] /sgx) { my $module = $1; my $non = $3; my $pos = $-[0] + 1; next if ($module eq 'base'); next if ($module eq 'overload'); next if ($module eq 'overload('); next if ($module eq 'lib'); next if ($module eq 'inc::latest'); next if ($module eq "'inc::latest'"); next if ($module eq 'Carp::Clan'); next if ($module eq 'Glib::Object::Subclass'); next if ($module eq 'Test::Without::Module'); next if ($module eq 'Sort::Key::Register'); next if ($module eq 'POE'); next if ($module eq 'constant'); next if ($module eq 'constant::defer'); next if ($module eq 'Memoize::ToConstant'); next if ($module eq 'Prima'); next if ($module eq 'Tk::Reindex'); my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); print "$filename:$line:$col: $module non colon \"$non\"\n", MyStuff::line_at_pos($str, $pos); } } exit 0; Perl-Critic-Pulp-97/devel/grep-arg-unpack.pl0000644000175000017500000000265611710434136016552 0ustar gggg#!/usr/bin/perl -w # Copyright 2008, 2009, 2010, 2012 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # Usage: perl grep-arg-unpack.pl # # Look for "sub { my ($foo); ... }" missing the @_ in the unpack. # Usually some variant unpacking or local vars. use 5.006; use strict; use warnings; use lib::abs '.'; use MyLocatePerl; use MyStuff; my $l = MyLocatePerl->new; while (my ($filename, $str) = $l->next) { while ($str =~ /( sub\s+\w*\s*{\s* my\s*\([^)]+\)\s*; ) /gx) { my $line = $1; my $pos = pos($str) - length($1); my ($linenum, $colnum) = MyStuff::pos_to_line_and_column ($str, $pos); print "$filename:$linenum:$colnum:\n", "$line\n"; } } __END__ use foo .5; use Foo::Bar _1000_; { no Foo::Bar v.1; } Perl-Critic-Pulp-97/devel/churn.pl0000755000175000017500000001342512214730663014711 0ustar gggg#!/usr/bin/perl -w # Copyright 2008, 2009, 2010, 2011, 2012, 2013 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # Usage: churn.pl [--const] [--not] [--diag] [directories...] # # Run the pulp tests over all files under the given directories, or by # default over /usr/share/perl (core and add-ons). # # The options select just one of the policies. # use 5.006; use strict; use warnings; use Getopt::Long; use lib 'lib','devel/lib'; use Perl::Critic; use Perl::Critic::Utils; use Perl::Critic::Violation; my @option_policies; my $option_t_files = 0; GetOptions (require_order => 1, t => \$option_t_files, F => sub { push @option_policies, 'Documentation::RequireFilenameMarkup$'; }, paracomma => sub { push @option_policies, 'Documentation::ProhibitParagraphEndComma$'; }, duphead => sub { push @option_policies, 'Documentation::ProhibitDuplicateHeadings'; }, ifif => sub { push @option_policies, 'CodeLayout::ProhibitIfIfSameLine'; }, duphashkeys => sub { push @option_policies, 'ValuesAndExpressions::ProhibitDuplicateHashKeys'; }, linkself => sub { push @option_policies, 'Documentation::ProhibitLinkSelf$'; }, unbal => sub { push @option_policies, 'Documentation::inprogressProhibitUnbalancedParens'; }, aref => sub { push @option_policies, 'ValuesAndExpressions::ProhibitArrayAssignAref'; }, const => sub { push @option_policies, 'ValuesAndExpressions::ConstantBeforeLt'; }, not => sub { push @option_policies, 'ValuesAndExpressions::NotWithCompare'; }, null => sub { push @option_policies, 'ValuesAndExpressions::ProhibitNullStatements'; }, literals => sub { push @option_policies, 'ValuesAndExpressions::UnexpandedSpecialLiteral'; }, commas => sub { push @option_policies, 'ValuesAndExpressions::ProhibitEmptyCommas'; }, lastpod => sub { push @option_policies, 'Documentation::RequireEndBeforeLastPod'; }, consthash => sub { push @option_policies, 'Compatibility::ConstantPragmaHash'; }, gtk2 => sub { push @option_policies, 'Modules::Gtk2Version'; }, podmin => sub { push @option_policies, 'Compatibility::PodMinimumVersion'; }, posix => sub { push @option_policies, 'Modules::ProhibitPOSIXimport'; }, usever => sub { push @option_policies, 'Modules::ProhibitUseQuotedVersion'; }, apropos => sub { push @option_policies, 'Documentation::ProhibitBadAproposMarkup'; }, backslash => sub { push @option_policies, 'ValuesAndExpressions::ProhibitUnknownBackslash'; }, semicolon => sub { push @option_policies, 'CodeLayout::RequireFinalSemicolon'; }, verb => sub { push @option_policies, 'Documentation::ProhibitVerbatimMarkup$'; }, shebang => sub { push @option_policies, 'Modules::ProhibitModuleShebang$'; }, numver => sub { push @option_policies, 'ValuesAndExpressions::RequireNumericVersion'; }, # coming soon ... fatnewline => sub { push @option_policies, 'ProhibitFatCommaAfterNewline'; }, testprint => sub { push @option_policies, 'TestingAndDebugging::ProhibitTestPrint'; }, trailing => sub { push @option_policies, 'CodeLayout::RequireTrailingCommaAtNewline'; }, ); my @files; if ($option_t_files) { require File::Locate; @files = File::Locate::locate ('*.t', '/var/cache/locate/locatedb'); } else { my @dirs = @ARGV; if (! @dirs) { @dirs = ( '/usr/share/perl5', '/usr/bin', '/bin', glob('/usr/share/perl/*.*.*'), ); } print "Directories:\n"; foreach (@dirs) { print " ",$_,"\n"; } @files = map { -d $_ ? Perl::Critic::Utils::all_perl_files($_) : $_ } @dirs; } @files = uniq_by_func (\&stat_dev_ino, @files); print "Files: ",scalar(@files),"\n"; # @list = uniq_by_func ($func, @list) sub uniq_by_func { my $func = shift; my %seen; return grep { my $key = $func->($_); defined $key && $seen{$key}++ == 0 } @_; } sub stat_dev_ino { my ($filename) = @_; my ($dev, $ino) = stat ($filename); return if ! defined $dev; return "$dev,$ino"; } my $critic; if (@option_policies) { $critic = Perl::Critic->new ('-profile' => '', '-single-policy' => shift @option_policies); foreach my $policy (@option_policies) { $critic->add_policy (-policy => $policy); } } else { $critic = Perl::Critic->new ('-profile' => '', '-theme' => 'pulp'); } # $critic->add_policy # (-policy => 'ValuesAndExpressions::ProhibitNullStatements', # -params => { allow_perl4_semihash => 1 }); print "Policies:\n"; foreach my $p ($critic->policies) { print " ",$p->get_short_name,"\n"; } # "%f:%l:%c:" is good for emacs compilation-mode Perl::Critic::Violation::set_format ("%f:%l:%c:\n %P\n %m\n %r\n"); foreach my $file (@files) { print "$file\n"; my @violations; if (! eval { @violations = $critic->critique ($file); 1 }) { print "Died in \"$file\": $@\n"; next; } print @violations; if (my $exception = Perl::Critic::Exception::Parse->caught) { print "Caught exception in \"$file\": $exception\n"; } } exit 0; Perl-Critic-Pulp-97/devel/grep-trailing-comma-heredoc.pl0000644000175000017500000000360712431223715021031 0ustar gggg#!/usr/bin/perl -w # Copyright 2014 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # cf use 5.005; use strict; use warnings; use lib::abs '.'; use MyLocatePerl; use MyStuff; # uncomment this to run the ### lines # use Smart::Comments; my $verbose = 0; my $l = MyLocatePerl->new; while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } # if ($str =~ /^__END__/m) { # substr ($str, $-[0], length($str), ''); # } # strip comments $str =~ s/#.*//mg; while ($str =~ /<<[ \t]*( '([A-Za-z_]\w*)' |"([A-Za-z_]\w*)" |([A-Za-z_]\w*) )[ \t]*\n/sgx) { my $whole = $&; my $key = $1 // $2 // $3; my $pos_end = pos($str); my $pos = $pos_end - length($whole) + 1; my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); my $l1 = MyStuff::line_at_pos($str, $pos); my $oldpos = pos($str); $str =~ /^$key[ \t]*$/mg; my $pos2 = pos($str); pos($str) = $oldpos; $pos2 // next; my $l2 = MyStuff::line_at_pos($str, $pos2+1); next unless $l2 =~ /^[ \t]*\)/; print "$filename:$line:$col:\n $l1 $l2"; } } exit 0; __END__ print <. # /usr /opt /tmp /etc c:\ # exclude NAME section for apropos use 5.006; use strict; use warnings; use FindBin; use Perl6::Slurp; use lib::abs '.'; use MyLocatePerl; use MyStuff; # uncomment this to run the ### lines # use Smart::Comments; my $verbose = 0; ### verbose on: $verbose=1 sub keep_only_newlines { my ($str) = @_; $str =~ tr/\n//cd; return $str; } sub zap_to_first_pod { my ($str) = @_; if ($str =~ /^=/) { return $str; # starts with pod } my $pos = index ($str, "\n\n="); if ($pos < 0) { # no pod at all return keep_only_newlines($str); } my $pre = substr($str,0,$pos); my $post = substr($str,$pos); return keep_only_newlines($pre) . $post; } ### zap: zap_to_first_pod("blah\nblah\n\n\n=pod") sub zap_after_last_pod { my ($str) = @_; ### zap_after_last_pod: $str my $pos; my $command = ''; while ($str =~ /\n\n=([^\n]*)\n?/sg) { $command = $1; $pos = $+[0]; } ### $pos if ($command eq 'cut') { return substr($str,0,$pos); } else { return $str; } } ### zap: zap_to_first_pod("blah\nblah\n\n\n=pod") sub zap_pod_verbatim { my ($str) = @_; $str =~ s{((^.+\n)+)} {substr($1,0,1) eq ' ' || substr($1,0,1) eq "\t" ? keep_only_newlines($1) : $1}mge; return $str; } sub zap_non_pod { my ($str) = @_; $str = zap_to_first_pod($str); $str = zap_after_last_pod($str); $str =~ s{(\n\n=cut.*\n)((.*\n)*)(\n^=)} {$1 . keep_only_newlines($2) . $4}emg; return $str; } sub process_file { my ($filename, $str) = @_; $str = zap_non_pod($str); $str =~ s/[ \t]+$//mg; # zap trailing whitespace $str = zap_pod_verbatim($str); ### $str while ($str =~ m{((^.+\n)+)}mg) { my $para = $1; my $pos = $-[0]; ### $para next if $para =~ /^[ \t]/; if ($para =~ /\n[ \t]/) { $pos += $-[0] + 1; my ($linenum, $colnum) = MyStuff::pos_to_line_and_column($str, $pos); print "$filename:$linenum:$colnum: indent within plain para\n ", MyStuff::line_at_pos($str, $pos); } } } my $l = MyLocatePerl->new (include_pod => 1, exclude_t => 1, under_directory => '/usr/share/perl5', # under_directory => '/usr/share/perl/5.14.2', ); while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } process_file ($filename, $str); ### exit: exit() } exit 0; =pod Plain para Plain para with indent Verbatim and/or more verbatim Perl-Critic-Pulp-97/devel/grep-array-slice-single.pl0000644000175000017500000000336011552416506020212 0ustar gggg#!/usr/bin/perl -w # Copyright 2009, 2010, 2011 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use 5.006; use strict; use warnings; use lib::abs '.'; use MyLocatePerl; use MyStuff; # uncomment this to run the ### lines #use Smart::Comments; my $verbose = 0; my $l = MyLocatePerl->new; OUTER: while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } # while ($str =~ /( # @\s* # \w+\s* # \[\s*\d+\s*\] # ) # /sgx) { # my $pos = pos($str)-length($1); # # my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); # print "$filename:$line:$col:\n", # MyStuff::line_at_pos($str, $pos); # } # hash slice while ($str =~ /( @\s* \w+\s* \{\s*(\w+|'[^']*'|"[^"]*")\s*\} ) /sgx) { my $pos = pos($str)-length($1); my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); print "$filename:$line:$col:\n", MyStuff::line_at_pos($str, $pos); } } exit 0; Perl-Critic-Pulp-97/devel/grep-pod-item-bullet.pl0000644000175000017500000000331612117550164017521 0ustar gggg#!/usr/bin/perl -w # Copyright 2013 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # various # some DB<1> debugger prompts use 5.005; use strict; use warnings; use Perl6::Slurp; use lib::abs '.'; use MyLocatePerl; use MyStuff; # uncomment this to run the ### lines use Smart::Comments; my $verbose = 0; { package MyParser; use base 'Pod::Simple'; sub _handle_element_start { my ($self, $element, $attrs) = @_; ### $element ### $attrs } sub _handle_text { my ($self, $text) = @_; ### $text } my $self = MyParser->new; $self->parse_string_document(" =over =item * Foo =back "); # exit 0; } my $l = MyLocatePerl->new (include_pod => 1); while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } while ($str =~ /^(=item[ \t]+\*[ \t]+.)/mg) { my $whole = $1; my $pos = pos($str) - length($whole); my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); my $line_str = MyStuff::line_at_pos($str, $pos); print "$filename:$line:$col:\n $line_str"; } } exit 0; =over =item * Bullet =back Perl-Critic-Pulp-97/devel/grep-backslash-control.pl0000644000175000017500000000313612326663661020140 0ustar gggg#!/usr/bin/perl -w # Copyright 2009, 2010, 2014 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # XML::RSS::TimingBot \cm\cj lower case use 5.005; use strict; use warnings; use Perl6::Slurp; use lib::abs '.'; use MyLocatePerl; use MyStuff; my $verbose = 0; my $l = MyLocatePerl->new; while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } if ($str =~ /^__END__/m) { substr ($str, $-[0], length($str), ''); } # strip comments # $str =~ s/#.*//mg; while ($str =~ /(?:^|\G|[^\\]) # current pos or not a \ (?:\\\\)* # odd number of \ # \\c(.) \\c([^\x40-\x5F]) /sgx) { my $char = $1; my $pos = pos($str); my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); my $s = MyStuff::line_at_pos($str, $pos); # substr($s,0,$col) =~ /q[qx]|"/ or next; print "$filename:$line:$col: unknown control \\c $char\n$s"; } } exit 0; Perl-Critic-Pulp-97/devel/grep-pod-linked-urls.pl0000644000175000017500000000344211552764733017542 0ustar gggg#!/usr/bin/perl -w # Copyright 2009, 2010, 2011 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use strict; use warnings; use Perl6::Slurp; use lib::abs '.'; use MyLocatePerl; use MyStuff; my $verbose = 0; my $l = MyLocatePerl->new (include_pod => 1); my $p = MyParser->new; my $wantver = version->new('5.008'); my $count = 0; my $filename; while (($filename, my $str) = $l->next) { my $code = $str; $code =~ s/^__END__.*//m; my $goodver = 0; while ($code =~ /^[^#]*\buse\s+(\d[0-9.]*)/mg) { my $gotver = version->new ($1); if ($gotver >= $wantver) { $goodver = 1; last; } } $goodver or next; if ($verbose) { print "parse $filename\n"; } $p->parse_from_string ($str, $filename); } print "total $count\n"; exit 0; package MyParser; use base 'Perl::Critic::Pulp::PodParser'; sub textblock { my ($self, $text, $linenum, $paraobj) = @_; while ($text =~ m{(? linked url\n", MyStuff::line_at_pos($text, $pos); $count++; } } Perl-Critic-Pulp-97/devel/posix-import.pl0000644000175000017500000000212711424406722016234 0ustar gggg#!/usr/bin/perl -w # Copyright 2008, 2009, 2010 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use strict; use warnings; BEGIN { $INC{'POSIXimportTest.pm'} = 'POSIXimportTest.pm'; } package POSIXimportTest; use Data::Dumper; sub import { print Data::Dumper->new([\@_],['import'])->Dump; } use POSIXimportTest (); use POSIXimportTest ((())); #use POSIXimportTest (),(); # use POSIXimportTest (1,2),(3,4,(5,6)); # POSIXimportTest::import ((1,2),(3,4,(5,6))); exit 0; Perl-Critic-Pulp-97/devel/grep-pod-links-adjacent.pl0000644000175000017500000000242012326663661020171 0ustar gggg#!/usr/bin/perl -w # Copyright 2011, 2014 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use 5.006; use strict; use warnings; use Perl6::Slurp; use lib::abs '.'; use MyLocatePerl; use MyStuff; my $verbose = 0; my $L_re = qr/L<+([^>]|E<[^>]*>)*?>/; my $adjacent_re = qr/$L_re[ \t]*\n?[ \t]*Lnew; while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } while ($str =~ /($adjacent_re)/og) { my $pos = pos($str); my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos-length($1)); print "$filename:$line:$col:\n", MyStuff::line_at_pos($str, $pos); } } exit 0; Perl-Critic-Pulp-97/devel/duplicate-hash-keys.pl0000644000175000017500000001160711710646725017440 0ustar gggg#!/usr/bin/perl -w # Copyright 2011, 2012 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use 5.010; use strict; use warnings; use lib 'devel/lib'; use Perl::Critic; use FindBin; my $progname = $FindBin::Script; my %zzz; my $zzz = {}; my %dup = ( qw(a 1 a 2), x => 1, , %zzz, %$zzz, x => 2); my $rr = \\{}; %$$$rr = (a => 1, 'a' => 2); %zzz = (a => 1, 'a' => 2); my %_Expiration_Units = ( map(($_, 1), qw(a b c)), map(($_, 1), qw(d e f)), ); my @filenames = ( "$FindBin::Bin/$FindBin::Script", "/usr/share/perl5/AppConfig/State.pm", "/usr/share/perl5/AnyEvent/HTTP.pm", "/usr/share/perl5/Cache/BaseCache.pm", "/usr/share/perl5/Dpkg/Deps.pm", "/usr/share/perl5/Encode/X11.pm", "/usr/share/perl5/Image/TIFF.pm", "/usr/share/perl5/Regexp/Assemble.pm", "/usr/share/perl5/Regexp/Grammars.pm", "/usr/share/perl5/String/RewritePrefix.pm", "/usr/share/perl5/Text/Autoformat.pm", "/usr/share/perl5/XML/XPathEngine.pm", "/usr/share/perl5/Email/Simple/Header.pm", "/usr/share/perl5/HTML/Lint/HTML4.pm", "/usr/share/perl5/PPIx/Regexp/Lexer.pm", "/usr/share/perl5/Perl/Critic/Command.pm", "/usr/share/perl5/Regexp/Parser/Objects.pm", # tricked by @_ "/usr/share/perl5/Acme/Tie/Eleet.pm", "/usr/share/perl5/Pod/Simple/RTF.pm", # conditional "/usr/share/perl5/App/Nopaste/Service.pm", "/usr/share/perl5/CPAN/Meta/Converter.pm", # expression "/usr/share/perl5/XUL/Gui.pm", "/usr/share/perl5/Class/Meta/Attribute.pm", "/usr/share/perl5/Curses/UI/Buttonbox.pm", "/usr/share/perl5/Curses/UI/Calendar.pm", "/usr/share/perl5/Curses/UI/Checkbox.pm", "/usr/share/perl5/Curses/UI/Listbox.pm", "/usr/share/perl5/Date/Calendar/Profiles.pm", "/usr/share/perl5/Dpkg/Control/Fields.pm", "/usr/share/perl5/Image/Caa/DriverANSI.pm", # tricked by reverse "/usr/share/perl5/XML/FeedPP.pm", # genuine dups ... "/usr/share/perl5/Parse/DebControl.pm", "/usr/share/perl5/XML/Twig.pm", "/usr/share/perl5/CPAN/Meta/Validator.pm", "/usr/share/perl5/Date/Manip/Zones.pm", "/usr/share/perl5/Image/ExifTool/APP12.pm", "/usr/share/perl5/Image/ExifTool/DICOM.pm", "/usr/share/perl5/Image/ExifTool/Exif.pm", "/usr/share/perl5/Image/ExifTool/Flash.pm", # and diff value "/usr/share/perl5/Image/ExifTool/FlashPix.pm",# and diff value "/usr/share/perl5/Image/ExifTool/GPS.pm", "/usr/share/perl5/Image/ExifTool/GeoTiff.pm", "/usr/share/perl5/Image/ExifTool/HTML.pm", "/usr/share/perl5/Image/ExifTool/Leaf.pm", "/usr/share/perl5/Image/ExifTool/PNG.pm", # same "/usr/share/perl5/Image/ExifTool/Pentax.pm", "/usr/share/perl5/Image/ExifTool/QuickTime.pm", "/usr/share/perl5/Lingua/EN/Inflect.pm", ); my $critic = Perl::Critic->new ('-profile' => '', '-single-policy' => 'ProhibitDuplicateHashKeys'); print "Policies:\n"; foreach my $p ($critic->policies) { print " ",$p->get_short_name,"\n"; } # "%f:%l:%c:" is good for emacs compilation-mode Perl::Critic::Violation::set_format ("%f:%l:%c:\n %P\n %m\n %r\n"); foreach my $filename (@filenames) { print "$filename\n"; my @violations; if (! eval { @violations = $critic->critique ($filename); 1 }) { print "Died in \"$filename\": $@\n"; next; } print @violations; if (my $exception = Perl::Critic::Exception::Parse->caught) { print "Caught exception in \"$filename\": $exception\n"; } } exit 0; Perl-Critic-Pulp-97/devel/grep-dollar-semi.pl0000644000175000017500000000320611733507052016725 0ustar gggg#!/usr/bin/perl -w # Copyright 2012 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # Usage: perl grep-dollar-semi.pl # # Look for $; # use 5.010; use strict; use lib::abs '.'; use MyLocatePerl; use MyStuff; # uncomment this to run the ### lines #use Smart::Comments; sub foo {} &foo; my $verbose = 0; my $l = MyLocatePerl->new; my $count; { my $filename = 'devel/grep-dollar-semi.pl'; my $content = eval { Perl6::Slurp::slurp ($filename) } || next; file ($filename, $content); } { while (my ($filename, $content) = $l->next) { file ($filename, $content); } exit 0; } sub file { my ($filename, $str) = @_; if ($verbose) { print "$filename\n"; } while ( $str =~ /return \$;/ # $str =~ /\$;[^,] # (?!\$*\)\s*\{) # not prototype # /sgx ) { my $pos = pos($str); my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); print "$filename:$line:$col: \$;\n", MyStuff::line_at_pos($str, $pos); } } exit 0; Perl-Critic-Pulp-97/devel/grep-pod-markup-gt.pl0000644000175000017500000000563712206572223017214 0ustar gggg#!/usr/bin/perl -w # Copyright 2013 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . =pod C> Foo > CE> C<> =cut use 5.005; use strict; use warnings; use Perl6::Slurp; use lib::abs '.'; use MyLocatePerl; use MyStuff; # uncomment this to run the ### lines # use Smart::Comments; my $verbose = 0; { package MyParser; use strict; use warnings; use base 'Pod::Parser'; sub parse_from_string { my ($self, $str, $filename) = @_; require IO::String; my $fh = IO::String->new ($str); $self->{_INFILE} = $filename; return $self->parse_from_filehandle ($fh); } sub command { my ($self, $command, $text, $linenum) = @_; if ($command eq 'begin') { $self->{'in_begin'} = $text; } if ($command eq 'end') { $self->{'in_begin'} = ''; } $self->textblock($text, $linenum); return ''; } sub verbatim { return ''; } sub textblock { my ($self, $text, $linenum, $paraobj) = @_; ### textblock(): $text if ($self->{'in_begin'} eq 'html') { return ''; } my $tree = $self->parse_text ($text, $linenum); my @pending = reverse $tree->children; my $prev = 'text'; while (@pending) { ### $prev my $elem = pop @pending; if (ref $elem && $elem->isa('Pod::ParseTree')) { push @pending, reverse $elem->children; next; } if (ref $elem) { ### obj: ref $elem $prev = $elem->cmd_name; (undef, $linenum) = $elem->file_line; } else { ### text: $elem if (($elem =~ /^(>)/ && $prev ne 'text') || ($elem =~ /^(<)/ && $prev ne 'text' && $prev ne 'Z')) { print "$self->{'filename'}:$linenum: $prev $1\n"; } if (length($elem)) { $prev = 'text'; } } } return ''; } } my $l = MyLocatePerl->new (under_directory => '/usr/share/perl5', # under_directory => '/usr/share/perl/5.14/', include_pod => 1, ); while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } my $parser = MyParser->new; $parser->{'filename'} = $filename; $parser->{'str'} = $str; $parser->{'in_begin'} = ''; $parser->parse_from_string($str); } exit 0; Perl-Critic-Pulp-97/devel/grep-pod-head-down2.pl0000644000175000017500000000402312110552020017204 0ustar gggg#!/usr/bin/perl -w # Copyright 2013 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use 5.005; use strict; use warnings; use Tie::IxHash; use lib::abs '.'; use MyLocatePerl; use MyStuff; # uncomment this to run the ### lines # use Smart::Comments; my $verbose = 0; my $scope = 'nest'; my $l = MyLocatePerl->new (exclude_t => 1, include_pod => 1, under_directory => '/usr/share/perl5', ); while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } my $prev_level = 0; while ($str =~ /^=head(\d+)\s+(.*?)\s*$/mg) { my $level = $1; my $name = $2; my $pos = $-[0]; if ($level > $prev_level + 1) { my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); my $s = MyStuff::line_at_pos($str, $pos); print "$filename:$line:$col: descend $prev_level -> $level\n $s"; print "\n"; } $prev_level = $level; } # exit 0; # my %seen; # tie %seen, 'Tie::IxHash'; # while (my ($name, $aref) = each %seen) { # if (@$aref > 1) { # foreach my $pos (@$aref) { # my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); # my $s = MyStuff::line_at_pos($str, $pos); # print "$filename:$line:$col: duplicate heading\n $s"; # } # } # } } exit 0; =head1 FOO =head2 Dup =head2 Dup =head1 BAR =head2 Dup Perl-Critic-Pulp-97/devel/churn-posix.pl0000644000175000017500000000424211424406724016043 0ustar gggg#!/usr/bin/perl -w # Copyright 2008, 2009, 2010 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # Churn ProhibitPOSIXimport over all .pm files. use 5.006; use strict; use warnings; use Getopt::Long; use Perl::Critic; use Perl::Critic::Utils; use Perl::Critic::Violation; use Perl6::Slurp; use Iterator::Simple qw(igrep); use Iterator::Simple::Locate; use lib::abs '.'; use MyUniqByMD5; my $it = Iterator::Simple::Locate->new (globs => [ '*.pm' ]); { my $uniq = MyUniqByMD5->new; $it = igrep { $uniq->uniq_file($_) } $it; } my $critic = Perl::Critic->new ('-profile' => '', '-single-policy' => 'ProhibitPOSIXimport'); print "Policies:\n"; foreach my $p ($critic->policies) { print " ",$p->get_short_name,"\n"; } # "%f:%l:%c:" is good for emacs compilation-mode Perl::Critic::Violation::set_format ("%f:%l:%c:\n %P\n %m\n %r\n"); while (my $filename = $it->next) { my $content = eval { Perl6::Slurp::slurp ($filename) } || next; ($content =~ /^(use POSIX.*)/m) || next; print "\n$filename\n$1\n"; my @violations; if (! eval { @violations = $critic->critique ($filename); 1 }) { print "Died in \"$filename\": $@\n"; next; } print @violations; if (my $exception = Perl::Critic::Exception::Parse->caught) { print "Caught exception in \"$filename\": $exception\n"; } } exit 0; # $it = igrep {filename_has_use_posix($_)} $it; # sub filename_has_use_posix { # my ($filename) = @_; # my $content = do { Perl6::Slurp::slurp ($filename) } || return 0; # return ($content =~ /^use POSIX.*/m) # } Perl-Critic-Pulp-97/devel/bareword-colon.pl0000644000175000017500000000334011710645075016501 0ustar gggg#!/usr/bin/perl -w # Copyright 2010, 2012 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use 5.010; use strict; use warnings; sub noop { } { package blah; sub x { print "method x runs\n" } } { # sub x { print "function x runs\n" } x blah => noop(); exit 0; } # { package main::foo; sub x {} } # { package main::foo::bar; sub y {} } # # { # $, = ' '; # # print %main::; # my $stash = \%main::; # # print keys %$stash; # print $stash->{foo::}//'undef',"\n"; # # $stash = \%main::foo::; # print keys %$stash,"\n"; # print $stash->{bar::}//'undef',"\n"; # exit 0; # } # # sub make { # return "make: @_"; # } # # { # package Math; # sub Complex { return "foo"; } # } # { # my $c = make Math::Complex 1, 2; # print $c,"\n"; # } # require Math::Complex; # { # my $c = make Math::Complex:: 3,4; # print $c,"\n"; # } # # print $Math::{'Complex::'},"\n"; # print $Math::{Complex::},"\n"; # # { # package Foo::Bar::Quux; # sub blah { return "blah"; } # } # print $Foo::{'Bar::Quux::'}||'undef',"\n"; # print $Foo::Bar::{'Quux::'},"\n"; # print $Foo::Bar::{'Quux'}||'undef',"\n"; Perl-Critic-Pulp-97/devel/grep-constant-underscore.pl0000644000175000017500000000357511552520352020523 0ustar gggg#!/usr/bin/perl -w # Copyright 2009, 2010, 2011 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use 5.005; use strict; use warnings; use lib::abs '.'; use MyLocatePerl; use MyStuff; # uncomment this to run the ### lines #use Smart::Comments; # use constant __FOO => 123; my $verbose = 0; my $l = MyLocatePerl->new; OUTER: while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } if ($str =~ /^[^#]*\buse warnings/) { # 5.6 for use warnings anyway, presume that what the code is targeting next; } while ($str =~ /\buse (5[.0-9]*)/g) { ### $1 my $perlver = eval { version->new($1) }; ### $perlver if (defined $perlver && $perlver >= 5.006) { ### skip, high enough next OUTER; } } while ($str =~ /\buse \s+ constant \s+ ([0-9.]+\s+)? _/sgx) { my $pos = pos($str)-1; my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); print "$filename:$line:$col:\n", MyStuff::line_at_pos($str, $pos); } } exit 0; { use Readonly; Readonly::Scalar my $FOO => 123; my $ref = \$FOO; $$ref = 456; use constant XYZZY => 123; $ref = \(XYZZY); $$ref = 456; exit 0; } Perl-Critic-Pulp-97/devel/grep-each.pl0000644000175000017500000000314311710434307015412 0ustar gggg#!/usr/bin/perl -w # Copyright 2009, 2010, 2012 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # Usage: perl grep-each.pl # # Look for "each %foo". # use 5.006; use strict; use warnings; use Perl6::Slurp; use File::Locate::Iterator; use FindBin; my $progname = $FindBin::Script; my $verbose = 0; my $it = File::Locate::Iterator->new (globs => [# '*.t', '*.pm', '*.pl']); print "$progname: $it->{'regexp'}\n"; my $count = 0; while (defined (my $filename = $it->next)) { open my $in, '<', $filename or next; if ($verbose) { print "$filename\n"; } $count++; while (<$in>) { /\beach\s+%/ or next; print "$filename:$.:1:\n $_"; } close $in or die; } print "count $count\n"; sub line_at_pos { my ($str, $pos) = @_; my $beg = rindex ($str, "\n", $pos) || -1; my $end = index ($str, "\n", $pos) || length($str); return substr ($str, $beg+1, $end-($beg+1)); } __END__ Perl-Critic-Pulp-97/devel/grep-use-decimal.pl0000644000175000017500000000312711710433137016704 0ustar gggg#!/usr/bin/perl -w # Copyright 2008, 2009, 2010, 2012 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # Usage: perl grep-use-decimal.pl # # Look for "use Foo .5" etc, with the version number not starting with a # digit. # use 5.006; use strict; use warnings; use Perl6::Slurp; my @files = ($0, split /\n/, `locate \\*.t \\*.pm \\*.pl`); print scalar(@files),"\n"; foreach my $filename (@files) { my $str = eval { Perl6::Slurp::slurp ($filename) } || do { # print "Cannot read $filename: $!\n"; next; }; while ($str =~ /((use|no)[ \t]+ [A-Za-z0-9_:]+[ \t]+ (v?[._][0-9._]*) [ \t]*;.* )/gx) { my $line = $1; my $pos = pos($str); # $3 =~ /[0-9]/ or next; # not '..' for use lib etc my $tmp = substr ($str, 0, $pos); my $count = ($tmp =~ tr/\n//) + 1; print "$filename:$count:1: $line\n"; } } __END__ use foo .5; use Foo::Bar _1000_; { no Foo::Bar v.1; } Perl-Critic-Pulp-97/devel/fat-comma.pl0000644000175000017500000000303611524615647015437 0ustar gggg #!/usr/bin/perl -w # Copyright 2010, 2011 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use strict; use vars '$VERSION'; $VERSION = 999; # uncomment this to run the ### lines use Data::Dumper 'Dumper'; BEGIN { sub mysub () { return 'fufu'; } } { my %hash = (main -> VERSION => 123, mysub + mysub => 123); print Dumper(\%hash); exit 0; } { # use constant CON => 'abc'; # use constant CON # => 'def'; print abc(); exit 0; } { my @dash = (-POSIX::DBL_MAX()); print Dumper(\@dash); exit 0; } { my %hash = (andx => 123); print Dumper(\%hash); exit 0; } { my %hash = (__PACKAGE__ => 123); ### %hash exit 0; } { my @x = ( print => 123 ); print @x; exit 0; } Perl-Critic-Pulp-97/devel/grep-pod-begin.pl0000644000175000017500000000262412326622215016362 0ustar gggg#!/usr/bin/perl -w # Copyright 2009, 2010, 2012, 2014 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # Grep for different types of =begin and =for use 5.005; use strict; use warnings; use Perl6::Slurp; use lib::abs '.'; use MyLocatePerl; use MyStuff; my $verbose = 0; my %seen; my $l = MyLocatePerl->new (exclude_t => 1, include_pod => 1); while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } while ($str =~ /^=(begin|for)[ \t]+([^ \t\r\n]*)/mg) { my $command = $1; my $type = $2; my $pos = $-[0]; next if $seen{$type}++; next unless $command eq 'begin'; my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); print "$filename:$line:$col: =$command $type\n"; } } exit 0; Perl-Critic-Pulp-97/devel/grep-shebang-t.pl0000644000175000017500000000252711716565046016402 0ustar gggg#!/usr/bin/perl -w # Copyright 2009, 2010, 2012 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use 5.006; use strict; use warnings; use Perl6::Slurp; use File::Locate::Iterator; use FindBin; my $progname = $FindBin::Script; my $verbose = 0; my $it = File::Locate::Iterator->new (glob => '*.pm'); my $count = 0; my %seen; while (defined (my $filename = $it->next)) { next unless -x $filename; open my $in, '<', $filename or next; if ($verbose) { print "$filename\n"; } $count++; my $line = <$in>; close $in or die; defined $line or next; if ($line =~ m{^#!perl}) { print "$filename:1:1: $line"; $seen{$0}++; } } print "count $count\n"; { local $,="\n"; print "saw:",keys %seen,''; } exit 0; Perl-Critic-Pulp-97/devel/trailing-comma-heredoc.pl0000644000175000017500000000251312452122137020070 0ustar gggg#!/usr/bin/perl -w # Copyright 2015 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use strict; use PPI::Document; use PPI::Dumper; my $whitespace = 1; sub ppidump { my ($str) = @_; $str =~ s/\s*$//s; $str =~ s/^\s*//s; my $document = PPI::Document->new(\$str) or die 'Could not parse code: ', PPI::Document::errstr(), "\n"; my $dump = PPI::Dumper->new($document, whitespace => $whitespace, locations => 1 ); $dump->print; print "\n"; print $document->serialize; print "\n"; } ppidump(" foo(<. use 5.005; use strict; use warnings; use Regexp::Common 'comment'; use lib::abs '.'; use MyLocatePerl; use MyStuff; my $verbose = 0; my $l = MyLocatePerl->new (only_t => 1); while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } if ($str =~ /^__END__/m) { substr ($str, $-[0], length($str), ''); } # strip comments $str =~ s/$RE{comment}{Perl}//og; $str =~ /\buse\s+Test::More\b/ or next; while ( $str =~ /(\b(?. use strict; use Try::Tiny; try { print "hi\n" } catch { 456 } try { print "hi\n" } catch { 456 } # { # try { 123 } catch { 456 } # } # { # try { 123 } catch { 456 } # } Perl-Critic-Pulp-97/devel/grep-constant-empty.pl0000644000175000017500000000450412304020360017467 0ustar gggg#!/usr/bin/perl -w # Copyright 2012, 2014 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # Look for # use constant foo => (); # use constant foo; # cf t/pragma/constant. # use constant UNDEF2 => ; # the weird way # use constant 'UNDEF3' ; # the 'short' way use 5.005; use strict; use warnings; use lib::abs '.'; use MyLocatePerl; use MyStuff; # uncomment this to run the ### lines #use Smart::Comments; use constant FOO => (); use constant BAR => ; use constant 'ABC'; my $verbose = 0; my $l = MyLocatePerl->new; my %seen; OUTER: while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } while ($str =~ /( \buse \s+ constant \s+ ([0-9.]+\s+)? \w+ \s* => ( \s* \(\s*\) | \s*; ) ) /sgx) { my $pos = pos($str)-1; my $whole = $1; next if $seen{$whole}++; my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); print "$filename:$line:$col:\n", MyStuff::line_at_pos($str, $pos); } while ($str =~ /( \buse \s+ constant \s+ ('|"|qw) ) /sgx) { my $pos = pos($str)-1; my $whole = $1; next if $seen{$whole}++; my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); print "$filename:$line:$col:\n", MyStuff::line_at_pos($str, $pos); } } exit 0; Perl-Critic-Pulp-97/devel/pod-simple.pl0000644000175000017500000000251313015435574015637 0ustar gggg#!/usr/bin/perl -w # Copyright 2016 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use 5.005; use strict; use warnings; use Perl6::Slurp; use lib::abs '.'; use MyLocatePerl; use MyStuff; # uncomment this to run the ### lines use Smart::Comments; my $verbose = 0; { package MyParser; use base 'Pod::Simple'; sub _handle_element_start { my ($self, $element, $attrs) = @_; ### $element ### $attrs } sub _handle_text { my ($self, $text) = @_; ### $text } } my $self = MyParser->new; # $self->parse_file('/usr/share/perl5/Lingua/Any/Numbers.pm'); $self->parse_file('/tmp/a.pl'); # $self->parse_string_document(' # # =pod # # Blah blah =cut. # # Xyzzy # =cut # # Blah # # '); Perl-Critic-Pulp-97/devel/posix-user.pl0000755000175000017500000000167711424406722015714 0ustar gggg#!/usr/bin/perl -w # Copyright 2008, 2009, 2010 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use strict; use warnings; use POSIX; BEGIN { print (defined &DBL_MANT_DIG ? "defined\n" : "not defined\n"); } print "digs ",DBL_MANT_DIG,"\n"; use FindBin; use lib $FindBin::Bin; require PosixUser; PosixUser::func(); 1; Perl-Critic-Pulp-97/devel/MyFileTempDBM.pm0000644000175000017500000000270512005676757016140 0ustar gggg# Copyright 2012 Kevin Ryde. # MyUniqByInode.pm is shared by various distributions. # # MyUniqByInode.pm is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any later # version. # # MyUniqByInode.pm is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . # sdbm # /so/perl/perl-5.10.0/ext/SDBM_File/sdbm/sdbm.3 # # /usr/include/gdbm.h -- single file # ndbm,odbm using gdbm # # db # package MyFileTempDBM; use strict; use File::Spec; use File::Temp 0.19; # version 0.19 for newdir() sub new { my ($class) = @_; my $dir = File::Temp->newdir; return bless { dirobj => $dir, filename => File::Spec->catfile ($dir->dirname, 'temp.sdbm'), }, $class; } sub filename { my ($self) = @_; return $self->{'filename'}; } sub dirname { my ($self) = @_; return $self->{'dirobj'}->dirname; } sub DESTROY { my ($self) = @_; unlink "$self->{'filename'}.dir"; unlink "$self->{'filename'}.pag"; unlink "$self->{'filename'}.sdbm_dir"; # on VMS, according to sdbm.h } 1; __END__ Perl-Critic-Pulp-97/devel/MyUniqByInode.pm0000644000175000017500000000476112010404505016252 0ustar gggg# Copyright 2009, 2010, 2011, 2012 Kevin Ryde. # MyUniqByInode.pm is shared by various distributions. # # MyUniqByInode.pm is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any later # version. # # MyUniqByInode.pm is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this file. If not, see . package MyUniqByInode; use strict; use warnings; use SDBM_File; use Fcntl; use MyFileTempDBM; # uncomment this to run the ### lines #use Smart::Comments; sub new { my ($class) = @_; ### new() ... my %hash; my $tempdbm = MyFileTempDBM->new; my $filename = $tempdbm->filename; print "tempfiles $filename.pag\n", " $filename.dir\n"; tie %hash, 'SDBM_File', $filename, Fcntl::O_RDWR() | Fcntl::O_CREAT(), 0600 or die $!; return bless { tempdbm => $tempdbm, hash => \%hash, }, $class; } DESTROY { my ($self) = @_; my $filename = $self->{'tempdbm'}->filename; my $num_keys = scalar(keys %{$self->{'hash'}}); print "tempfile $filename $num_keys entries, sizes ", -s "$filename.pag"," ", -s "$filename.dir","\n"; system "ls -l $filename.*"; } sub uniq { my ($self, $filename_or_handle) = @_; ### $filename_or_handle my ($dev, $ino) = (ref $filename_or_handle && $filename_or_handle->can('stat') ? $filename_or_handle->stat : stat ($filename_or_handle)); ### $dev ### $ino if (! defined $dev) { # error treated as unique return 1; } my $key = "$dev,$ino"; ### $key my $hash = $self->{'hash'}; ### hash: exists $hash->{$key} return (! exists $hash->{$key} && ($hash->{$key} = 1)); } # sub stat_dev_ino { # my ($filename) = @_; # my ($dev, $ino) = stat ($filename); # if (! defined $dev) { # # print "Cannot stat: $filename\n"; # return ''; # } # return "$dev,$ino"; # } 1; __END__ package main; my $u = MyUniqByInode->new; ### $u print $u->uniq('/etc/issue.net'),"\n"; print $u->uniq('/etc/issue.net'),"\n"; print $u->uniq('/etc/issue.net'),"\n"; print $u->uniq('/etc/issue.net'),"\n"; print "keys ",keys $u->{'hash'},"\n"; exit 0; Perl-Critic-Pulp-97/devel/h2xs/0002755000175000017500000000000013552456763014127 5ustar ggggPerl-Critic-Pulp-97/devel/h2xs/TestConstFoo.h0000644000175000017500000000134711132274736016663 0ustar gggg/* Copyright 2008, 2009 Kevin Ryde This file is part of Perl-Critic-Pulp. Perl-Critic-Pulp is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. Perl-Critic-Pulp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Perl-Critic-Pulp. If not, see . */ #define MYCONST 123 Perl-Critic-Pulp-97/devel/h2xs/run.pl0000755000175000017500000000167211132273145015256 0ustar gggg#!/usr/bin/perl # Copyright 2008, 2009 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use strict; use warnings; use TestConstFoo; print "MYCONST is ",TestConstFoo::MYCONST(),"\n"; # bad unless MYCONST() # if (MYCONST < 10) { print "yes\n"; } else { print "no\n"; } push @INC, '.'; require PostModule; exit 0; Perl-Critic-Pulp-97/devel/h2xs/PostModule.pm0000644000175000017500000000203311415713416016537 0ustar gggg# Copyright 2008, 2009, 2010 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . package PostModule; use strict; use warnings; use TestConstFoo ('MYCONST'); BEGIN { print "PostModule MYCONST is ",TestConstFoo::MYCONST(),"\n"; my $proto = prototype(\&MYCONST); print "proto '",(defined $proto ? $proto : 'undef'),"'\n"; } # bad unless MYCONST() if (MYCONST < 10) { print "yes\n"; } else { print "no\n"; } 1; Perl-Critic-Pulp-97/devel/grep-cut-noblank.pl0000644000175000017500000000246713015236544016742 0ustar gggg#!/usr/bin/perl -w # Copyright 2016 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation; either version 3, or (at your option) any # later version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # Look for =cut without preceding blank line. # use 5.008; use strict; use lib::abs '.'; use MyLocatePerl; use MyStuff; # uncomment this to run the ### lines use Smart::Comments; use base 'Exporter'; our @EXPORT = ('foo'); my $verbose = 0; my $l = MyLocatePerl->new; while (my ($filename, $str) = $l->next) { if ($verbose) { print "look at $filename\n"; } while ($str =~ /[^\n]\n=cut/mg) { my $pos = pos($str); my ($line, $col) = MyStuff::pos_to_line_and_column ($str, $pos); print "$filename:$line:$col: =cut without blank line\n", MyStuff::line_at_pos($str, $pos); } } exit 0; Perl-Critic-Pulp-97/devel/lib/0002755000175000017500000000000013552456763014011 5ustar ggggPerl-Critic-Pulp-97/devel/lib/Perl/0002755000175000017500000000000013552456763014713 5ustar ggggPerl-Critic-Pulp-97/devel/lib/Perl/Critic/0002755000175000017500000000000013552456763016130 5ustar ggggPerl-Critic-Pulp-97/devel/lib/Perl/Critic/Policy/0002755000175000017500000000000013552456763017367 5ustar ggggPerl-Critic-Pulp-97/devel/lib/Perl/Critic/Policy/Modules/0002755000175000017500000000000013552456763020777 5ustar ggggPerl-Critic-Pulp-97/devel/lib/Perl/Critic/Policy/Modules/UseExporter.pm0000644000175000017500000001125713217566527023624 0ustar gggg# Copyright 2015, 2016, 2017 Kevin Ryde # Perl-Critic-Pulp is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any later # version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . # Or any @ISA should have a use ? package Perl::Critic::Policy::Modules::UseExporter; use 5.006; use strict; use warnings; use Scalar::Util; use Perl::Critic::Policy::Modules::ProhibitPOSIXimport; use base 'Perl::Critic::Policy'; use Perl::Critic::Utils qw(is_function_call split_nodes_on_comma); use Perl::Critic::Utils::PPI qw(is_ppi_expression_or_generic_statement); use Perl::Critic::Pulp::Utils; # uncomment this to run the ### lines # use Smart::Comments; our $VERSION = 97; use constant supported_parameters => (); use constant default_severity => $Perl::Critic::Utils::SEVERITY_MEDIUM; use constant default_themes => qw(pulp bugs); use constant applies_to => ('PPI::Token::Symbol'); my %Exporter_symbols = ('@EXPORT' => 1, '@EXPORT_OK' => 1, '%EXPORT_TAGS' => 1, ); sub violates { my ($self, $elem, $document) = @_; $Exporter_symbols{$elem->symbol} || return; return if _document_has_use_Exporter ($document, 'Exporter'); return $self->violation ("\@EXPORT etc without \"use Exporter\"", '', $elem); } # return true if $document has require Exporter, use Exporter, # use base 'Exporter', etc sub _document_has_use_Exporter { my ($document) = @_; my $aref = $document->find ('PPI::Statement::Include'); foreach my $elem (@$aref) { ### elem: "$elem" next if $elem->type eq 'no'; my $module = $elem->module || next; if ($module eq 'Exporter') { ### yes, use or require Exporter ... return 1; } if ($module eq 'base' || $module eq 'parent') { my $child = $elem->schild(2) // next; ### $child my @args = Perl::Critic::Policy::Modules::ProhibitPOSIXimport::_elem_and_snext_siblings($child); ### @args @args = Perl::Critic::Policy::Modules::ProhibitPOSIXimport::_parse_args(@args); foreach my $arg (@args) { _arg_strip_semis($arg); @$arg == 1 or next; my $a = $arg->[0]; ### $a if ($a->isa('PPI::Token::Quote') && $arg->[0]->string eq 'Exporter') { ### yes, quoted string ... return 1; } if ($a->isa('PPI::Token::QuoteLike::Words') && grep {$_ eq 'Exporter'} $a->literal) { ### yes, quoted words ... return 1; } } } } return 0; } # $arg is an arrayref of PPI elements sub _arg_strip_semis { my ($arg) = @_; while (@$arg && _elem_is_semicolon($arg->[-1])) { pop @$arg; } } sub _elem_is_semicolon { my ($elem) = @_; return $elem->isa('PPI::Token::Structure') && $elem eq ';'; } 1; __END__ =for stopwords Ryde =head1 NAME Perl::Critic::Policy::Modules::UseExporter - check for "use Exporter" when applicable =head1 DESCRIPTION This policy is part of the L|Perl::Critic::Pulp> add-on. It checks that if you set an C<@EXPORT> etc then you have a C. package Foo; @ISA = ('Exporter'); @EXPORT = ('foo'); # bad, missing use Exporter =head2 Disabling If you don't care this sort of thing you can always disable C from your F<.perlcriticrc> in the usual way (see L), [-Modules::UseExporter] =head1 SEE ALSO L, L, L, =head1 HOME PAGE L =head1 COPYRIGHT Copyright 2015, 2016, 2017 Kevin Ryde Perl-Critic-Pulp is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. Perl-Critic-Pulp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Perl-Critic-Pulp. If not, see . =cut Perl-Critic-Pulp-97/devel/lib/Perl/Critic/Policy/Modules/UseExporter.t0000644000175000017500000000715713217566527023457 0ustar gggg#!/usr/bin/perl -w # Copyright 2015, 2016, 2017 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any later # version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use 5.006; use strict; use warnings; use Test::More tests => 39; use lib 't'; use MyTestHelpers; BEGIN { MyTestHelpers::nowarnings() } use lib 'devel/lib'; require Perl::Critic::Policy::Modules::UseExporter; #----------------------------------------------------------------------------- my $want_version = 97; is ($Perl::Critic::Policy::Modules::UseExporter::VERSION, $want_version, 'VERSION variable'); is (Perl::Critic::Policy::Modules::UseExporter->VERSION, $want_version, 'VERSION class method'); { ok (eval { Perl::Critic::Policy::Modules::UseExporter->VERSION($want_version); 1 }, "VERSION class check $want_version"); my $check_version = $want_version + 1000; ok (! eval { Perl::Critic::Policy::Modules::UseExporter->VERSION($check_version); 1 }, "VERSION class check $check_version"); } #----------------------------------------------------------------------------- # _document_has_use_Exporter() require PPI::Document; foreach my $data ( [ 1, "use base qw(Exporter), qw(Blah)" ], [ 1, "use base qw(Exporter)" ], [ 1, "use base qw(Blah), qw(Exporter)" ], [ 1, "use base qw(Exporter Blah)" ], [ 1, "use base qw(Blah Blah Exporter)" ], [ 1, "use base 'Exporter'" ], [ 1, "use parent 'Exporter'" ], # [ 0, "use parent '-norequire', 'Exporter'" ], # maybe [ 1, "use base \"Exporter\"" ], [ 0, "use base" ], [ 0, "use base 'exporter'" ], [ 0, "use base qw(Export)" ], [ 1, "require Exporter" ], [ 1, "use Exporter" ], [ 0, "require Export" ], ) { my ($want, $base_str) = @$data; foreach my $str ($base_str, $base_str . ';') { my $document = PPI::Document->new(\$str); ## no critic (ProtectPrivateSubs) my $got = Perl::Critic::Policy::Modules::UseExporter::_document_has_use_Exporter($document) ? 1 : 0; is ($got, $want, "str: $str"); } } #----------------------------------------------------------------------------- require Perl::Critic; my $critic = Perl::Critic->new ('-profile' => '', '-single-policy' => '^Perl::Critic::Policy::Modules::UseExporter$'); { my @p = $critic->policies; is (scalar @p, 1, 'single policy UseExporter'); my $policy = $p[0]; ok (eval { $policy->VERSION($want_version); 1 }, "VERSION object check $want_version"); my $check_version = $want_version + 1000; ok (! eval { $policy->VERSION($check_version); 1 }, "VERSION object check $check_version"); } foreach my $data ([ 0, "use Exporter; \@EXPORT = ('foo')" ], [ 0, "use Exporter; \@EXPORT_OK = ('foo')" ], [ 0, "use Exporter; \@EXPORT_TAGS = (':foo' => [])" ], ) { my ($want_count, $str) = @$data; foreach my $str ($str, $str . ';') { my @violations = $critic->critique (\$str); my $got_count = scalar @violations; is ($got_count, $want_count, "str: $str"); if ($got_count != $want_count) { foreach (@violations) { diag ($_->description); } } } } exit 0; Perl-Critic-Pulp-97/devel/lib/Perl/Critic/Policy/TestingAndDebugging/0002755000175000017500000000000013552456763023243 5ustar ggggPerl-Critic-Pulp-97/devel/lib/Perl/Critic/Policy/TestingAndDebugging/ProhibitTestPrint.t0000755000175000017500000000767112114040112027043 0ustar gggg#!/usr/bin/perl # Copyright 2008, 2010, 2011, 2013 Kevin Ryde # This file is part of Perl-Critic-Pulp. # # Perl-Critic-Pulp is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 3, or (at your option) any later # version. # # Perl-Critic-Pulp is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with Perl-Critic-Pulp. If not, see . use strict; use warnings; use Test::More tests => 32; use lib 't'; use MyTestHelpers; BEGIN { MyTestHelpers::nowarnings() } require Perl::Critic::Policy::TestingAndDebugging::inprogressProhibitTestPrint; #------------------------------------------------------------------------------ # my $want_version = 28; # is ($Perl::Critic::Policy::TestingAndDebugging::inprogressProhibitTestPrint::VERSION, # $want_version, # 'VERSION variable'); # is (Perl::Critic::Policy::TestingAndDebugging::inprogressProhibitTestPrint->VERSION, # $want_version, # 'VERSION class method'); # { # ok (eval { Perl::Critic::Policy::TestingAndDebugging::inprogressProhibitTestPrint->VERSION($want_version); 1 }, # "VERSION class check $want_version"); # my $check_version = $want_version + 1000; # ok (! eval { Perl::Critic::Policy::TestingAndDebugging::inprogressProhibitTestPrint->VERSION($check_version); 1 }, "VERSION class check $check_version"); # } #------------------------------------------------------------------------------ require Perl::Critic; my $critic = Perl::Critic->new ('-profile' => '', '-single-policy' => 'TestingAndDebugging::inprogressProhibitTestPrint'); { my @p = $critic->policies; is (scalar @p, 1, 'single policy inprogressProhibitTestPrint'); # my $policy = $p[0]; # ok (eval { $policy->VERSION($want_version); 1 }, # "VERSION object check $want_version"); # my $check_version = $want_version + 1000; # ok (! eval { $policy->VERSION($check_version); 1 }, # "VERSION object check $check_version"); } foreach my $data ([ 1, 'print {*STDOUT} 123;' ], [ 0, 'print {*FOO} 123;' ], [ 1, 'print {\\*STDOUT} 123;' ], [ 0, 'print {\\*FOO} 123;' ], [ 1, 'print "hello"' ], [ 0, 'print "#ok"' ], [ 0, 'print "#not ok"' ], [ 1, 'print STDOUT "hello"' ], [ 1, 'print STDERR "hello"' ], [ 1, 'print {STDOUT} "hello"' ], [ 1, 'print {STDERR} "hello"' ], [ 1, 'print { STDOUT } "hello"' ], [ 1, 'print { # comment STDOUT } "hello"' ], [ 0, 'print MYHANDLE "hello"' ], [ 0, 'print $myfh "hello"' ], [ 0, 'print $myfh # comment "hello"' ], [ 0, 'print {$myfh} "hello"' ], [ 1, 'print $myvar' ], [ 1, 'print $myvar, "hello"' ], [ 1, 'print $myvar , "hello"' ], [ 1, 'print $myvar' ], [ 1, 'print $x+$y' ], [ 1, 'print $x->method' ], [ 1, 'print $myvar;' ], [ 1, 'print myfunc();' ], [ 0, 'print MYHANDLE (1+2);' ], [ 1, 'print MYFUNC' ], [ 1, 'print STDOUT' ], [ 1, 'print STDERR' ], [ 0, 'print ARGV' ], ) { my ($want_count, $str) = @$data; $str = 'use Test::Simple; ' . $str; { my @violations = $critic->critique (\$str); my $got_count = scalar @violations; is ($got_count, $want_count, $str); } } exit 0; Perl-Critic-Pulp-97/devel/lib/Perl/Critic/Policy/TestingAndDebugging/inprogressProhibitTestPrint.pm0000644000175000017500000002113712107072037031333 0ustar gggg# * inprogressProhibitTestPrint -- use diag instead of print with Test::More # * inprogressProhibitTestPrint -- diag instead of print with Test::More # =item inprogressProhibitTestPrint -- use diag instead of print with C # # See L. # print <. package Perl::Critic::Policy::TestingAndDebugging::inprogressProhibitTestPrint; use strict; use warnings; use base 'Perl::Critic::Policy'; use Perl::Critic::Utils qw(is_perl_filehandle); # uncomment this to run the ### lines #use Smart::Comments; use constant supported_parameters => (); use constant default_severity => $Perl::Critic::Utils::SEVERITY_MEDIUM; use constant default_themes => qw(pulp tests); use constant applies_to => ('PPI::Token::Word'); # Test::Parser # my $test_print_ok_re = qr/^([ \t]*#|ok|not |\d+\.\.[^.]|pragma |TAP version |Bail out)/; sub violates { my ($self, $elem, $document) = @_; _document_is_test_script($document) or return; $elem eq 'print' or return; my ($handle, $rest) = _print_handle_and_rest($elem); _handle_is_std($handle) or return; my $str = _arg_start_string($rest); return if $str =~ $test_print_ok_re; return $self->violation ((_document_is_using_module($document,'Test::More') ? '"print"s better as diag() in a Test::More script' : '"print"s in a test script better with "#"'), '', $elem); } sub _document_is_test_script { my ($document) = @_; if (my $filename = $document->filename) { if ($filename =~ /\.t$/) { return 1; } } return (_document_is_using_module($document,'Test::More') || _document_is_using_module($document,'Test::Simple')); } sub _arg_start_string { my ($elem) = @_; if ($elem && $elem->isa('PPI::Token::Quote')) { return $elem->string }; return ''; } my %comma = (',' => 1, '=>' => 1); sub _print_handle_and_rest { my ($elem) = @_; my $handle = $elem->snext_sibling; my $rest = $handle && $handle->snext_sibling; ### _print_handle_and_rest: $handle ### rest: $rest if (! $rest) { # "print FOO" is a func FOO if exists, else handle FOO # assume it's a func, except for the builtin perl handles if ($handle && is_perl_filehandle($handle)) { return ($handle, $rest); } else { ### no handle return (undef, $handle); } } if ( # "print 123, ..." # "print 123+ ..." ($rest->isa('PPI::Token::Operator')) # "print 123;" || ($rest->isa('PPI::Token::Structure') && $rest eq ';') # "print FOO()" is a function call printed to stdout || ($rest->isa('PPI::Structure::List') # but "print FOO (...)" with whitespace is a handle && $handle->next_sibling == $rest) ) { ### no handle return (undef, $handle); } else { # "print FOO ..." return ($handle, $rest); } } # return true if $elem is a print handle to STDOUT or STDERR or no handle, # meaning the currently "select" handle, which is assumed to be STDOUT # my %std = (STDOUT => 1, STDERR => 1); sub _handle_is_std { my ($elem) = @_; $elem = _handle_destination($elem); ### _handle_destination: $elem if (! $elem) { return 1 } if (ref $elem && ! $elem->isa('PPI::Token::Word')) { return 0; } return $std{$elem}; } # $elem is the handle argument to a "print" statement. # Return an element which is the destination, usually a PPI::Token::Word or # PPI::Token::Symbol, but possibly a PPI::Statement for an expression. If # there's no explicit destination then return undef. # sub _handle_destination { my ($elem) = @_; if ($elem && $elem->isa('PPI::Structure::Block')) { # PPI::Structure::Block { ... } # PPI::Statement # PPI::Token::Word 'STDOUT' # the guts of a "print {FOO}" or "print {$x}" $elem = _single_content($elem); if ($elem->isa('PPI::Statement')) { my @children = $elem->children; while (@children && $children[0]->isa('PPI::Token::Cast')) { shift @children; } if (@children == 1) { $elem = $children[0]; } } } if ($elem && $elem->isa('PPI::Token::Symbol') && $elem->raw_type eq '*') { return substr ($elem->content, 1); } return $elem; } # skip down through single-element children of $elem # the return is an element with either no children, or more than one child sub _single_content { my ($elem) = @_; for (;;) { if (! $elem->can('schildren')) { return $elem; } my @children = $elem->schildren; if (@children != 1) { return $elem; # no children, or more than one child } $elem = $children[0]; } } # return true if $document contains a "use" of $module sub _document_is_using_module { my ($document, $module) = @_; my $key = __PACKAGE__ . ".using_$module"; if (! exists $document->{$key}) { $document->{$key} = !! $document->find_first (sub { my ($document, $elem) = @_; if ($elem->isa('PPI::Statement::Include') && $elem->type ne 'no' && $elem->module eq $module) { return 1; # found } else { return 0; # no-match, and continue looking } }); ### _document_is_using_module: $document->{$key} } return $document->{$key}; } 1; __END__ =head1 NAME Perl::Critic::Policy::TestingAndDebugging::inprogressProhibitTestPrint - don't use arbitrary prints in a test script =head1 DESCRIPTION This policy is part of the Perl::Critic::Pulp add-on. It asks you not to use a raw C in a test script to avoid any chance of confusing the test parsers. print "now doing $some $thing\n"; # bad Either a C<#> for a comment or C from C is better. print "# a comment about $some $thing\n"; # ok use Test::More; diag "blah blah blah"; # ok C has the advantage that it will insert C<#> comment after any newlines in the output too. Various Cs for explicit test output are allowed, print "ok 1\n" # ok print "not ok 2 - some reason\n" # ok print "pragma +something\n" # ok print "Bail out\n" # ok commentize is that it guarantees the output won't be misinterpreted by the test harnesses, see L. print "ok now we're starting\n"; # bad print STDERR "something\n"; # bad # handles for test file setups ok print TESTFH "some data"; # ok and is under the C theme (see L). As with all things perlcritic, it's largely a matter of personal preference whether you want this actively enforced. If you're happy to be careful with your prints then disable this policy from your F<.perlcriticrc> file in the usual way (see L), [-TestingAndDebugging::inprogressProhibitTestPrint] =head1 LIMITATIONS A C to an unspecified destination is assumed to be stdout. If you use C