lib: add clippy_pedantic group with all Allow by default lints (fixes #265)
This commit is contained in:
parent
2abc5ab97c
commit
88dd38de87
5 changed files with 36 additions and 28 deletions
25
src/lib.rs
25
src/lib.rs
|
@ -77,10 +77,19 @@ pub fn plugin_registrar(reg: &mut Registry) {
|
||||||
reg.register_lint_pass(box matches::MatchPass as LintPassObject);
|
reg.register_lint_pass(box matches::MatchPass as LintPassObject);
|
||||||
reg.register_lint_pass(box misc::PatternPass as LintPassObject);
|
reg.register_lint_pass(box misc::PatternPass as LintPassObject);
|
||||||
|
|
||||||
reg.register_lint_group("shadow", vec![
|
reg.register_lint_group("clippy_pedantic", vec![
|
||||||
|
methods::OPTION_UNWRAP_USED,
|
||||||
|
methods::RESULT_UNWRAP_USED,
|
||||||
|
ptr_arg::PTR_ARG,
|
||||||
shadow::SHADOW_REUSE,
|
shadow::SHADOW_REUSE,
|
||||||
shadow::SHADOW_SAME,
|
shadow::SHADOW_SAME,
|
||||||
shadow::SHADOW_UNRELATED,
|
strings::STRING_ADD,
|
||||||
|
strings::STRING_ADD_ASSIGN,
|
||||||
|
types::CAST_POSSIBLE_TRUNCATION,
|
||||||
|
types::CAST_POSSIBLE_WRAP,
|
||||||
|
types::CAST_PRECISION_LOSS,
|
||||||
|
types::CAST_SIGN_LOSS,
|
||||||
|
unicode::NON_ASCII_LITERAL,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
reg.register_lint_group("clippy", vec![
|
reg.register_lint_group("clippy", vec![
|
||||||
|
@ -102,8 +111,6 @@ pub fn plugin_registrar(reg: &mut Registry) {
|
||||||
loops::WHILE_LET_LOOP,
|
loops::WHILE_LET_LOOP,
|
||||||
matches::MATCH_REF_PATS,
|
matches::MATCH_REF_PATS,
|
||||||
matches::SINGLE_MATCH,
|
matches::SINGLE_MATCH,
|
||||||
methods::OPTION_UNWRAP_USED,
|
|
||||||
methods::RESULT_UNWRAP_USED,
|
|
||||||
methods::SHOULD_IMPLEMENT_TRAIT,
|
methods::SHOULD_IMPLEMENT_TRAIT,
|
||||||
methods::STR_TO_STRING,
|
methods::STR_TO_STRING,
|
||||||
methods::STRING_TO_STRING,
|
methods::STRING_TO_STRING,
|
||||||
|
@ -116,25 +123,15 @@ pub fn plugin_registrar(reg: &mut Registry) {
|
||||||
mut_mut::MUT_MUT,
|
mut_mut::MUT_MUT,
|
||||||
needless_bool::NEEDLESS_BOOL,
|
needless_bool::NEEDLESS_BOOL,
|
||||||
precedence::PRECEDENCE,
|
precedence::PRECEDENCE,
|
||||||
ptr_arg::PTR_ARG,
|
|
||||||
ranges::RANGE_STEP_BY_ZERO,
|
ranges::RANGE_STEP_BY_ZERO,
|
||||||
returns::LET_AND_RETURN,
|
returns::LET_AND_RETURN,
|
||||||
returns::NEEDLESS_RETURN,
|
returns::NEEDLESS_RETURN,
|
||||||
shadow::SHADOW_REUSE,
|
|
||||||
shadow::SHADOW_SAME,
|
|
||||||
shadow::SHADOW_UNRELATED,
|
shadow::SHADOW_UNRELATED,
|
||||||
strings::STRING_ADD,
|
|
||||||
strings::STRING_ADD_ASSIGN,
|
|
||||||
types::BOX_VEC,
|
types::BOX_VEC,
|
||||||
types::CAST_POSSIBLE_TRUNCATION,
|
|
||||||
types::CAST_POSSIBLE_WRAP,
|
|
||||||
types::CAST_PRECISION_LOSS,
|
|
||||||
types::CAST_SIGN_LOSS,
|
|
||||||
types::LET_UNIT_VALUE,
|
types::LET_UNIT_VALUE,
|
||||||
types::LINKEDLIST,
|
types::LINKEDLIST,
|
||||||
types::TYPE_COMPLEXITY,
|
types::TYPE_COMPLEXITY,
|
||||||
types::UNIT_CMP,
|
types::UNIT_CMP,
|
||||||
unicode::NON_ASCII_LITERAL,
|
|
||||||
unicode::ZERO_WIDTH_SPACE,
|
unicode::ZERO_WIDTH_SPACE,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#![plugin(clippy)]
|
#![plugin(clippy)]
|
||||||
|
|
||||||
#![allow(unused)]
|
#![allow(unused)]
|
||||||
#![deny(clippy)]
|
#![deny(clippy, clippy_pedantic)]
|
||||||
|
|
||||||
use std::ops::Mul;
|
use std::ops::Mul;
|
||||||
|
|
||||||
|
|
2
tests/compile-fail/shadow.rs
Normal file → Executable file
2
tests/compile-fail/shadow.rs
Normal file → Executable file
|
@ -2,7 +2,7 @@
|
||||||
#![plugin(clippy)]
|
#![plugin(clippy)]
|
||||||
|
|
||||||
#![allow(unused_parens, unused_variables)]
|
#![allow(unused_parens, unused_variables)]
|
||||||
#![deny(shadow)]
|
#![deny(clippy, clippy_pedantic)]
|
||||||
|
|
||||||
fn id<T>(x: T) -> T { x }
|
fn id<T>(x: T) -> T { x }
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
rm -rf target*/*so
|
rm -rf target*/*so
|
||||||
cargo build --lib && cp -R target target_recur && cargo rustc -- -Zextra-plugins=clippy -Ltarget_recur/debug -Dclippy || exit 1
|
cargo build --lib && cp -R target target_recur && cargo rustc -- -Zextra-plugins=clippy -Ltarget_recur/debug -Dclippy_pedantic -Dclippy || exit 1
|
||||||
rm -rf target_recur
|
rm -rf target_recur
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ def gen_table(lints, link=None):
|
||||||
"""Write lint table in Markdown format."""
|
"""Write lint table in Markdown format."""
|
||||||
if link:
|
if link:
|
||||||
lints = [(p, '[%s](%s#%s)' % (l, link, l), lvl, d)
|
lints = [(p, '[%s](%s#%s)' % (l, link, l), lvl, d)
|
||||||
for (p, l, lvl, d) in lints]
|
for (p, l, lvl, d) in lints]
|
||||||
# first and third column widths
|
# first and third column widths
|
||||||
w_name = max(len(l[1]) for l in lints)
|
w_name = max(len(l[1]) for l in lints)
|
||||||
w_desc = max(len(l[3]) for l in lints)
|
w_desc = max(len(l[3]) for l in lints)
|
||||||
|
@ -50,8 +50,10 @@ def gen_table(lints, link=None):
|
||||||
yield '%-*s | %-7s | %s\n' % (w_name, name, default, meaning)
|
yield '%-*s | %-7s | %s\n' % (w_name, name, default, meaning)
|
||||||
|
|
||||||
|
|
||||||
def gen_group(lints):
|
def gen_group(lints, levels=None):
|
||||||
"""Write lint group (list of all lints in the form module::NAME)."""
|
"""Write lint group (list of all lints in the form module::NAME)."""
|
||||||
|
if levels:
|
||||||
|
lints = [tup for tup in lints if tup[2] in levels]
|
||||||
for (module, name, _, _) in sorted(lints):
|
for (module, name, _, _) in sorted(lints):
|
||||||
yield ' %s::%s,\n' % (module, name.upper())
|
yield ' %s::%s,\n' % (module, name.upper())
|
||||||
|
|
||||||
|
@ -113,19 +115,28 @@ def main(print_only=False, check=False):
|
||||||
return
|
return
|
||||||
|
|
||||||
# replace table in README.md
|
# replace table in README.md
|
||||||
changed = replace_region('README.md', r'^name +\|', '^$',
|
changed = replace_region(
|
||||||
lambda: gen_table(lints, link=wiki_link),
|
'README.md', r'^name +\|', '^$',
|
||||||
write_back=not check)
|
lambda: gen_table(lints, link=wiki_link),
|
||||||
|
write_back=not check)
|
||||||
|
|
||||||
changed |= replace_region('README.md',
|
changed |= replace_region(
|
||||||
|
'README.md',
|
||||||
r'^There are \d+ lints included in this crate:', "",
|
r'^There are \d+ lints included in this crate:', "",
|
||||||
lambda: ['There are %d lints included in this crate:\n' % len(lints)],
|
lambda: ['There are %d lints included in this crate:\n' % len(lints)],
|
||||||
write_back=not check)
|
write_back=not check)
|
||||||
|
|
||||||
# same for "clippy" lint collection
|
# same for "clippy" lint collection
|
||||||
changed |= replace_region('src/lib.rs', r'reg.register_lint_group\("clippy"', r'\]\);',
|
changed |= replace_region(
|
||||||
lambda: gen_group(lints), replace_start=False,
|
'src/lib.rs', r'reg.register_lint_group\("clippy"', r'\]\);',
|
||||||
write_back=not check)
|
lambda: gen_group(lints, levels=('warn', 'deny')),
|
||||||
|
replace_start=False, write_back=not check)
|
||||||
|
|
||||||
|
# same for "clippy_pedantic" lint collection
|
||||||
|
changed |= replace_region(
|
||||||
|
'src/lib.rs', r'reg.register_lint_group\("clippy_pedantic"', r'\]\);',
|
||||||
|
lambda: gen_group(lints, levels=('allow',)),
|
||||||
|
replace_start=False, write_back=not check)
|
||||||
|
|
||||||
if check and changed:
|
if check and changed:
|
||||||
print('Please run util/update_lints.py to regenerate lints lists.')
|
print('Please run util/update_lints.py to regenerate lints lists.')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue