[SERVER-18703] Coverity analysis defect 72685: Copy-paste error Created: 28/May/15  Updated: 14/Apr/16  Resolved: 28/May/15

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Max Hirschhorn
Resolution: Done Votes: 0
Labels: coverity
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Quint Iteration 4
Participants:

 Description   

A copied piece of code is inconsistent with the original

Defect 72685 (STATIC_C)
Checker COPY_PASTE_ERROR (subcategory none)
File: /src/mongo/db/matcher/expression_algo_test.cpp
Function mongo::UnitTest_ExpressionAlgoIsSubsetOf_Exists::_doTest()
/src/mongo/db/matcher/expression_algo_test.cpp, line: 277
"aExists" looks like the original copy.

            ASSERT_TRUE(expression::isSubsetOf(aExists.get(), aExists.get()));

/src/mongo/db/matcher/expression_algo_test.cpp, line: 280
"aExists" in "aExists" looks like a copy-paste error.

            ASSERT_TRUE(expression::isSubsetOf(aExistsBExists.get(), aExists.get()));



 Comments   
Comment by Max Hirschhorn [ 28/May/15 ]

The test cases

ASSERT_TRUE(expression::isSubsetOf(aExists.get(), aExists.get()));
ASSERT_TRUE(expression::isSubsetOf(aExistsBExists.get(), aExists.get()));

are both intentional. The former ensures that checking whether two $exists expressions are equivalent works, and the latter ensures that AND-expressions involving $exists are identified as subsets.

Testing ASSERT_TRUE(expression::isSubsetOf(aExistsBExists.get(), aExistsBExists.get())) is valid, but would not provide any additional coverage. Closing this ticket as "works as designed."

Generated at Thu Feb 08 03:48:30 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.