Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
a33eaf5f
I
iSulad
项目概览
openeuler
/
iSulad
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
iSulad
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a33eaf5f
编写于
7月 09, 2020
作者:
W
wujing
提交者:
lifeng68
7月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add clang-tidy static check tool && fix some code
Signed-off-by:
N
wujing
<
wujing50@huawei.com
>
上级
3278f512
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
327 addition
and
202 deletion
+327
-202
src/client/connect/grpc/client_base.h
src/client/connect/grpc/client_base.h
+14
-18
src/client/connect/grpc/grpc_containers_client.cc
src/client/connect/grpc/grpc_containers_client.cc
+181
-180
src/client/libisula.h
src/client/libisula.h
+1
-1
tools/static_check
tools/static_check
+131
-3
未找到文件。
src/client/connect/grpc/client_base.h
浏览文件 @
a33eaf5f
...
...
@@ -14,24 +14,20 @@
******************************************************************************/
#ifndef __CLIENT_BASH_H
#define __CLIENT_BASH_H
#include <fstream>
#include <grpc++/grpc++.h>
#include <iostream>
#include <string>
#include <memory>
#include <grpc++/grpc++.h>
#include <sstream>
#include <
fstream
>
#include <
string
>
#include "certificate.h"
#include "connect.h"
#include "error.h"
#include "isula_libutils/log.h"
#include "connect.h"
#include "utils.h"
#include "certificate.h"
using
grpc
::
Channel
;
using
grpc
::
ClientContext
;
using
grpc
::
ClientReader
;
using
grpc
::
ClientReaderWriter
;
using
grpc
::
ClientWriter
;
using
grpc
::
Status
;
namespace
ClientBaseConstants
{
...
...
@@ -99,9 +95,9 @@ public:
response
->
cc
=
ISULAD_ERR_EXEC
;
}
virtual
int
run
(
const
RQ
*
request
,
RP
*
response
)
virtual
auto
run
(
const
RQ
*
request
,
RP
*
response
)
->
int
{
int
ret
;
int
ret
=
0
;
gRQ
req
;
gRP
reply
;
ClientContext
context
;
...
...
@@ -154,24 +150,24 @@ public:
}
protected:
virtual
int
request_to_grpc
(
const
RQ
*
rq
,
gRQ
*
grq
)
virtual
auto
request_to_grpc
(
const
RQ
*
/*rq*/
,
gRQ
*
/*grq*/
)
->
int
{
return
0
;
};
virtual
int
response_from_grpc
(
gRP
*
reply
,
RP
*
response
)
virtual
auto
response_from_grpc
(
gRP
*
/*reply*/
,
RP
*
/*response*/
)
->
int
{
return
0
;
};
virtual
int
check_parameter
(
const
gRQ
&
grq
)
virtual
auto
check_parameter
(
const
gRQ
&
/*grq*/
)
->
int
{
return
0
;
};
virtual
Status
grpc_call
(
ClientContext
*
context
,
const
gRQ
&
req
,
gRP
*
reply
)
virtual
auto
grpc_call
(
ClientContext
*
/*context*/
,
const
gRQ
&
/*req*/
,
gRP
*
/*reply*/
)
->
Status
{
return
Status
::
OK
;
};
std
::
string
ReadTextFile
(
const
char
*
file
)
auto
ReadTextFile
(
const
char
*
file
)
->
std
::
string
{
char
*
real_file
=
verify_file_and_get_real_path
(
file
);
if
(
real_file
==
nullptr
)
{
...
...
@@ -191,7 +187,7 @@ protected:
return
ss
.
str
();
}
int
SetMetadataInfo
(
ClientContext
&
context
)
auto
SetMetadataInfo
(
ClientContext
&
context
)
->
int
{
// Set common name from cert.perm
char
common_name_value
[
ClientBaseConstants
::
COMMON_NAME_LEN
]
=
{
0
};
...
...
@@ -215,7 +211,7 @@ protected:
};
template
<
class
REQUEST
,
class
RESPONSE
,
class
FUNC
>
int
container_func
(
const
REQUEST
*
request
,
RESPONSE
*
response
,
void
*
arg
)
noexcep
t
auto
container_func
(
const
REQUEST
*
request
,
RESPONSE
*
response
,
void
*
arg
)
noexcept
->
in
t
{
if
(
request
==
nullptr
||
response
==
nullptr
||
arg
==
nullptr
)
{
ERROR
(
"Receive NULL args"
);
...
...
src/client/connect/grpc/grpc_containers_client.cc
浏览文件 @
a33eaf5f
此差异已折叠。
点击以展开。
src/client/libisula.h
浏览文件 @
a33eaf5f
...
...
@@ -20,10 +20,10 @@
#include <stdio.h>
#include "constants.h"
#include "io_wrapper.h"
#include "isula_libutils/container_path_stat.h"
#include "isula_libutils/json_common.h"
#include "utils_timestamp.h"
#include "io_wrapper.h"
#ifdef __cplusplus
extern
"C"
{
...
...
tools/static_check
浏览文件 @
a33eaf5f
...
...
@@ -17,8 +17,7 @@
##- @Create: 2019-04-25
#######################################################################
CURRENT_PATH
=
$(
pwd
)
export
EULER_CODE_PATH
=
"
$(
realpath
${
CURRENT_PATH
}
/..
)
"
CURRENT_PATH
=
$(
dirname
$(
readlink
-f
"
$0
"
))
function
usage
()
{
echo
-e
"
\
...
...
@@ -33,6 +32,8 @@ function usage() {
echo
"Personal level build static check script for iSulad project"
echo
"Options:"
echo
" -s, --codestyle Perform codestyle(codedex) code static check"
echo
" -c, --tidy-check Perform clang-tidy code static check"
echo
" -x, --tidy-fix Quick fix code with clang-tidy"
echo
" -a, --all Perform all checks and statistics"
echo
" -i, --incremental-check Perform incremental check"
echo
" -f, --quick-format Incremental format code by astyle/clang-format"
...
...
@@ -332,6 +333,131 @@ function cpp_check() {
fi
}
function
clang_tidy_check
()
{
which clang-tidy
>
/dev/null
if
[[
$?
-ne
0
]]
;
then
echo
"please install clang-tidy tool first"
exit
1
fi
echo
-e
"
\
=================================================================================================
\0
33[1;33m
████████╗██╗██████╗ ██╗ ██╗ ██████╗██╗ ██╗███████╗ ██████╗██╗ ██╗
╚══██╔══╝██║██╔══██╗╚██╗ ██╔╝ ██╔════╝██║ ██║██╔════╝██╔════╝██║ ██╔╝
██║ ██║██║ ██║ ╚████╔╝ ██║ ███████║█████╗ ██║ █████╔╝
██║ ██║██║ ██║ ╚██╔╝ ██║ ██╔══██║██╔══╝ ██║ ██╔═██╗
██║ ██║██████╔╝ ██║ ╚██████╗██║ ██║███████╗╚██████╗██║ ██╗
╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝ ╚═════╝╚═╝ ╚═╝
\0
33[0m
================================================================================================="
local
start_time
=
$(
date
+%s
)
if
[[
!
-f
${
CURRENT_PATH
}
/../compile_commands.json
]]
;
then
echo
"compile_commands.json file not found in project root dirctory, generating..."
mkdir
-p
${
CURRENT_PATH
}
/../build
cd
${
CURRENT_PATH
}
/../build
cmake
-DCMAKE_EXPORT_COMPILE_COMMANDS
=
ON ../
cp
compile_commands.json ../
cd
${
CURRENT_PATH
}
fi
local
files
if
[[
${
1
}
==
"all"
]]
;
then
files
=
$(
find ./src ./test
-regextype
posix-extended
-regex
".*
\.
(h|c|cc)"
)
elif
[[
${
1
}
==
"incremental"
]]
;
then
files
=
$(
git diff
--name-only
HEAD |
grep
-E
"*.h
$|
*.c
$|
*.cc$"
)
elif
[[
-f
"
$1
"
]]
;
then
files
=
"
$1
"
elif
[[
-d
"
$1
"
]]
;
then
files
=
$(
find
"
$1
"
-regextype
posix-extended
-regex
".*
\.
(h|c|cc)"
)
fi
files
=(
${
files
// /
}
)
local
total
=
${#
files
[@]
}
local
index
=
1
logfile
=
${
CURRENT_PATH
}
/../clang-tidy-check.log
echo
""
>
${
logfile
}
if
[[
${
total
}
-eq
1
]]
;
then
clang-tidy
-checks
=
'-*,abseil-*,bugprone-*,cert-*,clang-analyzer-*,cppcoreguidelines-*, \
google-*,hicpp-*,linuxkernel-*,llvm-*,llvmlibc-*,-llvm-header-guard,misc-*,modernize-*,performance-*,portability-*,readability-*'
${
files
[0]
}
return
0
fi
for
file
in
${
files
[@]
}
do
echo
">>>>>>>>>>>>>>>>>>checking:
${
file
}
"
>>
${
logfile
}
clang-tidy
-checks
=
'-*,abseil-*,bugprone-*,cert-*,clang-analyzer-*,cppcoreguidelines-*, \
google-*,hicpp-*,linuxkernel-*,llvm-*,llvmlibc-*,-llvm-header-guard,misc-*,modernize-*,performance-*,portability-*,readability-*'
${
file
}
\
>>
${
logfile
}
2>&1
echo
">>>>>>>>>>>>>>>>>>checked:
${
file
}
"
>>
${
logfile
}
printf
"[
\0
33[1;36m%03d
\0
33[0m
\0
33[1;33m/
\0
33[0m
\0
33[1;34m%03d
\0
33[0m]@%-80s
\0
33[1;32m%-5s
\0
33[0m
\n
"
\
${
index
}
${
total
}
${
file
}
"[CHECKED]"
|
sed
-e
's/ /-/g'
-e
's/@/ /'
-e
's/-/ /'
index
=
$((
index+1
))
done
printf
"%0.s="
{
1..96
}
printf
"
\n
"
local
end_time
=
$(
date
+%s
)
local
duration
=
$((${
end_time
}
-
${
start_time
}))
echo
-e
"
\0
33[1;36mTotal files:
${
total
}
\0
33[0m.
\0
33[1;33mSpend time:
${
duration
}
seconds
\0
33[0m"
echo
-e
"
\0
33[1;31mCode analysis report
${
logfile
}
is in the root directory of the project, please refer to the modification
\0
33[0m"
}
function
clang_tidy_fix
()
{
which clang-tidy
>
/dev/null
if
[[
$?
-ne
0
]]
;
then
echo
"please install clang-tidy tool first"
exit
1
fi
echo
-e
"
\
=================================================================================================
\0
33[1;33m
████████╗██╗██████╗ ██╗ ██╗ ██████╗ ██████╗ ██████╗ ███████╗ ███████╗██╗██╗ ██╗
╚══██╔══╝██║██╔══██╗╚██╗ ██╔╝ ██╔════╝██╔═══██╗██╔══██╗██╔════╝ ██╔════╝██║╚██╗██╔╝
██║ ██║██║ ██║ ╚████╔╝ ██║ ██║ ██║██║ ██║█████╗ █████╗ ██║ ╚███╔╝
██║ ██║██║ ██║ ╚██╔╝ ██║ ██║ ██║██║ ██║██╔══╝ ██╔══╝ ██║ ██╔██╗
██║ ██║██████╔╝ ██║ ╚██████╗╚██████╔╝██████╔╝███████╗ ██║ ██║██╔╝ ██╗
╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═╝╚═╝ ╚═╝
\0
33[0m
================================================================================================="
local
start_time
=
$(
date
+%s
)
if
[[
!
-f
${
CURRENT_PATH
}
/../compile_commands.json
]]
;
then
echo
"compile_commands.json file not found in project root dirctory, generating..."
mkdir
-p
${
CURRENT_PATH
}
/../build
cd
${
CURRENT_PATH
}
/../build
cmake
-DCMAKE_EXPORT_COMPILE_COMMANDS
=
ON ../
cp
compile_commands.json ../
cd
${
CURRENT_PATH
}
fi
local
files
if
[[
${
1
}
==
"all"
]]
;
then
files
=
$(
find ./src ./test
-regextype
posix-extended
-regex
".*
\.
(h|c|cc)"
)
elif
[[
${
1
}
==
"incremental"
]]
;
then
files
=
$(
git diff
--name-only
HEAD |
grep
-E
"*.h
$|
*.c
$|
*.cc$"
)
elif
[[
-f
"
$1
"
]]
;
then
files
=
"
$1
"
elif
[[
-d
"
$1
"
]]
;
then
files
=
$(
find
"
$1
"
-regextype
posix-extended
-regex
".*
\.
(h|c|cc)"
)
fi
files
=(
${
files
// /
}
)
local
total
=
${#
files
[@]
}
local
index
=
1
if
[[
${
total
}
-eq
1
]]
;
then
clang-tidy
-checks
=
'-*,abseil-*,bugprone-*,cert-*,clang-analyzer-*,cppcoreguidelines-*, \
google-*,hicpp-*,linuxkernel-*,llvm-*,llvmlibc-*,-llvm-header-guard,misc-*,modernize-*,performance-*,portability-*,readability-*'
--fix
${
files
[0]
}
return
0
fi
for
file
in
${
files
[@]
}
do
clang-tidy
-checks
=
'-*,abseil-*,bugprone-*,cert-*,clang-analyzer-*,cppcoreguidelines-*, \
google-*,hicpp-*,linuxkernel-*,llvm-*,llvmlibc-*,-llvm-header-guard,misc-*,modernize-*,performance-*,portability-*,readability-*'
--fix
${
file
}
>
/dev/null 2>&1
printf
"[
\0
33[1;36m%03d
\0
33[0m
\0
33[1;33m/
\0
33[0m
\0
33[1;34m%03d
\0
33[0m]@%-80s
\0
33[1;32m%-5s
\0
33[0m
\n
"
\
${
index
}
${
total
}
${
file
}
"[REPAIRED]"
|
sed
-e
's/ /-/g'
-e
's/@/ /'
-e
's/-/ /'
index
=
$((
index+1
))
done
printf
"%0.s="
{
1..96
}
printf
"
\n
"
local
end_time
=
$(
date
+%s
)
local
duration
=
$((${
end_time
}
-
${
start_time
}))
echo
-e
"
\0
33[1;36mTotal files:
${
total
}
\0
33[0m.
\0
33[1;33mSpend time:
${
duration
}
seconds
\0
33[0m"
echo
-e
"
\0
33[1;31mThe code is repaired, please recompile and check
\0
33[0m"
}
function
incremental_check
()
{
style_check
"incremental"
if
[[
$?
-ne
0
]]
;
then
...
...
@@ -362,13 +488,15 @@ function static_check_all() {
fi
}
args
=
`
getopt
-o
s
iaf:kh
--long
codestyle
,incremental-check,all,quick-format:,style-check,cpp-check,help
--
"
$@
"
`
args
=
`
getopt
-o
s
c:x:iaf:kh
--long
codestyle,tidy-check:,tidy-fix:
,incremental-check,all,quick-format:,style-check,cpp-check,help
--
"
$@
"
`
if
[
$?
!=
0
]
;
then
echo
"Terminating..."
>
&2
;
exit
1
;
fi
eval set
--
"
$args
"
while
true
;
do
case
"
$1
"
in
-s
|
--codestyle
)
codestyle_check
"all"
||
(
err
"failed to perfrom codestyle(codedex) code static check"
&&
exit
-1
)
;
shift
;;
-c
|
--tidy-check
)
clang_tidy_check
"
$2
"
||
(
err
"failed to perform clang-tidy code static check"
&&
exit
-1
)
;
shift
2
;;
-x
|
--tidy-fix
)
clang_tidy_fix
"
$2
"
||
(
err
"failed to quick fix code with clang-tidy"
&&
exit
-1
)
;
shift
2
;;
-i
|
--incremental-check
)
incremental_check
||
(
err
"failed to perform incremental check"
&&
exit
-1
)
;
shift
;;
-a
|
--all
)
static_check_all
||
(
err
"failed to perform all checks and statistics"
&&
exit
-1
)
;
shift
;;
-f
|
--quick-format
)
quick_format
$2
||
(
err
"failed to format code"
&&
exit
-1
)
;
shift
2
;;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录