Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
m0_67397764
soar
提交
32d7cc13
S
soar
项目概览
m0_67397764
/
soar
与 Fork 源项目一致
Fork自
Xiaomi / soar
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
soar
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
32d7cc13
编写于
9月 16, 2019
作者:
martianzhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update version.go
上级
fedefa55
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
25 addition
and
49 deletion
+25
-49
.gitignore
.gitignore
+0
-1
Makefile
Makefile
+13
-8
advisor/rules.go
advisor/rules.go
+1
-1
common/version.go
common/version.go
+10
-0
doc/heuristic.md
doc/heuristic.md
+1
-1
genver.sh
genver.sh
+0
-38
未找到文件。
.gitignore
浏览文件 @
32d7cc13
bin/
release/
test/tmp/
common/version.go
doc/blueprint/
*.iml
*.swp
...
...
Makefile
浏览文件 @
32d7cc13
...
...
@@ -11,7 +11,13 @@ ifeq "$(GOPATH)" ""
endif
PATH
:=
${GOPATH}
/bin:
$(PATH)
GCFLAGS
=
-gcflags
"all=-trimpath=
${GOPATH}
"
LDFLAGS
=
-ldflags
=
"-s -w"
VERSION_TAG
:=
$(
shell
git describe
--tags
--always
)
VERSION_VERSION
:=
$(
shell
git log
--date
=
iso
--pretty
=
format:
"%cd"
-1
)
$(VERSION_TAG)
VERSION_COMPILE
:=
$(
shell
date
+
"%F %T %z"
)
by
$(
shell
go version
)
VERSION_BRANCH
:=
$(
shell
git rev-parse
--abbrev-ref
HEAD
)
VERSION_GIT_DIRTY
:=
$(
shell
git diff
--no-ext-diff
2>/dev/null |
wc
-l
)
VERSION_DEV_PATH
:=
$(
shell
pwd
)
LDFLAGS
=
-ldflags
=
"-s -w -X 'github.com/XiaoMi/soar/common.Version=
$(VERSION_VERSION)
' -X 'github.com/XiaoMi/soar/common.Compile=
$(VERSION_COMPILE)
' -X 'github.com/XiaoMi/soar/common.Branch=
$(VERSION_BRANCH)
' -X github.com/XiaoMi/soar/common.GitDirty=
$(VERSION_GIT_DIRTY)
-X github.com/XiaoMi/soar/common.DevPath=
$(VERSION_DEV_PATH)
"
# These are the values we want to pass for VERSION and BUILD
BUILD_TIME
=
`
date
+%Y%m%d%H%M
`
...
...
@@ -69,14 +75,14 @@ fmt: go_version_check
.PHONY
:
test
test
:
@
echo
"
$(CGREEN)
Run all test cases ...
$(CEND)
"
go
test
-timeout
10m
-race
./...
@
go
test
$(LDFLAGS)
-timeout
10m
-race
./...
@
echo
"test Success!"
# Rule golang test cases with `-update` flag
.PHONY
:
test-update
test-update
:
@
echo
"
$(CGREEN)
Run all test cases with -update flag ...
$(CEND)
"
go
test
./...
-update
@
go
test
$(LDFLAGS)
./...
-update
@
echo
"test-update Success!"
# Using bats test framework run all cli test cases
...
...
@@ -92,9 +98,9 @@ test-cli: build
.PHONY
:
cover
cover
:
test
@
echo
"
$(CGREEN)
Run test cover check ...
$(CEND)
"
go
test
-coverpkg
=
./...
-coverprofile
=
coverage.data ./... | column
-t
go tool cover
-html
=
coverage.data
-o
coverage.html
go tool cover
-func
=
coverage.data
-o
coverage.txt
@
go
test
$(LDFLAGS)
-coverpkg
=
./...
-coverprofile
=
coverage.data ./... | column
-t
@
go tool cover
-html
=
coverage.data
-o
coverage.html
@
go tool cover
-func
=
coverage.data
-o
coverage.txt
@
tail
-n
1 coverage.txt |
awk
'{sub(/%/, "", $$NF); \
if($$NF < 80) \
{print "
$(CRED)
"$$0"%
$(CEND)
"} \
...
...
@@ -107,10 +113,9 @@ cover: test
build
:
fmt
@
echo
"
$(CGREEN)
Building ...
$(CEND)
"
@
mkdir
-p
bin
@
bash ./genver.sh
@
ret
=
0
&&
for
d
in
$$
(
go list
-f
'{{if (eq .Name "main")}}{{.ImportPath}}{{end}}'
./...
)
;
do
\
b
=
$
$(
basename
$
${d}
)
;
\
go build
${GCFLAGS}
-o
bin/
$
${b}
$$
d
||
ret
=
$$
?
;
\
go build
${
LDFLAGS}
${
GCFLAGS}
-o
bin/
$
${b}
$$
d
||
ret
=
$$
?
;
\
done
;
exit
$$
ret
@
echo
"build Success!"
...
...
advisor/rules.go
浏览文件 @
32d7cc13
...
...
@@ -549,7 +549,7 @@ func init() {
Item
:
"COL.016"
,
Severity
:
"L1"
,
Summary
:
"整型定义建议采用 INT(10) 或 BIGINT(20)"
,
Content
:
`INT(M) 在 integer 数据类型中,M 表示最大显示宽度。 在 INT(M) 中,M 的值跟 INT(M) 所占多少存储空间并无任何关系。 INT(3)、INT(4)、INT(8) 在磁盘上都是占用 4 bytes 的存储空间。`
,
Content
:
`INT(M) 在 integer 数据类型中,M 表示最大显示宽度。 在 INT(M) 中,M 的值跟 INT(M) 所占多少存储空间并无任何关系。 INT(3)、INT(4)、INT(8) 在磁盘上都是占用 4 bytes 的存储空间。
高版本 MySQL 已经不推荐设置整数显示宽度。
`
,
Case
:
"CREATE TABLE tab (a INT(1));"
,
Func
:
(
*
Query4Audit
)
.
RuleIntPrecision
,
},
...
...
common/version.go
0 → 100644
浏览文件 @
32d7cc13
package
common
// -version输出信息
var
(
Version
=
"No Version Provided"
Compile
=
""
Branch
=
""
GitDirty
=
""
DevPath
=
""
)
doc/heuristic.md
浏览文件 @
32d7cc13
...
...
@@ -506,7 +506,7 @@ CREATE TABLE `tbl` (`c` blob DEFAULT NULL);
*
**Item**
:COL.016
*
**Severity**
:L1
*
**Content**
:INT(M) 在 integer 数据类型中,M 表示最大显示宽度。 在 INT(M) 中,M 的值跟 INT(M) 所占多少存储空间并无任何关系。 INT(3)、INT(4)、INT(8) 在磁盘上都是占用 4 bytes 的存储空间。
*
**Content**
:INT(M) 在 integer 数据类型中,M 表示最大显示宽度。 在 INT(M) 中,M 的值跟 INT(M) 所占多少存储空间并无任何关系。 INT(3)、INT(4)、INT(8) 在磁盘上都是占用 4 bytes 的存储空间。
高版本 MySQL 已经不推荐设置整数显示宽度。
*
**Case**
:
```
sql
...
...
genver.sh
已删除
100755 → 0
浏览文件 @
fedefa55
#!/bin/bash
## Generate Repository Version
tag
=
"
$(
git describe
--tags
--always
)
"
version
=
"
$(
git log
--date
=
iso
--pretty
=
format:
"%cd"
-1
)
${
tag
}
"
if
[
"X
${
version
}
"
==
"X"
]
;
then
version
=
"not a git repo"
tag
=
"not a git repo"
fi
git_dirty
=
$(
git diff
--no-ext-diff
2>/dev/null |
wc
-l
)
compile
=
"
$(
date
+
"%F %T %z"
)
by
$(
go version
)
"
branch
=
$(
git rev-parse
--abbrev-ref
HEAD
)
dev_path
=
$(
cd
"
$(
dirname
"
$0
"
)
"
||
exit
pwd
)
cat
<<
EOF
| gofmt >common/version.go
package common
// -version输出信息
const (
Version = "
${
version
}
"
Compile = "
${
compile
}
"
Branch = "
${
branch
}
"
GitDirty=
${
git_dirty
}
DevPath = "
${
dev_path
}
"
)
EOF
XIAOMI
=
$(
git ls-remote
--get-url
|
grep
XiaoMi
)
if
[
"x
${
XIAOMI
}
"
!=
"x"
]
;
then
echo
"
${
tag
}
"
|
awk
-F
'-'
'{print $1}'
>
VERSION
fi
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录