Skip to content

[clang-tidy] Check request: readability-use-format #139152

@denzor200

Description

@denzor200

Needs a check that will find a long concatenation chain and will suggest to use std::format instead.

BEFORE:

std::string message = "Hi " + name + "! You are " + std::to_string(age) +
                      " years old and your height is " +
                      std::to_string(static_cast<int>(std::floor(height))) +
                      "." + std::to_string(static_cast<int>(100 * (height - std::floor(height)))) + " m.";

AFTER:

std::string message = std::format(
        "Hi {}! You are {} years old and your height is {}.{} m.", 
        name, age, static_cast<int>(std::floor(height)),
        static_cast<int>(100 * (height - std::floor(height)))
    );

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-tidyenhancementImproving things as opposed to bug fixing, e.g. new or missing feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions