Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
0b566672
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
0b566672
编写于
9月 13, 2020
作者:
S
storypku
提交者:
Chang Songhong
9月 14, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
apollo.sh: apollo.sh lint --help support
上级
85874a85
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
71 addition
and
51 deletion
+71
-51
apollo.sh
apollo.sh
+1
-2
docs/specs/linters_and_formatters.md
docs/specs/linters_and_formatters.md
+14
-14
scripts/apollo_lint.sh
scripts/apollo_lint.sh
+56
-35
未找到文件。
apollo.sh
浏览文件 @
0b566672
...
...
@@ -195,8 +195,7 @@ function main() {
env
${
APOLLO_ENV
}
bash
"
${
APOLLO_ROOT_DIR
}
/scripts/apollo_buildify.sh"
;;
lint
)
# FIXME(all): apollo_lint.sh "$@" when bash/python scripts are ready.
env
${
APOLLO_ENV
}
bash
"
${
APOLLO_ROOT_DIR
}
/scripts/apollo_lint.sh"
cpp
env
${
APOLLO_ENV
}
bash
"
${
APOLLO_ROOT_DIR
}
/scripts/apollo_lint.sh"
"
$@
"
;;
clean
)
env
${
APOLLO_ENV
}
bash
"
${
APOLLO_ROOT_DIR
}
/scripts/apollo_clean.sh"
"
$@
"
...
...
docs/specs/linters_and_formatters.md
浏览文件 @
0b566672
...
...
@@ -40,10 +40,10 @@ are provided for developers to check style issues.
> near future.
| Linters | Source Extensions | Apollo Command Used |
| :--------: | :-----------------------------------: | :------------------------
-
|
| cpplint | .h/.c/.hpp/.cpp/.hh/.cc/.hxx/.cxx/.cu |
scripts/apollo_lint.sh
cpp |
| flake8 | .py |
scripts/apollo_lint.sh
py |
| shellcheck | .sh/.bash/.bashrc |
scripts/apollo_lint.sh
sh |
| :--------: | :-----------------------------------: | :------------------------ |
| cpplint | .h/.c/.hpp/.cpp/.hh/.cc/.hxx/.cxx/.cu |
bash apollo.sh lint --
cpp |
| flake8 | .py |
bash apollo.sh lint --
py |
| shellcheck | .sh/.bash/.bashrc |
bash apollo.sh lint --
sh |
To make sure your code conforms to Apollo coding style, you can use
`./apollo.sh lint`
to find any possible style problems and fix them manually.
...
...
@@ -57,9 +57,9 @@ avoid common mistakes when writing code.
The following table lists the formatters currently integrated into Apollo,
covering C/C++, Python, Bash, Bazel, Markdown, JSON and YAML files.
| Formatters |
Source Extension
| Apollo Command Used | Formatter Config |
| :----------: | :------------------------------------: | :----------------------------------------------: | :--------------: |
| clang-format | .h/.c/.hpp/.cpp/.hh/.cc/.hxx/.cxx
;/.cu
| ./apollo.sh format -c
<path
/
to
/
src
/
dir
/
or
/
files
>
| .clang-format |
| Formatters |
Source Extensions
| Apollo Command Used | Formatter Config |
| :----------: | :------------------------------------
------
: | :----------------------------------------------: | :--------------: |
| clang-format | .h/.c/.hpp/.cpp/.hh/.cc/.hxx/.cxx
/.cu/.proto
| ./apollo.sh format -c
<path
/
to
/
src
/
dir
/
or
/
files
>
| .clang-format |
| autopep8 | .py | ./apollo.sh format -p
<path
/
to
/
src
/
dir
/
or
/
files
>
| tox.ini |
| buildifier | .BUILD/.bzl/.bazel/WORKSPACE/BUILD | ./apollo.sh format -b
<path
/
to
/
src
/
dir
/
or
/
files
>
| N/A |
| shfmt | .sh/.bash/.bashrc | ./apollo.sh format -s
<path
/
to
/
src
/
dir
/
or
/
files
>
| .editorconfig |
...
...
@@ -82,8 +82,8 @@ which will auto-format Bazel `WORKSPACE` file under `$APOLLO_ROOT_DIR`,
Note:
> `./apollo.sh format` can also work outside Docker if relavant tools
>
installed
properly.
> `./apollo.sh format` can also work outside Docker if relavant tools
installed
> properly.
## Conclusion
...
...
scripts/apollo_lint.sh
浏览文件 @
0b566672
...
...
@@ -24,17 +24,20 @@ source "${TOP_DIR}/scripts/apollo.bashrc"
:
${
STAGE
:
=dev
}
PYTHON_LINT_FLAG
=
0
CPP_LINT_FLAG
=
0
SHELL_LINT_FLAG
=
0
function
_cpp_lint_impl
()
{
bazel
test
--config
=
cpplint
"
$@
"
}
function
run_cpp_lint
()
{
pushd
"
${
APOLLO_ROOT_DIR
}
"
>
/dev/null
pushd
"
${
APOLLO_ROOT_DIR
}
"
>
/dev/null
local
cpp_dirs
=
"cyber"
if
[[
"
${
STAGE
}
"
==
"dev"
]]
;
then
cpp_dirs
=
"
${
cpp_dirs
}
modules"
fi
# -not \( -path "modules/drivers/gnss/third_party" -prune \) \
for
prey
in
$(
find
${
cpp_dirs
}
-name
BUILD
\
| xargs
grep
-l
-E
'cc_library|cc_test|cc_binary|cuda_library'
\
| xargs
grep
-L
'cpplint()'
)
;
do
...
...
@@ -47,7 +50,7 @@ function run_cpp_lint() {
${
buidifier
}
-lint
=
fix
"
${
prey
}
"
fi
done
popd
>
/dev/null
popd
>
/dev/null
local
targets
=
"//cyber/..."
_cpp_lint_impl
"
${
targets
}
"
...
...
@@ -104,44 +107,62 @@ function run_py_lint() {
function
print_usage
()
{
info
"Usage:
$0
[Options]"
info
"Options:"
info
"
${
TAB
}
--py Lint Python files"
info
"
${
TAB
}
--sh Lint Bash scripts"
info
"
${
TAB
}
--cpp Lint cpp source files"
info
"
${
TAB
}
-a|--all Lint all. Equivalent to
\"
--py --sh --cpp
\"
"
info
"
${
TAB
}
-h|--help Show this message and exit"
info
"
${
TAB
}
py|python Lint Python code"
info
"
${
TAB
}
sh|shell Lint Bash code"
info
"
${
TAB
}
cpp Lint cpp code"
info
"
${
TAB
}
all Lint all (C++/Python/Bash)"
info
"
${
TAB
}
help Same as '--help'"
}
function
run_lint
()
{
local
cmd
=
"
$1
"
case
"
${
cmd
}
"
in
py
|
python
)
run_py_lint
function
parse_cmdline_args
()
{
if
[[
"$#"
-eq
0
]]
;
then
CPP_LINT_FLAG
=
1
return
0
fi
while
[[
"$#"
-gt
0
]]
;
do
local
opt
=
"
$1
"
shift
case
"
${
opt
}
"
in
--py
)
PYTHON_LINT_FLAG
=
1
;;
cpp
)
run_cpp_lint
--
cpp
)
CPP_LINT_FLAG
=
1
;;
sh
|
shell
)
run_sh_lint
--sh
)
SHELL_LINT_FLAG
=
1
;;
all
)
run_cpp_lint
run_py_lint
run_sh_lint
-a
|
--
all
)
PYTHON_LINT_FLAG
=
1
CPP_LINT_FLAG
=
1
SHELL_LINT_FLAG
=
1
;;
help
)
-h
|
--
help
)
print_usage
exit
0
;;
*
)
warning
"Unknown option:
${
opt
}
"
print_usage
exit
1
;;
esac
done
}
function
main
()
{
run_lint
"
$@
"
parse_cmdline_args
"
$@
"
if
[[
"
${
CPP_LINT_FLAG
}
"
]]
;
then
run_cpp_lint
fi
if
[[
"
${
PYTHON_LINT_FLAG
}
"
-eq
1
]]
;
then
run_py_lint
fi
if
[[
"
${
SHELL_LINT_FLAG
}
"
-eq
1
]]
;
then
run_sh_lint
fi
}
main
"
$@
"
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录