Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
94965834
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
94965834
编写于
4月 22, 2019
作者:
V
varkor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a tidy test for line count
上级
bd31c392
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
15 addition
and
3 deletion
+15
-3
src/tools/tidy/src/style.rs
src/tools/tidy/src/style.rs
+15
-3
未找到文件。
src/tools/tidy/src/style.rs
浏览文件 @
94965834
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
//! Example checks are:
//! Example checks are:
//!
//!
//! * No lines over 100 characters.
//! * No lines over 100 characters.
//! * No files with over 3000 lines.
//! * No tabs.
//! * No tabs.
//! * No trailing whitespace.
//! * No trailing whitespace.
//! * No CR characters.
//! * No CR characters.
...
@@ -18,6 +19,8 @@
...
@@ -18,6 +19,8 @@
const
COLS
:
usize
=
100
;
const
COLS
:
usize
=
100
;
const
LINES
:
usize
=
3000
;
const
UNEXPLAINED_IGNORE_DOCTEST_INFO
:
&
str
=
r#"unexplained "```ignore" doctest; try one:
const
UNEXPLAINED_IGNORE_DOCTEST_INFO
:
&
str
=
r#"unexplained "```ignore" doctest; try one:
* make the test actually pass, by adding necessary imports and declarations, or
* make the test actually pass, by adding necessary imports and declarations, or
...
@@ -139,11 +142,13 @@ pub fn check(path: &Path, bad: &mut bool) {
...
@@ -139,11 +142,13 @@ pub fn check(path: &Path, bad: &mut bool) {
let
mut
skip_cr
=
contains_ignore_directive
(
&
contents
,
"cr"
);
let
mut
skip_cr
=
contains_ignore_directive
(
&
contents
,
"cr"
);
let
mut
skip_tab
=
contains_ignore_directive
(
&
contents
,
"tab"
);
let
mut
skip_tab
=
contains_ignore_directive
(
&
contents
,
"tab"
);
let
mut
skip_length
=
contains_ignore_directive
(
&
contents
,
"linelength"
);
let
mut
skip_line_length
=
contains_ignore_directive
(
&
contents
,
"linelength"
);
let
mut
skip_file_length
=
contains_ignore_directive
(
&
contents
,
"filelength"
);
let
mut
skip_end_whitespace
=
contains_ignore_directive
(
&
contents
,
"end-whitespace"
);
let
mut
skip_end_whitespace
=
contains_ignore_directive
(
&
contents
,
"end-whitespace"
);
let
mut
skip_copyright
=
contains_ignore_directive
(
&
contents
,
"copyright"
);
let
mut
skip_copyright
=
contains_ignore_directive
(
&
contents
,
"copyright"
);
let
mut
leading_new_lines
=
false
;
let
mut
leading_new_lines
=
false
;
let
mut
trailing_new_lines
=
0
;
let
mut
trailing_new_lines
=
0
;
let
mut
lines
=
0
;
for
(
i
,
line
)
in
contents
.split
(
'\n'
)
.enumerate
()
{
for
(
i
,
line
)
in
contents
.split
(
'\n'
)
.enumerate
()
{
let
mut
err
=
|
msg
:
&
str
|
{
let
mut
err
=
|
msg
:
&
str
|
{
tidy_error!
(
bad
,
"{}:{}: {}"
,
file
.display
(),
i
+
1
,
msg
);
tidy_error!
(
bad
,
"{}:{}: {}"
,
file
.display
(),
i
+
1
,
msg
);
...
@@ -151,7 +156,7 @@ pub fn check(path: &Path, bad: &mut bool) {
...
@@ -151,7 +156,7 @@ pub fn check(path: &Path, bad: &mut bool) {
if
line
.chars
()
.count
()
>
COLS
&&
!
long_line_is_ok
(
line
)
{
if
line
.chars
()
.count
()
>
COLS
&&
!
long_line_is_ok
(
line
)
{
suppressible_tidy_err!
(
suppressible_tidy_err!
(
err
,
err
,
skip_length
,
skip_l
ine_l
ength
,
&
format!
(
"line longer than {} chars"
,
COLS
)
&
format!
(
"line longer than {} chars"
,
COLS
)
);
);
}
}
...
@@ -197,6 +202,7 @@ pub fn check(path: &Path, bad: &mut bool) {
...
@@ -197,6 +202,7 @@ pub fn check(path: &Path, bad: &mut bool) {
}
else
{
}
else
{
trailing_new_lines
=
0
;
trailing_new_lines
=
0
;
}
}
lines
=
i
;
}
}
if
leading_new_lines
{
if
leading_new_lines
{
tidy_error!
(
bad
,
"{}: leading newline"
,
file
.display
());
tidy_error!
(
bad
,
"{}: leading newline"
,
file
.display
());
...
@@ -206,6 +212,9 @@ pub fn check(path: &Path, bad: &mut bool) {
...
@@ -206,6 +212,9 @@ pub fn check(path: &Path, bad: &mut bool) {
1
=>
{}
1
=>
{}
n
=>
tidy_error!
(
bad
,
"{}: too many trailing newlines ({})"
,
file
.display
(),
n
),
n
=>
tidy_error!
(
bad
,
"{}: too many trailing newlines ({})"
,
file
.display
(),
n
),
};
};
if
!
skip_file_length
&&
lines
>
LINES
{
tidy_error!
(
bad
,
"{}: too many lines ({})"
,
file
.display
(),
lines
);
}
if
let
Directive
::
Ignore
(
false
)
=
skip_cr
{
if
let
Directive
::
Ignore
(
false
)
=
skip_cr
{
tidy_error!
(
bad
,
"{}: ignoring CR characters unnecessarily"
,
file
.display
());
tidy_error!
(
bad
,
"{}: ignoring CR characters unnecessarily"
,
file
.display
());
...
@@ -213,9 +222,12 @@ pub fn check(path: &Path, bad: &mut bool) {
...
@@ -213,9 +222,12 @@ pub fn check(path: &Path, bad: &mut bool) {
if
let
Directive
::
Ignore
(
false
)
=
skip_tab
{
if
let
Directive
::
Ignore
(
false
)
=
skip_tab
{
tidy_error!
(
bad
,
"{}: ignoring tab characters unnecessarily"
,
file
.display
());
tidy_error!
(
bad
,
"{}: ignoring tab characters unnecessarily"
,
file
.display
());
}
}
if
let
Directive
::
Ignore
(
false
)
=
skip_length
{
if
let
Directive
::
Ignore
(
false
)
=
skip_l
ine_l
ength
{
tidy_error!
(
bad
,
"{}: ignoring line length unnecessarily"
,
file
.display
());
tidy_error!
(
bad
,
"{}: ignoring line length unnecessarily"
,
file
.display
());
}
}
if
let
Directive
::
Ignore
(
false
)
=
skip_file_length
{
tidy_error!
(
bad
,
"{}: ignoring file length unnecessarily"
,
file
.display
());
}
if
let
Directive
::
Ignore
(
false
)
=
skip_end_whitespace
{
if
let
Directive
::
Ignore
(
false
)
=
skip_end_whitespace
{
tidy_error!
(
bad
,
"{}: ignoring trailing whitespace unnecessarily"
,
file
.display
());
tidy_error!
(
bad
,
"{}: ignoring trailing whitespace unnecessarily"
,
file
.display
());
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录