• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ParadoxGameConverters / Vic3ToHoI4 / 13090188366

26 Jan 2025 07:59AM UTC coverage: 95.116% (-0.03%) from 95.146%
13090188366

push

github

web-flow
Eliminate warnings (#701)

* Externals in angle brackets.

* Commons from lib

* Update to preview versions of externals.

* Update fronter

* Switch to std::filesystem::path

* Unused variables

* Type conversion stuff.

* constness

* Missing headers

* Prefix increment, not postfix

* Check optional

* Remove a stray extern

* explicit

* Return an error case.

* Default value

* Enforce warnings.

* Disable some unfixable warnings.

* Update commons

* Formatting

* Fix a test

* Use fixed common

* Fix tests.

* Formatting

* Update to merged versions

* Make codefactor happier.

965 of 1008 new or added lines in 120 files covered. (95.73%)

2 existing lines in 2 files now uncovered.

20428 of 21477 relevant lines covered (95.12%)

61689.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.05
/src/mappers/flags/flag_mapper.cpp
1
#include "src/mappers/flags/flag_mapper.h"
2

3
#include <external/commonItems/Log.h>
4
#include <external/commonItems/OSCompatibilityLayer.h>
5
#include <external/fmt/include/fmt/format.h>
6

7
#include <filesystem>
8

9

10

11
using std::filesystem::copy_options;
12
using std::filesystem::path;
13

14

15

16
namespace
17
{
18

19

20
}  // namespace
21

22

23
bool mappers::FlagMapper::CopyFlags(const std::vector<std::string>& tags)
5✔
24
{
25
   std::set<std::string> tags_needing_flags;
5✔
26
   for (const auto& tag: tags)
17✔
27
   {
28
      // Ignore if we already have a custom or mod flag.
29
      if (available_flags_.contains(tag) || custom_flags_.contains(tag))
12✔
30
      {
31
         available_flags_.erase(tag);
5✔
32
         continue;
5✔
33
      }
34
      tags_needing_flags.insert(tag);
7✔
35
   }
36
   for (const auto& tag: tags_needing_flags)
11✔
37
   {
38
      if (available_flags_.empty())
7✔
39
      {
40
         Log(LogLevel::Warning) << "Ran out of available flags.";
1✔
41
         return false;
1✔
42
      }
43
      if (!CopyFlag(tag))
6✔
44
      {
45
         return false;
×
46
      }
47
   }
48
   return true;
4✔
49
}
5✔
50

51
bool mappers::FlagMapper::CopyFlag(const std::string& tag)
9✔
52
{
53
   if (available_flags_.contains(tag) || custom_flags_.contains(tag))
9✔
54
   {
55
      available_flags_.erase(tag);
1✔
56
      return false;
1✔
57
   }
58
   if (available_flags_.empty())
8✔
59
   {
60
      return false;
1✔
61
   }
62

63
   path file_to_copy = available_flags_.extract(available_flags_.begin()).mapped();
7✔
64
   const path filename = file_to_copy.filename();
7✔
65
   const path extension = file_to_copy.extension();
7✔
66
   file_to_copy.remove_filename();
7✔
67
   for (const auto& folder: kFlagFolders)
28✔
68
   {
69
      const path source = file_to_copy / folder / filename;
21✔
70
      path target = base_flag_folder_ / folder / tag;
21✔
71
      target += extension;
21✔
72
      try
73
      {
74
         if (!copy_file(source, target, copy_options::overwrite_existing))
21✔
75
         {
NEW
76
            Log(LogLevel::Warning) << "Could not copy flag file " << source << " to " << target;
×
NEW
77
            return false;
×
78
         }
79
      }
NEW
80
      catch (...)
×
81
      {
82
         Log(LogLevel::Warning) << "Could not copy flag file " << source << " to " << target;
×
83
         return false;
×
UNCOV
84
      }
×
85
   }
21✔
86
   return true;
7✔
87
}
7✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc