Skip to content

Commit

Permalink
[planning] Opt-in to clang-format lint (#18701)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwnimmer-tri authored Feb 14, 2023
1 parent 4582a13 commit f062738
Show file tree
Hide file tree
Showing 22 changed files with 299 additions and 350 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ DerivePointerAlignment: false
PointerAlignment: Left

# Compress functions onto a single line (when they fit) iff they are defined
# inline (inside a of class).
AllowShortFunctionsOnASingleLine: InlineOnly
# inline (inside a of class) or are empty.
AllowShortFunctionsOnASingleLine: Inline

# Compress lambdas onto a single line iff they are empty.
AllowShortLambdasOnASingleLine: Empty
Expand Down
10 changes: 2 additions & 8 deletions bindings/pydrake/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ DerivePointerAlignment: false
PointerAlignment: Left

# Compress functions onto a single line (when they fit) iff they are defined
# inline (inside a of class).
AllowShortFunctionsOnASingleLine: InlineOnly
# inline (inside a of class) or are empty.
AllowShortFunctionsOnASingleLine: Inline

# Compress lambdas onto a single line iff they are empty.
AllowShortLambdasOnASingleLine: Empty
Expand Down Expand Up @@ -59,11 +59,5 @@ IncludeCategories:
# Avoid widening out code horizontally a lot.
AlignAfterOpenBracket: DontAlign

# Try to fit onto a single line:
# - functions with an empty body, or
# - member functions defined inside a class;
# everything else (e.g., free functions) are forced onto multiple lines.
AllowShortFunctionsOnASingleLine: Inline

# Compress lambdas as much as possible.
AllowShortLambdasOnASingleLine: All
6 changes: 2 additions & 4 deletions lcm/drake_lcm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,10 @@ class DrakeLcm::Impl {
std::string handle_subscriptions_error_message_;
};

DrakeLcm::DrakeLcm() : DrakeLcm(std::string{}) {
}
DrakeLcm::DrakeLcm() : DrakeLcm(std::string{}) {}

DrakeLcm::DrakeLcm(std::string lcm_url)
: DrakeLcm(DrakeLcmParams{.lcm_url = std::move(lcm_url)}) {
}
: DrakeLcm(DrakeLcmParams{.lcm_url = std::move(lcm_url)}) {}

DrakeLcm::DrakeLcm(const DrakeLcmParams& params)
: impl_(std::make_unique<Impl>(params)) {
Expand Down
2 changes: 1 addition & 1 deletion planning/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,4 @@ drake_cc_googletest(
],
)

add_lint_tests()
add_lint_tests(enable_clang_format_lint = True)
12 changes: 5 additions & 7 deletions planning/body_shape_description.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
namespace drake {
namespace planning {

BodyShapeDescription::BodyShapeDescription(
const geometry::Shape& shape,
const math::RigidTransformd& X_BS,
std::string model_instance_name,
std::string body_name)
BodyShapeDescription::BodyShapeDescription(const geometry::Shape& shape,
const math::RigidTransformd& X_BS,
std::string model_instance_name,
std::string body_name)
: shape_(shape.Clone()),
X_BS_(X_BS),
model_instance_name_(std::move(model_instance_name)),
Expand All @@ -37,8 +36,7 @@ BodyShapeDescription MakeBodyShapeDescription(
const auto frame_id = inspector.GetFrameId(geometry_id);
// inspector gives us the shape's pose w.r.t. the parent geometry frame F. We
// rely on MbP registering the geometry frame F to the body B as X_BF = I.
const math::RigidTransformd& X_BS =
inspector.GetPoseInFrame(geometry_id);
const math::RigidTransformd& X_BS = inspector.GetPoseInFrame(geometry_id);
const auto body = plant.GetBodyFromFrameId(frame_id);
DRAKE_DEMAND(body != nullptr);
const std::string& model_instance_name =
Expand Down
Loading

0 comments on commit f062738

Please sign in to comment.