Negate ignore_names condition

This commit is contained in:
Charlie Marsh 2022-12-14 22:50:26 -05:00
parent 6be910ae07
commit dc180dc277
4 changed files with 36 additions and 10 deletions

View File

@ -1,4 +1,4 @@
use rustpython_ast::{Located};
use rustpython_ast::Located;
use crate::ast::types::Range;
use crate::checks::{Check, CheckKind};

View File

@ -1,7 +1,6 @@
use rustpython_ast::{ExcepthandlerKind, ExprKind, Stmt, StmtKind};
use crate::ast::helpers::identifier_range;
use crate::checks::{Check, CheckKind};
use crate::source_code_locator::SourceCodeLocator;

View File

@ -33,7 +33,7 @@ pub fn invalid_function_name(
ignore_names: &[String],
locator: &SourceCodeLocator,
) -> Option<Check> {
if name.to_lowercase() != name && ignore_names.iter().any(|ignore_name| ignore_name == name) {
if name.to_lowercase() != name && !ignore_names.iter().any(|ignore_name| ignore_name == name) {
return Some(Check::new(
CheckKind::InvalidFunctionName(name.to_string()),
identifier_range(func_def, locator),

View File

@ -3,21 +3,48 @@ source: src/pep8_naming/mod.rs
expression: checks
---
- kind:
InvalidFunctionName: tearDownModule
InvalidFunctionName: Bad
location:
row: 32
row: 4
column: 4
end_location:
row: 32
column: 18
row: 4
column: 7
fix: ~
- kind:
InvalidFunctionName: tearDown
InvalidFunctionName: _Bad
location:
row: 37
row: 8
column: 4
end_location:
row: 8
column: 8
fix: ~
- kind:
InvalidFunctionName: BAD
location:
row: 12
column: 4
end_location:
row: 12
column: 7
fix: ~
- kind:
InvalidFunctionName: BAD_FUNC
location:
row: 16
column: 4
end_location:
row: 16
column: 12
fix: ~
- kind:
InvalidFunctionName: testTest
location:
row: 40
column: 8
end_location:
row: 37
row: 40
column: 16
fix: ~