Git Product home page Git Product logo

Comments (15)

0x804d8000 avatar 0x804d8000 commented on May 2, 2024

应该比较新的版本都可以,我一般不会专门找某个特定版本。

配置文件指定到flare下面的.clang-format应该就可以,现在是有什么地方格式化的不合预期吗

from flare.

4kangjc avatar 4kangjc commented on May 2, 2024

应该比较新的版本都可以,我一般不会专门找某个特定版本。

配置文件指定到flare下面的.clang-format应该就可以,现在是有什么地方格式化的不合预期吗

clang-format 14和clang-format 15格式化出来的有一点点区别, 我想加一个clang-format check的CI

#include "flare/fiber/fiber_local.h"
#include <atomic>
#include <thread>
#include <vector>
#include "gflags/gflags.h"
#include "gtest/gtest.h"
#include "flare/base/random.h"
#include "flare/fiber/alternatives.h"
#include "flare/fiber/detail/testing.h"
#include "flare/fiber/fiber.h"
#include "flare/fiber/this_fiber.h"

这个头文件的顺序应该不对吧, flare下面的.clang-format头文件好像格式化不了这种形式https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes
这个得我们自己加blank line

from flare.

4kangjc avatar 4kangjc commented on May 2, 2024

image
这种

from flare.

0x804d8000 avatar 0x804d8000 commented on May 2, 2024

这个确实是代码需要修改,应该按照空行分组。分组了之后clang-format应该就没问题了

from flare.

4kangjc avatar 4kangjc commented on May 2, 2024

挺多需要format的, 我用clang-format 15格式化了一下整个项目, proto文件感觉没有必要格式化

from flare.

4kangjc avatar 4kangjc commented on May 2, 2024

这个确实是代码需要修改,应该按照空行分组。分组了之后clang-format应该就没问题了

有没有不需要手动分组的方法:) clang-format承当这个工作

from flare.

4kangjc avatar 4kangjc commented on May 2, 2024

这个确实是代码需要修改,应该按照空行分组。分组了之后clang-format应该就没问题了

有没有不需要手动分组的方法:) clang-format承当这个工作

我尝试过这个, 但对于_benchmark.cc的文件没办法, 而且flare里还有一些.cc_test.cc文件里相关的文件不是他本身的前缀, 也不生效

IncludeBlocks:   Regroup
IncludeCategories:
  - Regex:           '^<.*\.h>'
    Priority:        1
  - Regex:           '^<.*'
    Priority:        2
  - Regex:           '^"(google|gperftools|jemalloc|lz4|snappy|nghttp2|zlib|benchmark|jsoncpp|ctemplate|curl|gflags|fmt|gtest|gmock|glog|yaml-cpp|openssl|opentracing|opentracing-cpp|zstd|rapidxml|xxhash|blake3)/'
    Priority:        3
  - Regex:           '.*'
    Priority:        4

from flare.

0x804d8000 avatar 0x804d8000 commented on May 2, 2024

这个确实是代码需要修改,应该按照空行分组。分组了之后clang-format应该就没问题了

有没有不需要手动分组的方法:) clang-format承当这个工作

不分组的话我理解格式化完了应该跟现在这个写法一样,这个也ok啊。也就是有空行的文件就分组格式化,没空行的先一起排序,也不影响什么,后面修改到了对应的文件在相应的处理这样

from flare.

4kangjc avatar 4kangjc commented on May 2, 2024

这个确实是代码需要修改,应该按照空行分组。分组了之后clang-format应该就没问题了

有没有不需要手动分组的方法:) clang-format承当这个工作

不分组的话我理解格式化完了应该跟现在这个写法一样,这个也ok啊。也就是有空行的文件就分组格式化,没空行的先一起排序,也不影响什么,后面修改到了对应的文件在相应的处理这样

#include "flare/rpc/internal/stream.h"
#include <deque>
#include <utility>
#include <vector>
#include "flare/base/chrono.h"
#include "flare/fiber/latch.h"
#include "flare/fiber/timer.h"
#include "flare/testing/main.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"

clang-format应该检测不到这种情况, 我的意思是git-clang能不能自动格式化成下面这种情况, 而不需要我们自己去分组

#include <utility>
#include <vector>

#include "gmock/gmock.h"
#include "gtest/gtest.h"

#include "flare/base/chrono.h"
#include "flare/fiber/latch.h"
#include "flare/fiber/timer.h"
#include "flare/testing/main.h"

from flare.

0x804d8000 avatar 0x804d8000 commented on May 2, 2024

这个好像我也没听说有什么办法,一直都是手动处理的

from flare.

4kangjc avatar 4kangjc commented on May 2, 2024

这个好像我也没听说有什么办法,一直都是手动处理的

OK

from flare.

4kangjc avatar 4kangjc commented on May 2, 2024

这个好像我也没听说有什么办法,一直都是手动处理的

IncludeIsMainRegex: "(_test|_benchmark)?$"
IncludeBlocks:   Regroup
IncludeCategories:
  - Regex:           '^<.*\.h>'
    Priority:        1
  - Regex:           '^<.*'
    Priority:        2
  - Regex:           '^"(google|gperftools|jemalloc|lz4|snappy|nghttp2|zlib|benchmark|jsoncpp|ctemplate|curl|gflags|fmt|gtest|gmock|glog|yaml-cpp|openssl|opentracing|opentracing-cpp|zstd|rapidxml|xxhash|blake3)/'
    Priority:        3
  - Regex:           '.*'
    Priority:        4

这个能处理flare中绝大多少的了, 极少部分比如上条PR里你提到了flare/base/object_pool/thread_local_test.cc这种才处理不了, 只能这样处理了, 你看可以吗

// clang-format off
#include "flare/base/object_pool.h"
// clang-format on

from flare.

0x804d8000 avatar 0x804d8000 commented on May 2, 2024

Group 3这个写法维护有点麻烦,还是保留PreserveBlocks吧,我感觉本地一次性用Regroup生成对现有代码的修复就可以了

然后clang-format off那些应该可以删掉。

另外我看那个mr有个小问题,好像把example/下面的代码的第一个include搞到其他目录下面的同名.h去了。这个不太对,example下面(除了恰好有.h,应该很少)直接从系统头文件开始比较好。逻辑上来说example下面的看做“外界”代码

from flare.

4kangjc avatar 4kangjc commented on May 2, 2024

Group 3这个写法维护有点麻烦,还是保留PreserveBlocks吧,我感觉本地一次性用Regroup生成对现有代码的修复就可以了

然后clang-format off那些应该可以删掉。

另外我看那个mr有个小问题,好像把example/下面的代码的第一个include搞到其他目录下面的同名.h去了。这个不太对,example下面(除了恰好有.h,应该很少)直接从系统头文件开始比较好。逻辑上来说example下面的看做“外界”代码

OK

from flare.

4kangjc avatar 4kangjc commented on May 2, 2024

Group 3这个写法维护有点麻烦,还是保留PreserveBlocks吧,我感觉本地一次性用Regroup生成对现有代码的修复就可以了

然后clang-format off那些应该可以删掉。

另外我看那个mr有个小问题,好像把example/下面的代码的第一个include搞到其他目录下面的同名.h去了。这个不太对,example下面(除了恰好有.h,应该很少)直接从系统头文件开始比较好。逻辑上来说example下面的看做“外界”代码

我另起一个pr

from flare.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.