From 648e932d2c9b776e1b33c15a27b29d5e3037fc33 Mon Sep 17 00:00:00 2001 From: David Golden Date: Wed, 28 Sep 2016 12:08:10 -0400 Subject: [PATCH] PERL-667 Add and pass minimal Perl::Critic release tests --- Changes | 4 ++++ dist.ini | 2 +- lib/MongoDB/BSON.pm | 2 ++ lib/MongoDB/BSON/Binary.pm | 2 ++ lib/MongoDB/BSON/Regexp.pm | 2 ++ lib/MongoDB/BSON/_EncodedDoc.pm | 2 ++ lib/MongoDB/BulkWrite.pm | 2 ++ lib/MongoDB/BulkWriteResult.pm | 2 ++ lib/MongoDB/BulkWriteView.pm | 2 ++ lib/MongoDB/Code.pm | 2 ++ lib/MongoDB/Collection.pm | 2 ++ lib/MongoDB/CommandResult.pm | 2 ++ lib/MongoDB/Cursor.pm | 2 ++ lib/MongoDB/DBRef.pm | 2 ++ lib/MongoDB/Database.pm | 2 ++ lib/MongoDB/DeleteResult.pm | 2 ++ lib/MongoDB/GridFS.pm | 4 +++- lib/MongoDB/GridFS/File.pm | 2 ++ lib/MongoDB/GridFSBucket.pm | 2 ++ lib/MongoDB/GridFSBucket/DownloadStream.pm | 2 ++ lib/MongoDB/GridFSBucket/UploadStream.pm | 2 ++ lib/MongoDB/IndexView.pm | 2 ++ lib/MongoDB/InsertManyResult.pm | 2 ++ lib/MongoDB/InsertOneResult.pm | 2 ++ lib/MongoDB/MongoClient.pm | 2 ++ lib/MongoDB/OID.pm | 2 ++ lib/MongoDB/Op/_Aggregate.pm | 2 ++ lib/MongoDB/Op/_BatchInsert.pm | 2 ++ lib/MongoDB/Op/_BulkWrite.pm | 4 +++- lib/MongoDB/Op/_Command.pm | 2 ++ lib/MongoDB/Op/_Count.pm | 2 ++ lib/MongoDB/Op/_CreateIndexes.pm | 2 ++ lib/MongoDB/Op/_Delete.pm | 2 ++ lib/MongoDB/Op/_Distinct.pm | 2 ++ lib/MongoDB/Op/_DropCollection.pm | 2 ++ lib/MongoDB/Op/_DropDatabase.pm | 2 ++ lib/MongoDB/Op/_DropIndexes.pm | 2 ++ lib/MongoDB/Op/_Explain.pm | 2 ++ lib/MongoDB/Op/_FSyncUnlock.pm | 2 ++ lib/MongoDB/Op/_FindAndDelete.pm | 2 ++ lib/MongoDB/Op/_FindAndUpdate.pm | 2 ++ lib/MongoDB/Op/_GetMore.pm | 2 ++ lib/MongoDB/Op/_InsertOne.pm | 2 ++ lib/MongoDB/Op/_KillCursors.pm | 2 ++ lib/MongoDB/Op/_ListCollections.pm | 2 ++ lib/MongoDB/Op/_ListIndexes.pm | 4 +++- lib/MongoDB/Op/_ParallelScan.pm | 2 ++ lib/MongoDB/Op/_Query.pm | 2 ++ lib/MongoDB/Op/_RenameCollection.pm | 2 ++ lib/MongoDB/Op/_Update.pm | 2 ++ lib/MongoDB/QueryResult.pm | 2 ++ lib/MongoDB/QueryResult/Filtered.pm | 2 ++ lib/MongoDB/ReadConcern.pm | 2 ++ lib/MongoDB/ReadPreference.pm | 2 ++ lib/MongoDB/Role/_BypassValidation.pm | 2 ++ lib/MongoDB/Role/_CollectionOp.pm | 2 ++ lib/MongoDB/Role/_CommandCursorOp.pm | 2 ++ lib/MongoDB/Role/_CursorAPI.pm | 2 ++ lib/MongoDB/Role/_DatabaseErrorThrower.pm | 2 ++ lib/MongoDB/Role/_DatabaseOp.pm | 2 ++ lib/MongoDB/Role/_DeprecationWarner.pm | 2 ++ lib/MongoDB/Role/_InsertPreEncoder.pm | 2 ++ lib/MongoDB/Role/_OpReplyParser.pm | 2 ++ lib/MongoDB/Role/_PrivateConstructor.pm | 6 +++-- lib/MongoDB/Role/_ReadOp.pm | 2 ++ lib/MongoDB/Role/_ReadPrefModifier.pm | 2 ++ lib/MongoDB/Role/_SingleBatchDocWrite.pm | 2 ++ lib/MongoDB/Role/_UpdatePreEncoder.pm | 2 ++ lib/MongoDB/Role/_WriteOp.pm | 2 ++ lib/MongoDB/Role/_WriteResult.pm | 2 ++ lib/MongoDB/Timestamp.pm | 2 ++ lib/MongoDB/UnacknowledgedResult.pm | 2 ++ lib/MongoDB/UpdateResult.pm | 2 ++ lib/MongoDB/WriteConcern.pm | 2 ++ lib/MongoDB/_Credential.pm | 2 ++ lib/MongoDB/_Server.pm | 2 ++ lib/MongoDB/_Topology.pm | 2 ++ lib/MongoDB/_Types.pm | 3 +++ lib/MongoDB/_URI.pm | 4 +++- perlcritic.rc | 26 ++++++++++++++++++++++ 80 files changed, 192 insertions(+), 7 deletions(-) create mode 100644 perlcritic.rc diff --git a/Changes b/Changes index e1518b0e..98a25361 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,10 @@ {{ $NEXT }} + [~ Internal changes ~] + + - PERL-667 Add and pass Perl::Critic tests before release + v1.5.0 2016-09-19 15:26:09-07:00 America/Los_Angeles (TRIAL RELEASE) [*** Deprecations ***] diff --git a/dist.ini b/dist.ini index 19d77028..10547c3f 100644 --- a/dist.ini +++ b/dist.ini @@ -63,7 +63,7 @@ max_target_perl = 5.008001 ;also_private = qr/^[A-Z_]+$/ ; check Perl::Critic -;[Test::Perl::Critic] +[Test::Perl::Critic] ;[Test::LocalBrew] ;brews = perl-5.10.1 diff --git a/lib/MongoDB/BSON.pm b/lib/MongoDB/BSON.pm index ad08adb9..0ee4569d 100644 --- a/lib/MongoDB/BSON.pm +++ b/lib/MongoDB/BSON.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::BSON; diff --git a/lib/MongoDB/BSON/Binary.pm b/lib/MongoDB/BSON/Binary.pm index 8e7f8a28..08126274 100644 --- a/lib/MongoDB/BSON/Binary.pm +++ b/lib/MongoDB/BSON/Binary.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::BSON::Binary; # ABSTRACT: MongoDB binary type diff --git a/lib/MongoDB/BSON/Regexp.pm b/lib/MongoDB/BSON/Regexp.pm index 55a5ab77..c3b48a2d 100644 --- a/lib/MongoDB/BSON/Regexp.pm +++ b/lib/MongoDB/BSON/Regexp.pm @@ -1,3 +1,5 @@ +use strict; +use warnings; package MongoDB::BSON::Regexp; # ABSTRACT: Regular expression type diff --git a/lib/MongoDB/BSON/_EncodedDoc.pm b/lib/MongoDB/BSON/_EncodedDoc.pm index a082f6ee..0fe39c8c 100644 --- a/lib/MongoDB/BSON/_EncodedDoc.pm +++ b/lib/MongoDB/BSON/_EncodedDoc.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::BSON::_EncodedDoc; # Wrapper for pre-encoded BSON documents, with optional metadata diff --git a/lib/MongoDB/BulkWrite.pm b/lib/MongoDB/BulkWrite.pm index 0aa9fa33..f77a99d9 100644 --- a/lib/MongoDB/BulkWrite.pm +++ b/lib/MongoDB/BulkWrite.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::BulkWrite; # ABSTRACT: MongoDB bulk write interface diff --git a/lib/MongoDB/BulkWriteResult.pm b/lib/MongoDB/BulkWriteResult.pm index dd12bd6e..eb78422b 100644 --- a/lib/MongoDB/BulkWriteResult.pm +++ b/lib/MongoDB/BulkWriteResult.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::BulkWriteResult; # ABSTRACT: MongoDB bulk write result document diff --git a/lib/MongoDB/BulkWriteView.pm b/lib/MongoDB/BulkWriteView.pm index 84399ec8..604c5b7e 100644 --- a/lib/MongoDB/BulkWriteView.pm +++ b/lib/MongoDB/BulkWriteView.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::BulkWriteView; # ABSTRACT: Bulk write operations against a query document diff --git a/lib/MongoDB/Code.pm b/lib/MongoDB/Code.pm index 3e22885d..8a4020e8 100644 --- a/lib/MongoDB/Code.pm +++ b/lib/MongoDB/Code.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Code; diff --git a/lib/MongoDB/Collection.pm b/lib/MongoDB/Collection.pm index 25a444a6..0a9490eb 100644 --- a/lib/MongoDB/Collection.pm +++ b/lib/MongoDB/Collection.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Collection; diff --git a/lib/MongoDB/CommandResult.pm b/lib/MongoDB/CommandResult.pm index 9fbcf031..db8f05b8 100644 --- a/lib/MongoDB/CommandResult.pm +++ b/lib/MongoDB/CommandResult.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::CommandResult; # ABSTRACT: MongoDB generic command result document diff --git a/lib/MongoDB/Cursor.pm b/lib/MongoDB/Cursor.pm index ec779dda..155fee78 100644 --- a/lib/MongoDB/Cursor.pm +++ b/lib/MongoDB/Cursor.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Cursor; diff --git a/lib/MongoDB/DBRef.pm b/lib/MongoDB/DBRef.pm index 7049752d..1b286a40 100644 --- a/lib/MongoDB/DBRef.pm +++ b/lib/MongoDB/DBRef.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::DBRef; # ABSTRACT: A MongoDB database reference diff --git a/lib/MongoDB/Database.pm b/lib/MongoDB/Database.pm index 455bc3d0..7ac52978 100644 --- a/lib/MongoDB/Database.pm +++ b/lib/MongoDB/Database.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Database; diff --git a/lib/MongoDB/DeleteResult.pm b/lib/MongoDB/DeleteResult.pm index 31026df0..1b5f9e71 100644 --- a/lib/MongoDB/DeleteResult.pm +++ b/lib/MongoDB/DeleteResult.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::DeleteResult; # ABSTRACT: MongoDB deletion result object diff --git a/lib/MongoDB/GridFS.pm b/lib/MongoDB/GridFS.pm index 6c0b876d..8f03c522 100644 --- a/lib/MongoDB/GridFS.pm +++ b/lib/MongoDB/GridFS.pm @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +use strict; +use warnings; package MongoDB::GridFS; # ABSTRACT: A file storage abstraction (DEPRECATED) @@ -245,7 +247,7 @@ sub find_one { $criteria ||= {}; my $file = $self->files->find_one($criteria, $fields); - return undef unless $file; + return undef unless $file; ## no critic return MongoDB::GridFS::File->new({_grid => $self,info => $file}); } diff --git a/lib/MongoDB/GridFS/File.pm b/lib/MongoDB/GridFS/File.pm index 906e61e0..014dd76c 100644 --- a/lib/MongoDB/GridFS/File.pm +++ b/lib/MongoDB/GridFS/File.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::GridFS::File; diff --git a/lib/MongoDB/GridFSBucket.pm b/lib/MongoDB/GridFSBucket.pm index 89a01aba..09431426 100644 --- a/lib/MongoDB/GridFSBucket.pm +++ b/lib/MongoDB/GridFSBucket.pm @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +use strict; +use warnings; package MongoDB::GridFSBucket; # ABSTRACT: A file storage abstraction diff --git a/lib/MongoDB/GridFSBucket/DownloadStream.pm b/lib/MongoDB/GridFSBucket/DownloadStream.pm index 8175877a..b376abc8 100644 --- a/lib/MongoDB/GridFSBucket/DownloadStream.pm +++ b/lib/MongoDB/GridFSBucket/DownloadStream.pm @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +use strict; +use warnings; package MongoDB::GridFSBucket::DownloadStream; # ABSTRACT: File handle abstraction for downloading diff --git a/lib/MongoDB/GridFSBucket/UploadStream.pm b/lib/MongoDB/GridFSBucket/UploadStream.pm index 9d4a5bb4..3e0d28ff 100644 --- a/lib/MongoDB/GridFSBucket/UploadStream.pm +++ b/lib/MongoDB/GridFSBucket/UploadStream.pm @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +use strict; +use warnings; package MongoDB::GridFSBucket::UploadStream; # ABSTRACT: File handle abstraction for uploading diff --git a/lib/MongoDB/IndexView.pm b/lib/MongoDB/IndexView.pm index 4ca9d874..a61ac750 100644 --- a/lib/MongoDB/IndexView.pm +++ b/lib/MongoDB/IndexView.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::IndexView; # ABSTRACT: Index management for a collection diff --git a/lib/MongoDB/InsertManyResult.pm b/lib/MongoDB/InsertManyResult.pm index 9ef838a4..9006c1c0 100644 --- a/lib/MongoDB/InsertManyResult.pm +++ b/lib/MongoDB/InsertManyResult.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::InsertManyResult; # ABSTRACT: MongoDB single insert result object diff --git a/lib/MongoDB/InsertOneResult.pm b/lib/MongoDB/InsertOneResult.pm index c5803edd..819ec6c6 100644 --- a/lib/MongoDB/InsertOneResult.pm +++ b/lib/MongoDB/InsertOneResult.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::InsertOneResult; # ABSTRACT: MongoDB single insert result object diff --git a/lib/MongoDB/MongoClient.pm b/lib/MongoDB/MongoClient.pm index a1968f01..a7d33e31 100644 --- a/lib/MongoDB/MongoClient.pm +++ b/lib/MongoDB/MongoClient.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::MongoClient; # ABSTRACT: A connection to a MongoDB server or multi-server deployment diff --git a/lib/MongoDB/OID.pm b/lib/MongoDB/OID.pm index 0f5456fa..d8cae8e0 100644 --- a/lib/MongoDB/OID.pm +++ b/lib/MongoDB/OID.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::OID; # ABSTRACT: A Mongo Object ID diff --git a/lib/MongoDB/Op/_Aggregate.pm b/lib/MongoDB/Op/_Aggregate.pm index 8173b42b..1f79f7ac 100644 --- a/lib/MongoDB/Op/_Aggregate.pm +++ b/lib/MongoDB/Op/_Aggregate.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_Aggregate; # Encapsulate aggregate operation; return MongoDB::QueryResult diff --git a/lib/MongoDB/Op/_BatchInsert.pm b/lib/MongoDB/Op/_BatchInsert.pm index 439ce8a9..a70a7e5f 100644 --- a/lib/MongoDB/Op/_BatchInsert.pm +++ b/lib/MongoDB/Op/_BatchInsert.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_BatchInsert; # Encapsulate a multi-document insert operation; returns a diff --git a/lib/MongoDB/Op/_BulkWrite.pm b/lib/MongoDB/Op/_BulkWrite.pm index cd9ed896..f058b691 100644 --- a/lib/MongoDB/Op/_BulkWrite.pm +++ b/lib/MongoDB/Op/_BulkWrite.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_BulkWrite; # Encapsulate a multi-document multi-operation write; returns a @@ -380,7 +382,7 @@ sub _execute_legacy_batch { return $_->result; } die $_ unless $w_0 && /exceeds maximum size/; - return undef; + return undef; ## no critic: this makes op_result undef }; my $gle_result = diff --git a/lib/MongoDB/Op/_Command.pm b/lib/MongoDB/Op/_Command.pm index 5e42819a..b76e46da 100644 --- a/lib/MongoDB/Op/_Command.pm +++ b/lib/MongoDB/Op/_Command.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_Command; # Encapsulate running a command and returning a MongoDB::CommandResult diff --git a/lib/MongoDB/Op/_Count.pm b/lib/MongoDB/Op/_Count.pm index 0e150cd6..cfb44f46 100644 --- a/lib/MongoDB/Op/_Count.pm +++ b/lib/MongoDB/Op/_Count.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_Count; # Encapsulate code path for count commands diff --git a/lib/MongoDB/Op/_CreateIndexes.pm b/lib/MongoDB/Op/_CreateIndexes.pm index b7f9cad8..7ef6266a 100644 --- a/lib/MongoDB/Op/_CreateIndexes.pm +++ b/lib/MongoDB/Op/_CreateIndexes.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_CreateIndexes; # Encapsulate index creation operations; returns a MongoDB::CommandResult diff --git a/lib/MongoDB/Op/_Delete.pm b/lib/MongoDB/Op/_Delete.pm index 24375523..ab3102cb 100644 --- a/lib/MongoDB/Op/_Delete.pm +++ b/lib/MongoDB/Op/_Delete.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_Delete; # Encapsulate a delete operation; returns a MongoDB::DeleteResult diff --git a/lib/MongoDB/Op/_Distinct.pm b/lib/MongoDB/Op/_Distinct.pm index e27f4a03..6901f1ff 100644 --- a/lib/MongoDB/Op/_Distinct.pm +++ b/lib/MongoDB/Op/_Distinct.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_Distinct; # Encapsulate distinct operation; return MongoDB::QueryResult diff --git a/lib/MongoDB/Op/_DropCollection.pm b/lib/MongoDB/Op/_DropCollection.pm index e7c79a44..42f8b851 100644 --- a/lib/MongoDB/Op/_DropCollection.pm +++ b/lib/MongoDB/Op/_DropCollection.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_DropCollection; # Implements a collection drop; returns a MongoDB::CommandResult diff --git a/lib/MongoDB/Op/_DropDatabase.pm b/lib/MongoDB/Op/_DropDatabase.pm index 99a0b0f6..49a0e903 100644 --- a/lib/MongoDB/Op/_DropDatabase.pm +++ b/lib/MongoDB/Op/_DropDatabase.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_DropDatabase; # Implements a database drop; returns a MongoDB::CommandResult diff --git a/lib/MongoDB/Op/_DropIndexes.pm b/lib/MongoDB/Op/_DropIndexes.pm index 77eba05c..f1fe9535 100644 --- a/lib/MongoDB/Op/_DropIndexes.pm +++ b/lib/MongoDB/Op/_DropIndexes.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_DropIndexes; # Implements index drops; returns a MongoDB::CommandResult diff --git a/lib/MongoDB/Op/_Explain.pm b/lib/MongoDB/Op/_Explain.pm index 794c0a98..bcde7b8e 100644 --- a/lib/MongoDB/Op/_Explain.pm +++ b/lib/MongoDB/Op/_Explain.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_Explain; # Encapsulate code path for explain commands/queries diff --git a/lib/MongoDB/Op/_FSyncUnlock.pm b/lib/MongoDB/Op/_FSyncUnlock.pm index 1060485a..3ec0e23c 100644 --- a/lib/MongoDB/Op/_FSyncUnlock.pm +++ b/lib/MongoDB/Op/_FSyncUnlock.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_FSyncUnlock; # Encapsulate collection list operations; returns arrayref of collection diff --git a/lib/MongoDB/Op/_FindAndDelete.pm b/lib/MongoDB/Op/_FindAndDelete.pm index 62ae3b4e..2f24bfb5 100644 --- a/lib/MongoDB/Op/_FindAndDelete.pm +++ b/lib/MongoDB/Op/_FindAndDelete.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_FindAndDelete; # Encapsulate find_and_delete operation; atomically delete and return doc diff --git a/lib/MongoDB/Op/_FindAndUpdate.pm b/lib/MongoDB/Op/_FindAndUpdate.pm index 770ed47a..bf23859c 100644 --- a/lib/MongoDB/Op/_FindAndUpdate.pm +++ b/lib/MongoDB/Op/_FindAndUpdate.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_FindAndUpdate; # Encapsulate find_and_update operation; atomically update and return doc diff --git a/lib/MongoDB/Op/_GetMore.pm b/lib/MongoDB/Op/_GetMore.pm index 3388817e..edebd0f5 100644 --- a/lib/MongoDB/Op/_GetMore.pm +++ b/lib/MongoDB/Op/_GetMore.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_GetMore; # Encapsulate a cursor fetch operation; returns raw results object diff --git a/lib/MongoDB/Op/_InsertOne.pm b/lib/MongoDB/Op/_InsertOne.pm index 9c7a2bec..54a0e7f6 100644 --- a/lib/MongoDB/Op/_InsertOne.pm +++ b/lib/MongoDB/Op/_InsertOne.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_InsertOne; # Encapsulate a single-document insert operation; returns a diff --git a/lib/MongoDB/Op/_KillCursors.pm b/lib/MongoDB/Op/_KillCursors.pm index dfbaf917..f5ad61fd 100644 --- a/lib/MongoDB/Op/_KillCursors.pm +++ b/lib/MongoDB/Op/_KillCursors.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_KillCursors; # Encapsulate a cursor kill operation; returns true diff --git a/lib/MongoDB/Op/_ListCollections.pm b/lib/MongoDB/Op/_ListCollections.pm index 7191bc87..1b624375 100644 --- a/lib/MongoDB/Op/_ListCollections.pm +++ b/lib/MongoDB/Op/_ListCollections.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_ListCollections; # Encapsulate collection list operations; returns arrayref of collection diff --git a/lib/MongoDB/Op/_ListIndexes.pm b/lib/MongoDB/Op/_ListIndexes.pm index a74dcc0b..5dc0f50c 100644 --- a/lib/MongoDB/Op/_ListIndexes.pm +++ b/lib/MongoDB/Op/_ListIndexes.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_ListIndexes; # Encapsulate index list operation; returns array ref of index documents @@ -75,7 +77,7 @@ sub _command_list_indexes { } catch { if ( $_->$_isa("MongoDB::DatabaseError") ) { - return undef if $_->code == NAMESPACE_NOT_FOUND(); + return undef if $_->code == NAMESPACE_NOT_FOUND(); ## no critic: make $res undef } die $_; }; diff --git a/lib/MongoDB/Op/_ParallelScan.pm b/lib/MongoDB/Op/_ParallelScan.pm index 6f4535d6..dc4c8041 100644 --- a/lib/MongoDB/Op/_ParallelScan.pm +++ b/lib/MongoDB/Op/_ParallelScan.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_ParallelScan; # Encapsulate code path for parallelCollectionScan commands diff --git a/lib/MongoDB/Op/_Query.pm b/lib/MongoDB/Op/_Query.pm index eb9793ca..5a616c96 100644 --- a/lib/MongoDB/Op/_Query.pm +++ b/lib/MongoDB/Op/_Query.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_Query; # Encapsulate a query operation; returns a MongoDB::QueryResult object diff --git a/lib/MongoDB/Op/_RenameCollection.pm b/lib/MongoDB/Op/_RenameCollection.pm index 0fff6de4..fe070804 100644 --- a/lib/MongoDB/Op/_RenameCollection.pm +++ b/lib/MongoDB/Op/_RenameCollection.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_RenameCollection; # Implements a collection move/rename; returns a MongoDB::CommandResult diff --git a/lib/MongoDB/Op/_Update.pm b/lib/MongoDB/Op/_Update.pm index c76a31af..47540676 100644 --- a/lib/MongoDB/Op/_Update.pm +++ b/lib/MongoDB/Op/_Update.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Op::_Update; # Encapsulate an update operation; returns a MongoDB::UpdateResult diff --git a/lib/MongoDB/QueryResult.pm b/lib/MongoDB/QueryResult.pm index ca454baf..8b0e593c 100644 --- a/lib/MongoDB/QueryResult.pm +++ b/lib/MongoDB/QueryResult.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::QueryResult; # ABSTRACT: An iterator for Mongo query results diff --git a/lib/MongoDB/QueryResult/Filtered.pm b/lib/MongoDB/QueryResult/Filtered.pm index 895c16f3..0f9ebc63 100644 --- a/lib/MongoDB/QueryResult/Filtered.pm +++ b/lib/MongoDB/QueryResult/Filtered.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::QueryResult::Filtered; # ABSTRACT: An iterator for Mongo query results with client-side filtering diff --git a/lib/MongoDB/ReadConcern.pm b/lib/MongoDB/ReadConcern.pm index 5b6d123f..efa86c08 100644 --- a/lib/MongoDB/ReadConcern.pm +++ b/lib/MongoDB/ReadConcern.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::ReadConcern; # ABSTRACT: Encapsulate and validate a read concern diff --git a/lib/MongoDB/ReadPreference.pm b/lib/MongoDB/ReadPreference.pm index 4340ca76..f51cb016 100644 --- a/lib/MongoDB/ReadPreference.pm +++ b/lib/MongoDB/ReadPreference.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::ReadPreference; # ABSTRACT: Encapsulate and validate read preferences diff --git a/lib/MongoDB/Role/_BypassValidation.pm b/lib/MongoDB/Role/_BypassValidation.pm index 0d8e037a..d60d5c9e 100644 --- a/lib/MongoDB/Role/_BypassValidation.pm +++ b/lib/MongoDB/Role/_BypassValidation.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Role::_BypassValidation; # MongoDB interface for optionally applying bypassDocumentValidation diff --git a/lib/MongoDB/Role/_CollectionOp.pm b/lib/MongoDB/Role/_CollectionOp.pm index 53172f07..4ca102ef 100644 --- a/lib/MongoDB/Role/_CollectionOp.pm +++ b/lib/MongoDB/Role/_CollectionOp.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Role::_CollectionOp; # MongoDB role for things that operate on collections and need diff --git a/lib/MongoDB/Role/_CommandCursorOp.pm b/lib/MongoDB/Role/_CommandCursorOp.pm index 30691454..b40a43d1 100644 --- a/lib/MongoDB/Role/_CommandCursorOp.pm +++ b/lib/MongoDB/Role/_CommandCursorOp.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Role::_CommandCursorOp; # MongoDB interface for database commands with cursors diff --git a/lib/MongoDB/Role/_CursorAPI.pm b/lib/MongoDB/Role/_CursorAPI.pm index e4f4dd85..7827f5a0 100644 --- a/lib/MongoDB/Role/_CursorAPI.pm +++ b/lib/MongoDB/Role/_CursorAPI.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Role::_CursorAPI; # Role providing a cursor interface diff --git a/lib/MongoDB/Role/_DatabaseErrorThrower.pm b/lib/MongoDB/Role/_DatabaseErrorThrower.pm index 73dcb47d..1571cd62 100644 --- a/lib/MongoDB/Role/_DatabaseErrorThrower.pm +++ b/lib/MongoDB/Role/_DatabaseErrorThrower.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Role::_DatabaseErrorThrower; # MongoDB interface for providing the last database error diff --git a/lib/MongoDB/Role/_DatabaseOp.pm b/lib/MongoDB/Role/_DatabaseOp.pm index f7afd5b9..e56241d1 100644 --- a/lib/MongoDB/Role/_DatabaseOp.pm +++ b/lib/MongoDB/Role/_DatabaseOp.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Role::_DatabaseOp; # MongoDB role for operations within a database, that need a database name diff --git a/lib/MongoDB/Role/_DeprecationWarner.pm b/lib/MongoDB/Role/_DeprecationWarner.pm index c95e9076..91153e2d 100644 --- a/lib/MongoDB/Role/_DeprecationWarner.pm +++ b/lib/MongoDB/Role/_DeprecationWarner.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Role::_DeprecationWarner; # MongoDB interface for issuing deprecation warnings diff --git a/lib/MongoDB/Role/_InsertPreEncoder.pm b/lib/MongoDB/Role/_InsertPreEncoder.pm index 116d19bf..2c7e4f0d 100644 --- a/lib/MongoDB/Role/_InsertPreEncoder.pm +++ b/lib/MongoDB/Role/_InsertPreEncoder.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Role::_InsertPreEncoder; # MongoDB interface for pre-encoding and validating docs to insert diff --git a/lib/MongoDB/Role/_OpReplyParser.pm b/lib/MongoDB/Role/_OpReplyParser.pm index a510521f..9486f979 100644 --- a/lib/MongoDB/Role/_OpReplyParser.pm +++ b/lib/MongoDB/Role/_OpReplyParser.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Role::_OpReplyParser; # MongoDB interface for sending OP_QUERY|OP_GETMORE and parsing OP_REPLY diff --git a/lib/MongoDB/Role/_PrivateConstructor.pm b/lib/MongoDB/Role/_PrivateConstructor.pm index a9bacf61..e38e2f55 100644 --- a/lib/MongoDB/Role/_PrivateConstructor.pm +++ b/lib/MongoDB/Role/_PrivateConstructor.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Role::_PrivateConstructor; # MongoDB interface for a private constructor @@ -32,8 +34,8 @@ use namespace::clean; # the private constructor blesses args directly to the class for speed. BEGIN { WITH_ASSERTS - ? eval 'sub _new { my $class = shift; $class->new(@_) }' - : eval 'sub _new { my $class = shift; return bless {@_}, $class }'; + ? eval 'sub _new { my $class = shift; $class->new(@_) }' ## no critic + : eval 'sub _new { my $class = shift; return bless {@_}, $class }'; ## no critic } 1; diff --git a/lib/MongoDB/Role/_ReadOp.pm b/lib/MongoDB/Role/_ReadOp.pm index dccde7b5..f7ab389f 100644 --- a/lib/MongoDB/Role/_ReadOp.pm +++ b/lib/MongoDB/Role/_ReadOp.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Role::_ReadOp; # MongoDB role for read ops that provides read preference diff --git a/lib/MongoDB/Role/_ReadPrefModifier.pm b/lib/MongoDB/Role/_ReadPrefModifier.pm index e66f0dbc..be973eea 100644 --- a/lib/MongoDB/Role/_ReadPrefModifier.pm +++ b/lib/MongoDB/Role/_ReadPrefModifier.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Role::_ReadPrefModifier; # MongoDB role to modify OP_QUERY query document or flags to account diff --git a/lib/MongoDB/Role/_SingleBatchDocWrite.pm b/lib/MongoDB/Role/_SingleBatchDocWrite.pm index 432df0c7..0dcbce95 100644 --- a/lib/MongoDB/Role/_SingleBatchDocWrite.pm +++ b/lib/MongoDB/Role/_SingleBatchDocWrite.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Role::_SingleBatchDocWrite; # MongoDB interface for database insert/update/delete operations diff --git a/lib/MongoDB/Role/_UpdatePreEncoder.pm b/lib/MongoDB/Role/_UpdatePreEncoder.pm index e7120e0f..db3cda2f 100644 --- a/lib/MongoDB/Role/_UpdatePreEncoder.pm +++ b/lib/MongoDB/Role/_UpdatePreEncoder.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Role::_UpdatePreEncoder; # MongoDB interface for pre-encoding and validating update/replace docs diff --git a/lib/MongoDB/Role/_WriteOp.pm b/lib/MongoDB/Role/_WriteOp.pm index 0cec8d80..f91b08c8 100644 --- a/lib/MongoDB/Role/_WriteOp.pm +++ b/lib/MongoDB/Role/_WriteOp.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Role::_WriteOp; # MongoDB interface for database write operations (whether write commands diff --git a/lib/MongoDB/Role/_WriteResult.pm b/lib/MongoDB/Role/_WriteResult.pm index 85062576..89fe05e6 100644 --- a/lib/MongoDB/Role/_WriteResult.pm +++ b/lib/MongoDB/Role/_WriteResult.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Role::_WriteResult; # MongoDB interface for common write result attributes and methods diff --git a/lib/MongoDB/Timestamp.pm b/lib/MongoDB/Timestamp.pm index 220754a8..dd93a2c8 100644 --- a/lib/MongoDB/Timestamp.pm +++ b/lib/MongoDB/Timestamp.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::Timestamp; # ABSTRACT: Replication timestamp diff --git a/lib/MongoDB/UnacknowledgedResult.pm b/lib/MongoDB/UnacknowledgedResult.pm index 044cfacc..a2bd9d4f 100644 --- a/lib/MongoDB/UnacknowledgedResult.pm +++ b/lib/MongoDB/UnacknowledgedResult.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::UnacknowledgedResult; # ABSTRACT: MongoDB unacknowledged result object diff --git a/lib/MongoDB/UpdateResult.pm b/lib/MongoDB/UpdateResult.pm index 7d4409a7..1a87fcd5 100644 --- a/lib/MongoDB/UpdateResult.pm +++ b/lib/MongoDB/UpdateResult.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::UpdateResult; # ABSTRACT: MongoDB update result object diff --git a/lib/MongoDB/WriteConcern.pm b/lib/MongoDB/WriteConcern.pm index fe884b7a..df1a0390 100644 --- a/lib/MongoDB/WriteConcern.pm +++ b/lib/MongoDB/WriteConcern.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::WriteConcern; # ABSTRACT: Encapsulate and validate a write concern diff --git a/lib/MongoDB/_Credential.pm b/lib/MongoDB/_Credential.pm index 0bcf48f8..d4520d54 100644 --- a/lib/MongoDB/_Credential.pm +++ b/lib/MongoDB/_Credential.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::_Credential; use version; diff --git a/lib/MongoDB/_Server.pm b/lib/MongoDB/_Server.pm index 0f758a4c..db626af3 100644 --- a/lib/MongoDB/_Server.pm +++ b/lib/MongoDB/_Server.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::_Server; use version; diff --git a/lib/MongoDB/_Topology.pm b/lib/MongoDB/_Topology.pm index 49271372..ff610dcb 100644 --- a/lib/MongoDB/_Topology.pm +++ b/lib/MongoDB/_Topology.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::_Topology; use version; diff --git a/lib/MongoDB/_Types.pm b/lib/MongoDB/_Types.pm index ae5b3d6f..30c37973 100644 --- a/lib/MongoDB/_Types.pm +++ b/lib/MongoDB/_Types.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::_Types; # MongoDB type definitions @@ -41,6 +43,7 @@ use Type::Library IndexModel IndexModelList IxHash + MaybeHashRef MongoDBCollection MongoDBDatabase NonEmptyStr diff --git a/lib/MongoDB/_URI.pm b/lib/MongoDB/_URI.pm index 437a51dc..b1e10d5b 100644 --- a/lib/MongoDB/_URI.pm +++ b/lib/MongoDB/_URI.pm @@ -14,6 +14,8 @@ # limitations under the License. # +use strict; +use warnings; package MongoDB::_URI; use version; @@ -129,7 +131,7 @@ sub _parse_doc { my $set = {}; for my $tag ( split /,/, $string ) { if ( $tag =~ /\S/ ) { - my @kv = map { s{^\s*}{}; s{\s*$}{}; $_ } split /:/, $tag, 2; + my @kv = map { my $s = $_; $s =~ s{^\s*}{}; $s =~ s{\s*$}{}; $s } split /:/, $tag, 2; MongoDB::UsageError->throw("in option '$name', '$tag' is not a key:value pair") unless @kv == 2; $set->{$kv[0]} = $kv[1]; diff --git a/perlcritic.rc b/perlcritic.rc new file mode 100644 index 00000000..af4aa6b3 --- /dev/null +++ b/perlcritic.rc @@ -0,0 +1,26 @@ +severity = 5 +verbose = [%p] %m at %f, line %l, column %c. (Severity: %s)\n + +[Variables::ProhibitPunctuationVars] +allow = $@ $! + +[TestingAndDebugging::ProhibitNoStrict] +allow = refs + +[Variables::ProhibitEvilVariables] +variables = $DB::single + +# Turn these off +[-BuiltinFunctions::ProhibitStringyEval] +[-ControlStructures::ProhibitPostfixControls] +[-ControlStructures::ProhibitUnlessBlocks] +[-Documentation::RequirePodSections] +[-InputOutput::ProhibitInteractiveTest] +[-References::ProhibitDoubleSigils] +[-RegularExpressions::RequireExtendedFormatting] +[-InputOutput::ProhibitTwoArgOpen] +[-Modules::ProhibitEvilModules] + +# Turn this on +[Lax::ProhibitStringyEval::ExceptForRequire] +