SSL-Roots / consai2r2

https://github.com/SSL-Roots/consai_ros2 へ開発を移行しています。
MIT License
8 stars 7 forks source link

lintを通すために各ファイルのフォーマットを整える #24

Closed ShotaAk closed 4 years ago

ShotaAk commented 4 years ago

CIにlintを取り入れる予定です。 コード量が増える前に対策したい。

ShotaAk commented 4 years ago

ament_copyrightを通すため、ソースファイルのヘッダにMITライセンスの条文を書き加える。

文章のテンプレートは下記を参照。

https://github.com/ament/ament_lint/blob/master/ament_copyright/ament_copyright/template/mit_header.txt

ShotaAk commented 4 years ago

23 でsim_sender.cppのフォーマットを整えてもらってるので、マージするまで待機

ShotaAk commented 4 years ago

コンフリクトを防ぐため、lint対策するときはissueを立てる。

MiraiHattori commented 4 years ago

こちらについて,protobufについてlintがうまくいく時といかない時があるようです.

senderではgrSim_Packet.protoのように大文字やアンダーバーを含んだものになっていて,変換後にもgrSim_Packet.pb.hのように大文字となっています. 一方,receiverではreferee.protoのように小文字のみとなっていて,変換後にもreferee.pb.hとなっています.

これらのheaderをincludeすると,colcon testで前者は通るが後者は通りません. 後者は

Include the directory when naming .h files

というエラーが出ており,どうやら

#include "(何らかのディレクトリ)/referee.pb.h"

とする必要がありそうですが,protobufは何かのディレクトリの下にpb.hを出力する仕様ではないため,エラーを消すことができなさそうです.

MiraiHattori commented 4 years ago

今のところ思いついている解決策は2つあって,

#include "./referee.pb.h"

とする referee.protoをSSL_Referee.protoにrenameする といった感じです.

MiraiHattori commented 4 years ago

https://stackoverflow.com/questions/26147454/how-to-automatically-move-pb-h-and-pb-h-under-include-and-src-directories これの一番下のコメントを参考にして,protoディレクトリにCMakeLists.txtを足して,add_subdirectoryを呼ぶのもありかもしれません.

MiraiHattori commented 4 years ago

一旦"./referee.pb.h"のようにすることで,現在あるPull Requestのcolcon testを(多分)(あと8分程度で確定する)すべて通しました. https://github.com/SSL-Roots/consai2r2/pull/34 https://github.com/SSL-Roots/consai2r2/pull/35

ShotaAk commented 4 years ago

そういう問題があるんですね。

今回はディレクトリをきれいに保つため、*.pb.hをprotoディレクトリに生成しないようにしてました。

consai2ではadd_subdirectory使ってました。 https://github.com/SSL-Roots/consai2/blob/master/consai2_sender/scripts/proto/CMakeLists.txt

ShotaAk commented 4 years ago

最終的にどうするか、考え中(保留)

ShotaAk commented 4 years ago

issueが抽象的なことと、lintが通ったことにより、本件closeします。 protoをどうするかは他のPRやissueで議論する(議論済み)