<commit_before>//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#include "CheckLegacyParamsAction.h"

#include "AppFactory.h"
#include "Registry.h"

registerMooseAction("MooseApp", CheckLegacyParamsAction, "check_legacy_params");

InputParameters
CheckLegacyParamsAction::validParams()
{
  auto params = Action::validParams();
  params.addClassDescription("Checks whether or not objects exist that are constructed with the "
                             "legacy input parameter construction");
  return Action::validParams();
}

CheckLegacyParamsAction::CheckLegacyParamsAction(InputParameters params) : Action(params) {}

void
CheckLegacyParamsAction::act()
{
  // Not a big fan of testing objects within the object itself... but this is a temp object
  // and this is the easiest way to do it. MooseTestApp uses this parameter for the test
  const bool for_test = _app.parameters().have_parameter<bool>("test_check_legacy_params") &&
                        _app.parameters().get<bool>("test_check_legacy_params");

  std::set<std::pair<std::string, std::string>> objects;

  // Get the MooseObjects and Actions whose input parameters are constructed
  // using the legacy method, skipping those registered to MooseApp
  // (which is required so that apps that use legacy params from framework
  // objects still pass while we deprecate)
  const auto add_registry_objects = [&objects, &for_test](const auto & per_label_map)
  {
    for (const auto & label_entries_pair : per_label_map)
    {
      const auto & label = label_entries_pair.first;
      const auto & entries = label_entries_pair.second;

      for (const auto & entry : entries)
      {
        const auto & object_name = entry._classname;
        if (Registry::isRegisteredObj(object_name))
        {
          const auto params = entry._params_ptr();
          if (params.fromLegacyConstruction() || for_test)
            objects.insert(std::make_pair(object_name, label));
        }
      }
    }<commit_msg>a small fix for creating multiple subapps of a MultiApp #20657<commit_after>//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#include "CheckLegacyParamsAction.h"

#include "AppFactory.h"
#include "Registry.h"

registerMooseAction("MooseApp", CheckLegacyParamsAction, "check_legacy_params");

InputParameters
CheckLegacyParamsAction::validParams()
{
  auto params = Action::validParams();
  params.addClassDescription("Checks whether or not objects exist that are constructed with the "
                             "legacy input parameter construction");
  return Action::validParams();
}

CheckLegacyParamsAction::CheckLegacyParamsAction(InputParameters params) : Action(params) {}

void
CheckLegacyParamsAction::act()
{
  // no need to do the check for sub-apps other than the zero-th of a MultiApp
  // which helps when a MultiApp spawns lots of sub-apps.
  if (_app.multiAppNumber() > 0)
    return;

  // Not a big fan of testing objects within the object itself... but this is a temp object
  // and this is the easiest way to do it. MooseTestApp uses this parameter for the test
  const bool for_test = _app.parameters().have_parameter<bool>("test_check_legacy_params") &&
                        _app.parameters().get<bool>("test_check_legacy_params");

  std::set<std::pair<std::string, std::string>> objects;

  // Get the MooseObjects and Actions whose input parameters are constructed
  // using the legacy method, skipping those registered to MooseApp
  // (which is required so that apps that use legacy params from framework
  // objects still pass while we deprecate)
  const auto add_registry_objects = [&objects, &for_test](const auto & per_label_map)
  {
    for (const auto & label_entries_pair : per_label_map)
    {
      const auto & label = label_entries_pair.first;
      const auto & entries = label_entries_pair.second;

      for (const auto & entry : entries)
      {
        const auto & object_name = entry._classname;
        if (Registry::isRegisteredObj(object_name))
        {
          const auto params = entry._params_ptr();
          if (params.fromLegacyConstruction() || for_test)
            objects.insert(std::make_pair(object_name, label));
        }
      }
    }
{'fraction_non_alphanumeric': 0.10249894112664125, 'fraction_numerical': 0.002964845404489623, 'mean_word_length': 3.5588803088803087, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 12, 'https://': 6, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5518683', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1322, 'n_words': 404}