mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 00:18:11 +01:00
Use Clang 11 (#1846)
This commit is contained in:
parent
4711f36a1f
commit
13fe9e83fa
7 changed files with 74 additions and 32 deletions
40
.clang-tidy
40
.clang-tidy
|
@ -4,14 +4,37 @@ Checks: >-
|
||||||
-abseil-*,
|
-abseil-*,
|
||||||
-android-*,
|
-android-*,
|
||||||
-boost-*,
|
-boost-*,
|
||||||
|
-bugprone-branch-clone,
|
||||||
-bugprone-macro-parentheses,
|
-bugprone-macro-parentheses,
|
||||||
|
-bugprone-narrowing-conversions,
|
||||||
|
-bugprone-reserved-identifier,
|
||||||
|
-bugprone-signed-char-misuse,
|
||||||
|
-bugprone-suspicious-include,
|
||||||
|
-bugprone-too-small-loop-variable,
|
||||||
|
-bugprone-unhandled-self-assignment,
|
||||||
|
-cert-dcl37-c,
|
||||||
-cert-dcl50-cpp,
|
-cert-dcl50-cpp,
|
||||||
|
-cert-dcl51-cpp,
|
||||||
-cert-err58-cpp,
|
-cert-err58-cpp,
|
||||||
|
-cert-oop54-cpp,
|
||||||
|
-cert-oop57-cpp,
|
||||||
|
-cert-str34-c,
|
||||||
-clang-analyzer-core.CallAndMessage,
|
-clang-analyzer-core.CallAndMessage,
|
||||||
|
-clang-analyzer-deadcode.DeadStores,
|
||||||
|
-clang-analyzer-optin.*,
|
||||||
-clang-analyzer-osx.*,
|
-clang-analyzer-osx.*,
|
||||||
-clang-analyzer-security.*,
|
-clang-analyzer-security.*,
|
||||||
|
-clang-diagnostic-fortify-source,
|
||||||
|
-clang-diagnostic-shadow-field,
|
||||||
|
-cppcoreguidelines-avoid-c-arrays,
|
||||||
-cppcoreguidelines-avoid-goto,
|
-cppcoreguidelines-avoid-goto,
|
||||||
|
-cppcoreguidelines-avoid-magic-numbers,
|
||||||
|
-cppcoreguidelines-avoid-non-const-global-variables,
|
||||||
-cppcoreguidelines-c-copy-assignment-signature,
|
-cppcoreguidelines-c-copy-assignment-signature,
|
||||||
|
-cppcoreguidelines-init-variables,
|
||||||
|
-cppcoreguidelines-macro-usage,
|
||||||
|
-cppcoreguidelines-narrowing-conversions,
|
||||||
|
-cppcoreguidelines-non-private-member-variables-in-classes,
|
||||||
-cppcoreguidelines-owning-memory,
|
-cppcoreguidelines-owning-memory,
|
||||||
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||||
-cppcoreguidelines-pro-bounds-constant-array-index,
|
-cppcoreguidelines-pro-bounds-constant-array-index,
|
||||||
|
@ -37,10 +60,16 @@ Checks: >-
|
||||||
-google-runtime-int,
|
-google-runtime-int,
|
||||||
-google-runtime-references,
|
-google-runtime-references,
|
||||||
-hicpp-*,
|
-hicpp-*,
|
||||||
|
-llvm-else-after-return,
|
||||||
-llvm-header-guard,
|
-llvm-header-guard,
|
||||||
-llvm-include-order,
|
-llvm-include-order,
|
||||||
|
-llvm-qualified-auto,
|
||||||
|
-llvmlibc-*,
|
||||||
|
-misc-non-private-member-variables-in-classes,
|
||||||
|
-misc-no-recursion,
|
||||||
-misc-unconventional-assign-operator,
|
-misc-unconventional-assign-operator,
|
||||||
-misc-unused-parameters,
|
-misc-unused-parameters,
|
||||||
|
-modernize-avoid-c-arrays,
|
||||||
-modernize-deprecated-headers,
|
-modernize-deprecated-headers,
|
||||||
-modernize-pass-by-value,
|
-modernize-pass-by-value,
|
||||||
-modernize-pass-by-value,
|
-modernize-pass-by-value,
|
||||||
|
@ -48,14 +77,25 @@ Checks: >-
|
||||||
-modernize-use-auto,
|
-modernize-use-auto,
|
||||||
-modernize-use-default-member-init,
|
-modernize-use-default-member-init,
|
||||||
-modernize-use-equals-default,
|
-modernize-use-equals-default,
|
||||||
|
-modernize-use-trailing-return-type,
|
||||||
-mpi-*,
|
-mpi-*,
|
||||||
-objc-*,
|
-objc-*,
|
||||||
-performance-unnecessary-value-param,
|
-performance-unnecessary-value-param,
|
||||||
-readability-braces-around-statements,
|
-readability-braces-around-statements,
|
||||||
|
-readability-const-return-type,
|
||||||
|
-readability-convert-member-functions-to-static,
|
||||||
-readability-else-after-return,
|
-readability-else-after-return,
|
||||||
-readability-implicit-bool-conversion,
|
-readability-implicit-bool-conversion,
|
||||||
|
-readability-isolate-declaration,
|
||||||
|
-readability-magic-numbers,
|
||||||
|
-readability-make-member-function-const,
|
||||||
-readability-named-parameter,
|
-readability-named-parameter,
|
||||||
|
-readability-qualified-auto,
|
||||||
|
-readability-redundant-access-specifiers,
|
||||||
-readability-redundant-member-init,
|
-readability-redundant-member-init,
|
||||||
|
-readability-redundant-string-init,
|
||||||
|
-readability-uppercase-literal-suffix,
|
||||||
|
-readability-use-anyofallof,
|
||||||
-warnings-as-errors,
|
-warnings-as-errors,
|
||||||
-zircon-*
|
-zircon-*
|
||||||
WarningsAsErrors: '*'
|
WarningsAsErrors: '*'
|
||||||
|
|
|
@ -565,7 +565,8 @@ MQTTMessageTrigger::MQTTMessageTrigger(const std::string &topic) : topic_(topic)
|
||||||
void MQTTMessageTrigger::set_qos(uint8_t qos) { this->qos_ = qos; }
|
void MQTTMessageTrigger::set_qos(uint8_t qos) { this->qos_ = qos; }
|
||||||
void MQTTMessageTrigger::set_payload(const std::string &payload) { this->payload_ = payload; }
|
void MQTTMessageTrigger::set_payload(const std::string &payload) { this->payload_ = payload; }
|
||||||
void MQTTMessageTrigger::setup() {
|
void MQTTMessageTrigger::setup() {
|
||||||
global_mqtt_client->subscribe(this->topic_,
|
global_mqtt_client->subscribe(
|
||||||
|
this->topic_,
|
||||||
[this](const std::string &topic, const std::string &payload) {
|
[this](const std::string &topic, const std::string &payload) {
|
||||||
if (this->payload_.has_value() && payload != *this->payload_) {
|
if (this->payload_.has_value() && payload != *this->payload_) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -7,7 +7,8 @@ namespace mqtt_subscribe {
|
||||||
static const char *TAG = "mqtt_subscribe.sensor";
|
static const char *TAG = "mqtt_subscribe.sensor";
|
||||||
|
|
||||||
void MQTTSubscribeSensor::setup() {
|
void MQTTSubscribeSensor::setup() {
|
||||||
mqtt::global_mqtt_client->subscribe(this->topic_,
|
mqtt::global_mqtt_client->subscribe(
|
||||||
|
this->topic_,
|
||||||
[this](const std::string &topic, std::string payload) {
|
[this](const std::string &topic, std::string payload) {
|
||||||
auto val = parse_float(payload);
|
auto val = parse_float(payload);
|
||||||
if (!val.has_value()) {
|
if (!val.has_value()) {
|
||||||
|
|
|
@ -7,8 +7,8 @@ namespace mqtt_subscribe {
|
||||||
static const char *TAG = "mqtt_subscribe.text_sensor";
|
static const char *TAG = "mqtt_subscribe.text_sensor";
|
||||||
|
|
||||||
void MQTTSubscribeTextSensor::setup() {
|
void MQTTSubscribeTextSensor::setup() {
|
||||||
this->parent_->subscribe(this->topic_,
|
this->parent_->subscribe(
|
||||||
[this](const std::string &topic, std::string payload) { this->publish_state(payload); },
|
this->topic_, [this](const std::string &topic, std::string payload) { this->publish_state(payload); },
|
||||||
this->qos_);
|
this->qos_);
|
||||||
}
|
}
|
||||||
float MQTTSubscribeTextSensor::get_setup_priority() const { return setup_priority::AFTER_CONNECTION; }
|
float MQTTSubscribeTextSensor::get_setup_priority() const { return setup_priority::AFTER_CONNECTION; }
|
||||||
|
|
|
@ -95,7 +95,7 @@ float clamp(float val, float min, float max);
|
||||||
float lerp(float completion, float start, float end);
|
float lerp(float completion, float start, float end);
|
||||||
|
|
||||||
/// std::make_unique
|
/// std::make_unique
|
||||||
template<typename T, typename... Args> std::unique_ptr<T> make_unique(Args &&... args) {
|
template<typename T, typename... Args> std::unique_ptr<T> make_unique(Args &&...args) {
|
||||||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ def run_format(args, queue, lock):
|
||||||
"""Takes filenames out of queue and runs clang-tidy on them."""
|
"""Takes filenames out of queue and runs clang-tidy on them."""
|
||||||
while True:
|
while True:
|
||||||
path = queue.get()
|
path = queue.get()
|
||||||
invocation = ['clang-format-7']
|
invocation = ['clang-format-11']
|
||||||
if args.inplace:
|
if args.inplace:
|
||||||
invocation.append('-i')
|
invocation.append('-i')
|
||||||
invocation.append(path)
|
invocation.append(path)
|
||||||
|
@ -69,12 +69,12 @@ def main():
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
get_output('clang-format-7', '-version')
|
get_output('clang-format-11', '-version')
|
||||||
except:
|
except:
|
||||||
print("""
|
print("""
|
||||||
Oops. It looks like clang-format is not installed.
|
Oops. It looks like clang-format is not installed.
|
||||||
|
|
||||||
Please check you can run "clang-format-7 -version" in your terminal and install
|
Please check you can run "clang-format-11 -version" in your terminal and install
|
||||||
clang-format (v7) if necessary.
|
clang-format (v7) if necessary.
|
||||||
|
|
||||||
Note you can also upload your code as a pull request on GitHub and see the CI check
|
Note you can also upload your code as a pull request on GitHub and see the CI check
|
||||||
|
|
|
@ -30,7 +30,7 @@ else:
|
||||||
def run_tidy(args, tmpdir, queue, lock, failed_files):
|
def run_tidy(args, tmpdir, queue, lock, failed_files):
|
||||||
while True:
|
while True:
|
||||||
path = queue.get()
|
path = queue.get()
|
||||||
invocation = ['clang-tidy-7', '-header-filter=^{}/.*'.format(re.escape(basepath))]
|
invocation = ['clang-tidy-11', '-header-filter=^{}/.*'.format(re.escape(basepath))]
|
||||||
if tmpdir is not None:
|
if tmpdir is not None:
|
||||||
invocation.append('-export-fixes')
|
invocation.append('-export-fixes')
|
||||||
# Get a temporary file. We immediately close the handle so clang-tidy can
|
# Get a temporary file. We immediately close the handle so clang-tidy can
|
||||||
|
@ -90,13 +90,13 @@ def main():
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
get_output('clang-tidy-7', '-version')
|
get_output('clang-tidy-11', '-version')
|
||||||
except:
|
except:
|
||||||
print("""
|
print("""
|
||||||
Oops. It looks like clang-tidy is not installed.
|
Oops. It looks like clang-tidy-11 is not installed.
|
||||||
|
|
||||||
Please check you can run "clang-tidy-7 -version" in your terminal and install
|
Please check you can run "clang-tidy-11 -version" in your terminal and install
|
||||||
clang-tidy (v7) if necessary.
|
clang-tidy (v11) if necessary.
|
||||||
|
|
||||||
Note you can also upload your code as a pull request on GitHub and see the CI check
|
Note you can also upload your code as a pull request on GitHub and see the CI check
|
||||||
output to apply clang-tidy.
|
output to apply clang-tidy.
|
||||||
|
@ -163,7 +163,7 @@ def main():
|
||||||
if args.fix and failed_files:
|
if args.fix and failed_files:
|
||||||
print('Applying fixes ...')
|
print('Applying fixes ...')
|
||||||
try:
|
try:
|
||||||
subprocess.call(['clang-apply-replacements-7', tmpdir])
|
subprocess.call(['clang-apply-replacements-11', tmpdir])
|
||||||
except:
|
except:
|
||||||
print('Error applying fixes.\n', file=sys.stderr)
|
print('Error applying fixes.\n', file=sys.stderr)
|
||||||
raise
|
raise
|
||||||
|
|
Loading…
Reference in a new issue