The following issues were found

src/mongo/db/commands.cpp
1 issues
Boolean value assigned to pointer.
Error

Line: 657 CWE codes: 587

                                "threadName"_attr = threadName,
                  "appName"_attr = appName,
                  "namespace"_attr = nss,
                  "isInternalClient"_attr = isInternalClient,
                  "command"_attr = cmd->getName());

            return true;
        }
    }

            

Reported by Cppcheck.

src/mongo/db/commands/async_command_execution_test.cpp
1 issues
syntax error
Error

Line: 147

                  }
};

TEST_F(AsyncCommandExecutionTest, BuildInfo) {
    runTestForCommand("buildinfo");
}

}  // namespace
}  // namespace mongo

            

Reported by Cppcheck.

src/mongo/db/commands/command_mirroring_test.cpp
1 issues
syntax error
Error

Line: 139

                  boost::optional<BSONObj> shardVersion;
};

TEST_F(UpdateCommandTest, NoQuery) {
    auto update = BSON("q" << BSONObj() << "u" << BSON("$set" << BSON("_id" << 1)));
    auto mirroredObj = createCommandAndGetMirrored(kCollection, {update});

    ASSERT_EQ(mirroredObj["find"].String(), kCollection);
    ASSERT_EQ(mirroredObj["filter"].Obj().toString(), "{}");

            

Reported by Cppcheck.

src/mongo/db/commands/fsync.cpp
1 issues
Boolean value assigned to pointer.
Error

Line: 139 CWE codes: 587

                      }

        const bool lock = cmdObj["lock"].trueValue();
        LOGV2(20461, "CMD fsync: lock:{lock}", "CMD fsync", "lock"_attr = lock);

        // fsync + lock is sometimes used to block writes out of the system and does not care if
        // the `BackupCursorService::fsyncLock` call succeeds.
        const bool allowFsyncFailure =
            getTestCommandsEnabled() && cmdObj["allowFsyncFailure"].trueValue();

            

Reported by Cppcheck.

src/mongo/db/commands/index_filter_commands_test.cpp
1 issues
syntax error
Error

Line: 204

               * Tests for ListFilters
 */

TEST(IndexFilterCommandsTest, ListFiltersEmpty) {
    QuerySettings empty;
    vector<BSONObj> filters = getFilters(empty);
    ASSERT_TRUE(filters.empty());
}


            

Reported by Cppcheck.

src/mongo/db/commands/list_collections_filter_test.cpp
1 issues
syntax error
Error

Line: 41

              
using namespace mongo;

TEST(ListCollectionsFilterTest, AddCollectionFilter) {
    BSONObj filter = fromjson("{'options.capped': false}");
    BSONObj expected = fromjson(
        "{$and: ["
        "{'options.capped': false}, "
        "{$or: [{type: 'collection'}, {type: {$exists: false}}]}]}");

            

Reported by Cppcheck.

src/mongo/db/commands/map_reduce_agg_test.cpp
1 issues
syntax error
Error

Line: 71

              constexpr auto reduceJavascript = "reduce!"_sd;
constexpr auto finalizeJavascript = "finalize!"_sd;

TEST(MapReduceAggTest, testBasicTranslate) {
    auto nss = NamespaceString{"db", "coll"};
    auto mr =
        MapReduceCommandRequest{nss,
                                MapReduceJavascriptCode{mapJavascript.toString()},
                                MapReduceJavascriptCode{reduceJavascript.toString()},

            

Reported by Cppcheck.

src/mongo/db/commands/map_reduce_parse_test.cpp
1 issues
syntax error
Error

Line: 50

              constexpr auto reduceJavascript = "reduce!"_sd;
constexpr auto finalizeJavascript = "finalize!"_sd;

TEST(MapReduceParseTest, failedParse) {
    auto ctx = IDLParserErrorContext("mapReduce");
    // Missing fields.
    ASSERT_THROWS(MapReduceCommandRequest::parse(ctx,
                                                 BSON(""
                                                      << ""

            

Reported by Cppcheck.

src/mongo/db/commands/mr_test.cpp
1 issues
syntax error
Error

Line: 129

              /**
 * Tests for map_reduce_common::parseOutputOptions.
 */
TEST(ConfigOutputOptionsTest, parseOutputOptions) {
    // Missing 'out' field.
    ASSERT_THROWS(map_reduce_common::parseOutputOptions("mydb", fromjson("{}")),
                  AssertionException);
    // 'out' must be either string or object.
    ASSERT_THROWS(map_reduce_common::parseOutputOptions("mydb", fromjson("{out: 99}")),

            

Reported by Cppcheck.

src/mongo/db/commands/parse_log_component_settings_test.cpp
1 issues
syntax error
Error

Line: 45

              
typedef std::vector<LogComponentSetting> Settings;

TEST(Empty, Empty) {
    BSONObj input;
    StatusWith<Settings> result = parseLogComponentSettings(input);

    ASSERT_OK(result.getStatus());
    ASSERT_EQUALS(result.getValue().size(), 0u);

            

Reported by Cppcheck.