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 % 53 0
Test Date: 2026-10-11 15:05:20 Functions: 0.0 % 3 0

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

Generated by: LCOV version 2.0-1