| 97 | } |
| 98 | |
| 99 | std::size_t cmSarif::ResultsLog::UseRule(std::string const& id) const |
| 100 | { |
| 101 | // Check if the rule is already in the index |
| 102 | auto it = this->RuleToIndex.find(id); |
| 103 | if (it != this->RuleToIndex.end()) { |
| 104 | // The rule is already in use. Return the known index |
| 105 | return it->second; |
| 106 | } |
| 107 | |
| 108 | // This rule is not yet in the index, so check if it is recognized |
| 109 | auto itKnown = this->KnownRules.find(id); |
| 110 | if (itKnown == this->KnownRules.end()) { |
| 111 | // The rule is not known. Add an empty rule to the known rules so that it |
| 112 | // is included in the output |
| 113 | this->KnownRules.emplace(RuleBuilder(id.c_str()).Build()); |
| 114 | } |
| 115 | |
| 116 | // Since this is the first time the rule is used, enable it and add it to the |
| 117 | // index |
| 118 | std::size_t idx = this->EnabledRules.size(); |
| 119 | this->RuleToIndex[id] = idx; |
| 120 | this->EnabledRules.emplace_back(id); |
| 121 | return idx; |
| 122 | } |
| 123 | |
| 124 | cmSarif::ResultSeverityLevel cmSarif::MessageSeverityLevel(MessageType t) |
| 125 | { |
no test coverage detected