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

GothenburgBitFactory / taskwarrior / 9689737168

27 Jun 2024 02:29AM UTC coverage: 84.216% (-0.3%) from 84.513%
9689737168

push

github

web-flow
Un-deprecate the non-1/0 boolean values (#3522)

As per https://github.com/GothenburgBitFactory/tw.org/issues/867

Co-authored-by: Sebastian Carlos <sebastiancarlos@gmail.com>

19251 of 22859 relevant lines covered (84.22%)

19999.0 hits per line

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

66.67
/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
#include <cstddef>
29
#include <sstream>
30
#include <Context.h>
31
#include <format.h>
32

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

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

51
  // One-time initialization, on demand.
52
  static std::map <std::string, std::string> legacyMap {{"priority.", "priority"}};
7,823✔
53

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

63
////////////////////////////////////////////////////////////////////////////////
64
void legacySortColumnMap (std::string& name)
1,523✔
65
{
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"}};
2,105✔
81

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

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

100
    // Deprecated in 2.5.0.
101
    // report.*.annotations
102
    if (it.first.length () > 19 &&
2,886✔
103
        it.first.substr (0, 7) == "report." &&
15,676✔
104
        it.first.substr (it.first.length () - 12) == ".annotations")
8,189✔
105
      deprecated.push_back (it.first);
×
106

107
    // Deprecated in 2.5.0.
108
    if (it.first == "next"              ||
12,790✔
109
        it.first == "annotations"       ||
12,790✔
110
        it.first == "export.ical.class")
6,395✔
111
      deprecated.push_back (it.first);
×
112

113
    // Deprecated in 2.5.0.
114
    if (it.first == "urgency.inherit.coefficient")
6,395✔
115
        deprecated.push_back (it.first);
×
116
  }
117

118
  std::stringstream out;
26✔
119
  if (deprecated.size ())
26✔
120
  {
121
    out << "Your .taskrc file contains variables that are deprecated:\n";
×
122

123
    for (const auto& dep : deprecated)
×
124
      out << "  " << dep << "\n";
×
125

126
    out << "\n";
×
127
  }
128

129
  return out.str ();
52✔
130
}
26✔
131

132
////////////////////////////////////////////////////////////////////////////////
133
std::string legacyCheckForDeprecatedColumns ()
26✔
134
{
135
  std::vector <std::string> deprecated;
26✔
136
  for (auto& it : Context::getContext ().config)
6,421✔
137
  {
138
    if (it.first.find ("report") == 0)
6,395✔
139
    {
140
      // Deprecated in 2.0.0
141
      std::string value = Context::getContext ().config.get (it.first);
2,678✔
142
      if (value.find ("entry_time") != std::string::npos ||
5,356✔
143
          value.find ("start_time") != std::string::npos ||
5,356✔
144
          value.find ("end_time")   != std::string::npos)
2,678✔
145
        deprecated.push_back (it.first);
×
146
    }
2,678✔
147
  }
148

149
  std::stringstream out;
26✔
150
  out << "\n";
26✔
151

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

156
    for (const auto& dep : deprecated)
×
157
      out << "  " << dep << "=" << Context::getContext ().config.get (dep) << "\n";
×
158

159
    out << "\n";
×
160
  }
161

162
  return out.str ();
52✔
163
}
26✔
164

165
////////////////////////////////////////////////////////////////////////////////
166
void legacyAttributeMap (std::string& name)
×
167
{
168
  // TW-1274, 2.4.0
169
  if (name == "modification")
×
170
    name = "modified";
×
171
}
172

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