Skip to content
Permalink
Browse files

Activate readability-identifier-naming.VariableCase check.

Change-Id: I866d8a94b02e8e920c6783877ea021a0fcb76aad
  • Loading branch information...
svenpanne committed May 14, 2019
1 parent f8b147d commit 6d207649a1c261d1d3d3c436cffc38a14fe8429a
@@ -57,4 +57,6 @@ CheckOptions:
value: '_'
- key: readability-identifier-naming.PrivateMemberSuffix
value: '_'
- key: readability-identifier-naming.VariableCase
value: 'lower_case'
...
@@ -379,7 +379,7 @@ std::string extractStateType(const std::string &str) {
return str;
}

std::unordered_map<std::string, ServiceState> serviceStateTypes{
std::unordered_map<std::string, ServiceState> fl_service_state_types{
// normal states
{"OK", ServiceState::ok},
{"WARNING", ServiceState::warning},
@@ -388,7 +388,7 @@ std::unordered_map<std::string, ServiceState> serviceStateTypes{
// states from "... ALERT"/"... NOTIFICATION"
{"RECOVERY", ServiceState::ok}};

std::unordered_map<std::string, HostState> hostStateTypes{
std::unordered_map<std::string, HostState> fl_host_state_types{
// normal states
{"UP", HostState::up},
{"DOWN", HostState::down},
@@ -405,12 +405,12 @@ std::unordered_map<std::string, HostState> hostStateTypes{

// static
ServiceState LogEntry::parseServiceState(const std::string &str) {
auto it = serviceStateTypes.find(extractStateType(str));
return it == serviceStateTypes.end() ? ServiceState::ok : it->second;
auto it = fl_service_state_types.find(extractStateType(str));
return it == fl_service_state_types.end() ? ServiceState::ok : it->second;
}

// static
HostState LogEntry::parseHostState(const std::string &str) {
auto it = hostStateTypes.find(extractStateType(str));
return it == hostStateTypes.end() ? HostState::up : it->second;
auto it = fl_host_state_types.find(extractStateType(str));
return it == fl_host_state_types.end() ? HostState::up : it->second;
}
@@ -183,7 +183,7 @@ Logger *LogManager::lookup(const std::string &name, Logger *parent) {
return it->second.get();
}

LogManager LogManager::_global_log_manager;
LogManager LogManager::global_log_manager;

// -----------------------------------------------------------------------------

@@ -246,11 +246,11 @@ class ContextLogger : public LoggerDecorator {

class LogManager {
public:
static LogManager *getLogManager() { return &_global_log_manager; }
static LogManager *getLogManager() { return &global_log_manager; }
Logger *getLogger(const std::string &name);

private:
static LogManager _global_log_manager;
static LogManager global_log_manager;

// The mutex protects _known_loggers.
std::mutex _mutex;
@@ -70,11 +70,11 @@ std::optional<std::string> CustomVariableExpander::expand(
return {};
}

RegExp regExp(str.substr(_prefix.size()), RegExp::Case::ignore,
RegExp::Syntax::literal);
RegExp re(str.substr(_prefix.size()), RegExp::Case::ignore,
RegExp::Syntax::literal);
for (const auto &[name, value] :
_mc->customAttributes(&_cvm, AttributeKind::custom_variables)) {
if (regExp.match(name)) {
if (re.match(name)) {
return value;
}
}
@@ -399,10 +399,10 @@ void Query::parseStatsLine(char *line) {
auto it = stats_ops.find(col_or_op);
if (it == stats_ops.end()) {
column = _table.column(col_or_op);
auto relOp = relationalOperatorForName(nextStringArgument(&line));
auto rel_op = relationalOperatorForName(nextStringArgument(&line));
auto operand = mk::lstrip(line);
sc = std::make_unique<StatsColumnCount>(
column->createFilter(Filter::Kind::stats, relOp, operand));
column->createFilter(Filter::Kind::stats, rel_op, operand));
} else {
column = _table.column(nextStringArgument(&line));
sc = std::make_unique<StatsColumnOp>(it->second, column.get());
@@ -416,9 +416,9 @@ void Query::parseStatsLine(char *line) {

void Query::parseFilterLine(char *line, FilterStack &filters) {
auto column = _table.column(nextStringArgument(&line));
auto relOp = relationalOperatorForName(nextStringArgument(&line));
auto rel_op = relationalOperatorForName(nextStringArgument(&line));
auto operand = mk::lstrip(line);
auto sub_filter = column->createFilter(Filter::Kind::row, relOp, operand);
auto sub_filter = column->createFilter(Filter::Kind::row, rel_op, operand);
filters.push_back(std::move(sub_filter));
_all_columns.insert(column);
}
@@ -561,8 +561,8 @@ void TableStateHistory::answerQuery(Query *query) {
entry->_kind == LogEntryKind::state_host ||
entry->_kind == LogEntryKind::downtime_alert_host) {
if (state_changed != 0) {
for (auto &_service : state->_services) {
updateHostServiceState(query, entry, _service,
for (auto &svc : state->_services) {
updateHostServiceState(query, entry, svc,
only_update);
}
}
@@ -30,7 +30,7 @@
#include "RegExp.h"

namespace {
std::unordered_map<std::string, RelationalOperator> fromString = {
std::unordered_map<std::string, RelationalOperator> fl_from_string = {
{"=", RelationalOperator::equal},
{"!=", RelationalOperator::not_equal},
{"~", RelationalOperator::matches},
@@ -53,14 +53,14 @@ std::ostream &operator<<(std::ostream &os, const RelationalOperator &relOp) {
// Slightly inefficient, but this doesn't matter for our purposes. We could
// use Boost.Bimap or use 2 maps if really necessary.
auto it =
std::find_if(fromString.cbegin(), fromString.cend(),
std::find_if(fl_from_string.cbegin(), fl_from_string.cend(),
[&](auto &strAndOp) { return strAndOp.second == relOp; });
return it == fromString.cend() ? os : (os << it->first);
return it == fl_from_string.cend() ? os : (os << it->first);
}

RelationalOperator relationalOperatorForName(const std::string &name) {
auto it = fromString.find(name);
if (it == fromString.end()) {
auto it = fl_from_string.find(name);
if (it == fl_from_string.end()) {
throw std::runtime_error("invalid operator '" + name + "'");
}
return it->second;

0 comments on commit 6d20764

Please sign in to comment.
You can’t perform that action at this time.