Skip to content

Commit 6f97ce4

Browse files
committed
Update .clang-format to regroup includes correctly and reformat tested files
Configure IncludeBlocks: Regroup and organize IncludeCategories into: 1. C/POSIX system headers 2. C++ standard library headers 3. Third-party library headers (explicitly matching <zip.h> and preserving external library headers written with angle brackets) 4. Project headers (cuttlefish/, allocd/, and external_proto/) Apply clang-format specifically to all source files verified by format_test_srcs targets. Assisted-by: Jetski:Gemini Next Bug: b/512215781
1 parent cf7634d commit 6f97ce4

139 files changed

Lines changed: 247 additions & 220 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,15 @@
1919
# of the below options.
2020

2121
BasedOnStyle: Google
22-
IncludeBlocks: Preserve
22+
IncludeBlocks: Regroup
23+
IncludeCategories:
24+
- Regex: '^[<"](cuttlefish|allocd|external_proto)/'
25+
Priority: 4
26+
- Regex: '^<(zip|zlib|png|lz4|archive|tinyxml2|pcre2)\.h>'
27+
Priority: 3
28+
- Regex: '^<([^/]*|(sys|linux|netinet|arpa|asm|net|gnu)/.*)\.h>'
29+
Priority: 1
30+
- Regex: '^<[a-z_]*>'
31+
Priority: 2
32+
- Regex: '.*'
33+
Priority: 3

base/cvd/cuttlefish/common/libs/fs/shared_fd_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616

1717
#include "cuttlefish/common/libs/fs/shared_fd.h"
1818

19-
#include <gtest/gtest.h>
2019
#include <unistd.h>
2120

21+
#include <gtest/gtest.h>
22+
2223
namespace cuttlefish {
2324

2425
char pipe_message[] = "Testing the pipe";

base/cvd/cuttlefish/common/libs/utils/environment_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include <string>
2121
#include <string_view>
2222

23-
#include <gtest/gtest.h>
2423
#include "absl/cleanup/cleanup.h"
24+
#include <gtest/gtest.h>
2525

2626
namespace cuttlefish {
2727

base/cvd/cuttlefish/common/libs/utils/files_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
#include <fstream>
1919
#include <string>
2020

21+
#include "absl/cleanup/cleanup.h"
22+
#include "absl/strings/str_cat.h"
2123
#include <android-base/file.h>
2224
#include <gmock/gmock.h>
2325
#include <gtest/gtest.h>
24-
#include "absl/cleanup/cleanup.h"
25-
#include "absl/strings/str_cat.h"
2626

2727
#include "cuttlefish/result/result.h"
2828
#include "cuttlefish/result/result_matchers.h"

base/cvd/cuttlefish/common/libs/utils/flags_validator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
#include <string>
18-
1917
#include "cuttlefish/common/libs/utils/flags_validator.h"
2018

19+
#include <string>
20+
2121
namespace cuttlefish {
2222
Result<void> ValidateSetupWizardMode(const std::string& setupwizard_mode) {
2323
// One of DISABLED,OPTIONAL,REQUIRED

base/cvd/cuttlefish/common/libs/utils/inotify.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@
1414
* limitations under the License.
1515
*/
1616

17+
#include "inotify.h"
18+
1719
#include <limits.h>
1820
#include <string.h>
1921
#include <sys/inotify.h>
2022
#include <unistd.h>
23+
2124
#include <string>
2225
#include <vector>
2326

2427
#include "absl/log/log.h"
2528

26-
#include "inotify.h"
27-
2829
namespace cuttlefish {
2930

3031
std::vector<std::string> GetCreatedFileListFromInotifyFd(int fd) {

base/cvd/cuttlefish/common/libs/utils/json.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16+
#include "cuttlefish/common/libs/utils/json.h"
17+
1618
#include <memory>
1719
#include <string>
1820
#include <string_view>
1921

2022
#include "cuttlefish/common/libs/fs/shared_buf.h"
2123
#include "cuttlefish/common/libs/fs/shared_fd.h"
22-
#include "cuttlefish/common/libs/utils/json.h"
2324

2425
namespace cuttlefish {
2526

base/cvd/cuttlefish/common/libs/utils/known_paths.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
#include "cuttlefish/common/libs/utils/known_paths.h"
1818

19-
#include "cuttlefish/common/libs/utils/environment.h"
20-
2119
#include <string>
2220

21+
#include "cuttlefish/common/libs/utils/environment.h"
22+
2323
namespace cuttlefish {
2424

2525
std::string TempDir() { return StringFromEnv("TMPDIR", "/tmp"); }

base/cvd/cuttlefish/common/libs/utils/network_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16-
#include <gtest/gtest.h>
17-
1816
#include "cuttlefish/common/libs/utils/network.h"
1917

18+
#include <gtest/gtest.h>
19+
2020
namespace cuttlefish {
2121
namespace {
2222

base/cvd/cuttlefish/common/libs/utils/proc_file_utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
#include <unordered_map>
2626
#include <vector>
2727

28-
#include <android-base/file.h>
29-
#include <fmt/core.h>
3028
#include "absl/log/log.h"
3129
#include "absl/strings/ascii.h"
3230
#include "absl/strings/match.h"
3331
#include "absl/strings/numbers.h"
3432
#include "absl/strings/str_split.h"
3533
#include "absl/strings/strip.h"
34+
#include <android-base/file.h>
35+
#include <fmt/core.h>
3636

3737
#include "cuttlefish/common/libs/fs/shared_buf.h"
3838
#include "cuttlefish/common/libs/fs/shared_fd.h"

0 commit comments

Comments
 (0)