@brief A builder for SARIF rules `Rule` is a data model for SARIF rules. Known rules are usually initialized manually by field. Using a builder makes initialization more readable and prevents issues with reordering and optional fields.
| 113 | /// manually by field. Using a builder makes initialization more readable and |
| 114 | /// prevents issues with reordering and optional fields. |
| 115 | class RuleBuilder |
| 116 | { |
| 117 | public: |
| 118 | /// @brief Construct a new rule builder for a rule with the given ID |
| 119 | RuleBuilder(char const* id) { this->NewRule.Id = id; } |
| 120 | |
| 121 | /// @brief Set the name of the rule |
| 122 | RuleBuilder& Name(std::string name) |
| 123 | { |
| 124 | this->NewRule.Name = std::move(name); |
| 125 | return *this; |
| 126 | } |
| 127 | |
| 128 | /// @brief Set the full description of the rule |
| 129 | RuleBuilder& FullDescription(std::string fullDescription) |
| 130 | { |
| 131 | this->NewRule.FullDescription = std::move(fullDescription); |
| 132 | return *this; |
| 133 | } |
| 134 | |
| 135 | /// @brief Set the default message for the rule |
| 136 | RuleBuilder& DefaultMessage(std::string defaultMessage) |
| 137 | { |
| 138 | this->NewRule.DefaultMessage = std::move(defaultMessage); |
| 139 | return *this; |
| 140 | } |
| 141 | |
| 142 | /// @brief Build the rule |
| 143 | std::pair<std::string, Rule> Build() const |
| 144 | { |
| 145 | return std::make_pair(this->NewRule.Id, this->NewRule); |
| 146 | } |
| 147 | |
| 148 | private: |
| 149 | Rule NewRule; |
| 150 | }; |
| 151 | |
| 152 | /// @brief Get the SARIF severity level of a CMake message type |
| 153 | ResultSeverityLevel MessageSeverityLevel(MessageType t); |
no test coverage detected
searching dependent graphs…