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

GothenburgBitFactory / taskwarrior / 10152339701

29 Jul 2024 09:45PM UTC coverage: 84.437% (+0.07%) from 84.372%
10152339701

push

github

web-flow
Merge pull request #3566 from felixschurk/add-clang-format

Add clang-format to enforce style guide

12359 of 13760 new or added lines in 147 files covered. (89.82%)

123 existing lines in 42 files now uncovered.

19070 of 22585 relevant lines covered (84.44%)

19724.02 hits per line

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

95.83
/src/columns/ColTypeString.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 <ColTypeString.h>
31
#include <Context.h>
32
#include <Eval.h>
33
#include <Filter.h>
34
#include <Variant.h>
35
#include <format.h>
36

37
#define STRING_INVALID_MOD "The '{1}' attribute does not allow a value of '{2}'."
38

39
////////////////////////////////////////////////////////////////////////////////
40
ColumnTypeString::ColumnTypeString() { _type = "string"; }
56,317✔
41

42
////////////////////////////////////////////////////////////////////////////////
43
bool ColumnTypeString::validate(const std::string& input) const {
14✔
44
  return input.length() ? true : false;
14✔
45
}
46

47
////////////////////////////////////////////////////////////////////////////////
48
void ColumnTypeString::modify(Task& task, const std::string& value) {
109✔
49
  std::string label = "   [1;37;43mMODIFICATION [0m ";
109✔
50

51
  // Only if it's a DOM ref, eval it first.
52
  Lexer lexer(value);
109✔
53
  std::string domRef;
109✔
54
  Lexer::Type type;
55
  if (lexer.token(domRef, type) && type == Lexer::Type::dom &&
112✔
56
      // Ensure 'value' contains only the DOM reference and no other tokens
57
      // The lexer.token returns false for end-of-string.
58
      // This works as long as all the DOM references we should support consist
59
      // only of a single token.
60
      lexer.token(domRef, type) == false) {
3✔
61
    Eval e;
3✔
62
    e.addSource(domSource);
3✔
63

64
    Variant v;
3✔
65
    e.evaluateInfixExpression(value, v);
3✔
66
    std::string strValue = (std::string)v;
3✔
67
    if (validate(strValue)) {
3✔
68
      task.set(_name, strValue);
3✔
69
      Context::getContext().debug(label + _name + " <-- '" + strValue + "' <-- '" + value + '\'');
3✔
70
    } else
NEW
71
      throw format(STRING_INVALID_MOD, _name, value);
×
72
  } else {
3✔
73
    if (validate(value)) {
106✔
74
      task.set(_name, value);
104✔
75
      Context::getContext().debug(label + _name + " <-- '" + value + '\'');
104✔
76
    } else
77
      throw format(STRING_INVALID_MOD, _name, value);
2✔
78
  }
79
}
113✔
80

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

© 2025 Coveralls, Inc