LCOV - code coverage report
Current view: top level - oksutils/apps - oks_report_no_descriptions.cxx (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 55 0
Test Date: 2025-12-21 13:07:08 Functions: 0.0 % 3 0

            Line data    Source code
       1              : /**
       2              :  *  \file oks_dump.cpp
       3              :  *
       4              :  *  This file is part of the OKS package.
       5              :  *  https://gitlab.cern.ch/atlas-tdaq-software/oks
       6              :  *
       7              :  *  Report classes without descriptions.
       8              :  */
       9              : 
      10              : #include <stdlib.h>
      11              : 
      12              : #include "oks/attribute.hpp"
      13              : #include "oks/relationship.hpp"
      14              : #include "oks/class.hpp"
      15              : #include "oks/kernel.hpp"
      16              : #include "oks/file.hpp"
      17              : #include "oks/exceptions.hpp"
      18              : 
      19              : using namespace dunedaq;
      20              : using namespace dunedaq::oks;
      21              : 
      22              : static void
      23            0 : printUsage(std::ostream& s)
      24              : {
      25            0 :   s << "Usage: oks_report_bad_classes [--help] database-file [database-file(s)]\n"
      26              :        "\n"
      27              :        "Options:\n"
      28              :        "    -h | --help     print this text\n"
      29              :        "\n"
      30              :        "Description:\n"
      31              :        "    Report classes, attributes and relationships without description.\n"
      32            0 :        "\n";
      33            0 : }
      34              : 
      35              : static void
      36            0 : report_class(const OksClass * c, bool no_description)
      37              : {
      38            0 :   std::cout << " * class \"" << c->get_name() << '\"';
      39              : 
      40            0 :   if (no_description)
      41            0 :     std::cout << " has no description";
      42              : 
      43            0 :   std::cout << " (from \"" << c->get_file()->get_short_file_name() << "\")\n";
      44            0 : }
      45              : 
      46              : int
      47            0 : main(int argc, char **argv)
      48              : {
      49            0 :   OksKernel kernel;
      50            0 :   kernel.set_silence_mode(true);
      51              : 
      52            0 :   try
      53              :     {
      54            0 :       for (int i = 1; i < argc; i++)
      55              :         {
      56            0 :           const char *cp = argv[i];
      57              : 
      58            0 :           if (!strcmp(cp, "-h") || !strcmp(cp, "--help"))
      59              :             {
      60            0 :               printUsage(std::cout);
      61              :               return EXIT_SUCCESS;
      62              :             }
      63              :           else
      64              :             {
      65            0 :               if (kernel.load_file(cp) == 0)
      66              :                 {
      67            0 :                   Oks::error_msg("oks_dump") << "\tCan not load file \"" << cp << "\", exiting...\n";
      68              :                   return EXIT_FAILURE;
      69              :                 }
      70              :             }
      71              :         }
      72              : 
      73            0 :       if (kernel.schema_files().empty())
      74              :         {
      75            0 :           Oks::error_msg("oks_dump") << "\tAt least one oks file have to be provided, exiting...\n";
      76              :           return EXIT_FAILURE;
      77              :         }
      78              :     }
      79            0 :   catch (oks::exception &ex)
      80              :     {
      81            0 :       std::cerr << "Caught oks exception:\n" << ex << std::endl;
      82            0 :       return EXIT_FAILURE;
      83            0 :     }
      84            0 :   catch (std::exception &e)
      85              :     {
      86            0 :       std::cerr << "Caught standard C++ exception: " << e.what() << std::endl;
      87            0 :       return EXIT_FAILURE;
      88            0 :     }
      89            0 :   catch (...)
      90              :     {
      91            0 :       std::cerr << "Caught unknown exception" << std::endl;
      92            0 :       return EXIT_FAILURE;
      93            0 :     }
      94              : 
      95            0 :   std::cout << "Processed schema files:\n";
      96            0 :   for (const auto &i : kernel.schema_files())
      97            0 :     std::cout << i.second->get_short_file_name() << std::endl;
      98              : 
      99            0 :   for (const auto i : kernel.classes())
     100              :     {
     101            0 :       bool printed(false);
     102              : 
     103            0 :       if (i.second->get_description().empty())
     104              :         {
     105            0 :           report_class(i.second, true);
     106              :           printed = true;
     107              :         }
     108              : 
     109            0 :       if (const std::list<OksAttribute*> *attrs = i.second->direct_attributes())
     110            0 :         for (const auto &j : *attrs)
     111              : 
     112            0 :           if (j->get_description().empty())
     113              :             {
     114            0 :               if (!printed)
     115              :                 {
     116            0 :                   report_class(i.second, false);
     117              :                   printed = true;
     118              :                 }
     119            0 :               std::cout << "   - attribute \"" << j->get_name() << "\" has no description\n";
     120              :             }
     121              : 
     122            0 :       if (const std::list<OksRelationship*> *rels = i.second->direct_relationships())
     123            0 :         for (const auto &j : *rels)
     124            0 :           if (j->get_description().empty())
     125              :             {
     126            0 :               if (!printed)
     127              :                 {
     128            0 :                   report_class(i.second, false);
     129              :                   printed = true;
     130              :                 }
     131            0 :               std::cout << "   - relationship \"" << j->get_name() << "\" has no description\n";
     132              :             }
     133              :     }
     134              : 
     135            0 :   return EXIT_SUCCESS;
     136            0 : }
        

Generated by: LCOV version 2.0-1