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

GothenburgBitFactory / taskwarrior / 12358478612

16 Dec 2024 05:59PM UTC coverage: 84.898% (-0.6%) from 85.522%
12358478612

push

github

web-flow
[pre-commit.ci] pre-commit autoupdate (#3725)

updates:
- [github.com/pre-commit/mirrors-clang-format: v19.1.4 → v19.1.5](https://github.com/pre-commit/mirrors-clang-format/compare/v19.1.4...v19.1.5)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

19276 of 22705 relevant lines covered (84.9%)

23265.72 hits per line

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

67.31
/src/legacy.cpp
1
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright 2006 - 2021, Tomas Babej, Paul Beckingham, Federico Hernandez.
4
//
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
//
12
// The above copyright notice and this permission notice shall be included
13
// in all copies or substantial portions of the Software.
14
//
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
// SOFTWARE.
22
//
23
// https://www.opensource.org/licenses/mit-license.php
24
//
25
////////////////////////////////////////////////////////////////////////////////
26

27
#include <cmake.h>
28
// cmake.h include header must come first
29

30
#include <Context.h>
31
#include <format.h>
32

33
#include <cstddef>
34
#include <sstream>
35

36
#define STRING_LEGACY_PRIORITY "Legacy attribute found.  Please change '{1}' to '{2}'."
37

38
////////////////////////////////////////////////////////////////////////////////
39
void legacyColumnMap(std::string& name) {
7,539✔
40
  // 2014-01-26: priority_long        --> priority.long        Mapping removed
41
  // 2014-01-26: entry_time           --> entry                Mapping removed
42
  // 2014-01-26: start_time           --> start                Mapping removed
43
  // 2014-01-26: end_time             --> end                  Mapping removed
44
  // 2014-01-26: countdown            --> due.countdown        Mapping removed
45
  // 2014-01-26: countdown_compact    --> due.countdown        Mapping removed
46
  // 2014-01-26: age                  --> entry.age            Mapping removed
47
  // 2014-01-26: age_compact          --> entry.age            Mapping removed
48
  // 2014-01-26: active               --> start.active         Mapping removed
49
  // 2014-01-26: recurrence_indicator --> recur.indicator      Mapping removed
50
  // 2014-01-26: tag_indicator        --> tags.indicator       Mapping removed
51
  // 2014-01-26: description_only     --> description.desc     Mapping removed
52

53
  // One-time initialization, on demand.
54
  static std::map<std::string, std::string> legacyMap{{"priority.", "priority"}};
9,528✔
55

56
  // If a legacy column was used, complain about it, but modify it anyway.
57
  auto found = legacyMap.find(name);
7,539✔
58
  if (found != legacyMap.end()) {
7,539✔
59
    Context::getContext().footnote(format(STRING_LEGACY_PRIORITY, name, found->second));
×
60
    name = found->second;
×
61
  }
62
}
8,202✔
63

64
////////////////////////////////////////////////////////////////////////////////
65
void legacySortColumnMap(std::string& name) {
1,573✔
66
  // 2014-01-26: priority_long        --> priority             Mapping removed
67
  // 2014-01-26: entry_time           --> entry                Mapping removed
68
  // 2014-01-26: start_time           --> start                Mapping removed
69
  // 2014-01-26: end_time             --> end                  Mapping removed
70
  // 2014-01-26: countdown            --> due                  Mapping removed
71
  // 2014-01-26: countdown_compact    --> due                  Mapping removed
72
  // 2014-01-26: age                  --> entry                Mapping removed
73
  // 2014-01-26: age_compact          --> entry                Mapping removed
74
  // 2014-01-26: active               --> start                Mapping removed
75
  // 2014-01-26: recurrence_indicator --> recur                Mapping removed
76
  // 2014-01-26: tag_indicator        --> tags                 Mapping removed
77
  // 2014-01-26: description_only     --> description          Mapping removed
78

79
  // One-time initialization, on demand.
80
  static std::map<std::string, std::string> legacyMap{{"priority.", "priority"}};
3,397✔
81

82
  // If a legacy column was used, complain about it, but modify it anyway.
83
  auto found = legacyMap.find(name);
1,573✔
84
  if (found != legacyMap.end()) {
1,573✔
85
    Context::getContext().footnote(format(STRING_LEGACY_PRIORITY, name, found->second));
×
86
    name = found->second;
×
87
  }
88
}
2,181✔
89

90
////////////////////////////////////////////////////////////////////////////////
91
std::string legacyCheckForDeprecatedVariables() {
26✔
92
  std::vector<std::string> deprecated;
26✔
93
  for (auto& it : Context::getContext().config) {
6,395✔
94
    // 2014-07-04: report.*.limit removed.
95
    // 2016-02-24: alias._query removed.
96

97
    // Deprecated in 2.5.0.
98
    // report.*.annotations
99
    if (it.first.length() > 19 && it.first.substr(0, 7) == "report." &&
14,532✔
100
        it.first.substr(it.first.length() - 12) == ".annotations")
8,163✔
101
      deprecated.push_back(it.first);
×
102

103
    // Deprecated in 2.5.0.
104
    if (it.first == "next" || it.first == "annotations" || it.first == "export.ical.class")
6,369✔
105
      deprecated.push_back(it.first);
×
106

107
    // Deprecated in 2.5.0.
108
    if (it.first == "urgency.inherit.coefficient") deprecated.push_back(it.first);
6,369✔
109
  }
110

111
  std::stringstream out;
26✔
112
  if (deprecated.size()) {
26✔
113
    out << "Your .taskrc file contains variables that are deprecated:\n";
×
114

115
    for (const auto& dep : deprecated) out << "  " << dep << "\n";
×
116

117
    out << "\n";
×
118
  }
119

120
  return out.str();
52✔
121
}
26✔
122

123
////////////////////////////////////////////////////////////////////////////////
124
std::string legacyCheckForDeprecatedColumns() {
26✔
125
  std::vector<std::string> deprecated;
26✔
126
  for (auto& it : Context::getContext().config) {
6,395✔
127
    if (it.first.find("report") == 0) {
6,369✔
128
      // Deprecated in 2.0.0
129
      std::string value = Context::getContext().config.get(it.first);
2,678✔
130
      if (value.find("entry_time") != std::string::npos ||
5,356✔
131
          value.find("start_time") != std::string::npos ||
5,356✔
132
          value.find("end_time") != std::string::npos)
2,678✔
133
        deprecated.push_back(it.first);
×
134
    }
2,678✔
135
  }
136

137
  std::stringstream out;
26✔
138
  out << "\n";
26✔
139

140
  if (deprecated.size()) {
26✔
141
    out << "Your .taskrc file contains reports with deprecated columns.  Please check for "
142
           "entry_time, start_time or end_time in:\n";
×
143

144
    for (const auto& dep : deprecated)
×
145
      out << "  " << dep << "=" << Context::getContext().config.get(dep) << "\n";
×
146

147
    out << "\n";
×
148
  }
149

150
  return out.str();
52✔
151
}
26✔
152

153
////////////////////////////////////////////////////////////////////////////////
154
void legacyAttributeMap(std::string& name) {
×
155
  // TW-1274, 2.4.0
156
  if (name == "modification") name = "modified";
×
157
}
×
158

159
////////////////////////////////////////////////////////////////////////////////
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

© 2024 Coveralls, Inc