Compare commits

..

14 Commits

Author SHA1 Message Date
Charlie Marsh
062c41b6f5 Bump version to 0.0.93 2022-10-31 09:20:39 -04:00
Charlie Marsh
78889efa37 Modify public API to return Check rather than Message (#524) 2022-10-31 09:20:14 -04:00
Charlie Marsh
97fc281779 Remove erroneous foo.py file 2022-10-30 19:19:49 -04:00
Charlie Marsh
138b06c98a Bump version to 0.0.92 2022-10-30 18:04:30 -04:00
Charlie Marsh
2415d73260 Remove RustPython fork (#523) 2022-10-30 18:04:05 -04:00
Charlie Marsh
b060ae2f22 Move SourceCodeLocator to its own module (#522) 2022-10-30 15:51:59 -04:00
Charlie Marsh
9aa91d3d3c Add a cargo bench for SourceCodeLocator (#521) 2022-10-30 13:50:42 -04:00
Charlie Marsh
dcedb801e5 Tweak a few check messages (#520) 2022-10-30 13:13:37 -04:00
Charlie Marsh
d3e7fdabb5 Implement consistent newline handling for SourceCodeLocator (#519) 2022-10-30 13:11:08 -04:00
Charlie Marsh
dfa5a4f0f7 Fix 9/32 flake8-bugbear reference 2022-10-30 13:03:39 -04:00
Charlie Marsh
58a2d600da Avoid flagging D202 for inner functions and classes (#518) 2022-10-30 13:02:55 -04:00
Harutaka Kawamura
7ecbfe4f6a Implement B006 (#515) 2022-10-30 12:57:57 -04:00
Charlie Marsh
d8248104a7 Avoid re-indenting empty lines in D207 (#517) 2022-10-30 09:41:54 -04:00
Charlie Marsh
6eb09122c0 Add final newline in SourceCodeLocator 2022-10-29 19:23:16 -04:00
187 changed files with 2715 additions and 2230 deletions

View File

@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.91
rev: v0.0.93
hooks:
- id: ruff

169
Cargo.lock generated
View File

@@ -37,6 +37,12 @@ dependencies = [
"libc",
]
[[package]]
name = "anes"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
[[package]]
name = "annotate-snippets"
version = "0.6.1"
@@ -368,6 +374,12 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c"
[[package]]
name = "cast"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
[[package]]
name = "cc"
version = "1.0.73"
@@ -416,6 +428,45 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fff857943da45f546682664a79488be82e69e43c1a7a2307679ab9afb3a66d2e"
[[package]]
name = "ciborium"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0c137568cc60b904a7724001b35ce2630fd00d5d84805fbb608ab89509d788f"
dependencies = [
"ciborium-io",
"ciborium-ll",
"serde",
]
[[package]]
name = "ciborium-io"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "346de753af073cc87b52b2083a506b38ac176a44cfb05497b622e27be899b369"
[[package]]
name = "ciborium-ll"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "213030a2b5a4e0c0892b6652260cf6ccac84827b83a85a534e178e3906c4cf1b"
dependencies = [
"ciborium-io",
"half",
]
[[package]]
name = "clap"
version = "3.2.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5"
dependencies = [
"bitflags",
"clap_lex 0.2.4",
"indexmap",
"textwrap 0.16.0",
]
[[package]]
name = "clap"
version = "4.0.15"
@@ -425,7 +476,7 @@ dependencies = [
"atty",
"bitflags",
"clap_derive",
"clap_lex",
"clap_lex 0.3.0",
"once_cell",
"strsim",
"termcolor",
@@ -444,6 +495,15 @@ dependencies = [
"syn",
]
[[package]]
name = "clap_lex"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
dependencies = [
"os_str_bytes",
]
[[package]]
name = "clap_lex"
version = "0.3.0"
@@ -548,6 +608,42 @@ dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "criterion"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7c76e09c1aae2bc52b3d2f29e13c6572553b30c4aa1b8a49fd70de6412654cb"
dependencies = [
"anes",
"atty",
"cast",
"ciborium",
"clap 3.2.23",
"criterion-plot",
"itertools",
"lazy_static",
"num-traits",
"oorandom",
"plotters",
"rayon",
"regex",
"serde",
"serde_derive",
"serde_json",
"tinytemplate",
"walkdir",
]
[[package]]
name = "criterion-plot"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1"
dependencies = [
"cast",
"itertools",
]
[[package]]
name = "crossbeam-channel"
version = "0.5.6"
@@ -1041,6 +1137,12 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "half"
version = "1.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
[[package]]
name = "hashbrown"
version = "0.12.3"
@@ -1571,6 +1673,12 @@ version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1"
[[package]]
name = "oorandom"
version = "11.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
[[package]]
name = "opaque-debug"
version = "0.2.3"
@@ -1779,6 +1887,34 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "plotters"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2538b639e642295546c50fcd545198c9d64ee2a38620a628724a3b266d5fbf97"
dependencies = [
"num-traits",
"plotters-backend",
"plotters-svg",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "plotters-backend"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "193228616381fecdc1224c62e96946dfbc73ff4384fba576e052ff8c1bea8142"
[[package]]
name = "plotters-svg"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f"
dependencies = [
"plotters-backend",
]
[[package]]
name = "polling"
version = "2.3.0"
@@ -2054,18 +2190,19 @@ dependencies = [
[[package]]
name = "ruff"
version = "0.0.91"
version = "0.0.93"
dependencies = [
"anyhow",
"assert_cmd",
"bincode",
"cacache",
"chrono",
"clap",
"clap 4.0.15",
"clearscreen",
"codegen",
"colored",
"common-path",
"criterion",
"dirs 4.0.0",
"fern",
"filetime",
@@ -2089,7 +2226,7 @@ dependencies = [
"strum",
"strum_macros",
"test-case",
"textwrap",
"textwrap 0.15.1",
"titlecase",
"toml",
"update-informer",
@@ -2111,7 +2248,7 @@ dependencies = [
[[package]]
name = "rustpython-ast"
version = "0.1.0"
source = "git+https://github.com/charliermarsh/RustPython.git?rev=1b253a12705f84972cd76e8dc1cdaaccb233e5a5#1b253a12705f84972cd76e8dc1cdaaccb233e5a5"
source = "git+https://github.com/RustPython/RustPython.git?rev=77b821a1941019fe34f73ce17cea013ae1b98fd0#77b821a1941019fe34f73ce17cea013ae1b98fd0"
dependencies = [
"num-bigint",
"rustpython-common",
@@ -2121,7 +2258,7 @@ dependencies = [
[[package]]
name = "rustpython-common"
version = "0.0.0"
source = "git+https://github.com/charliermarsh/RustPython.git?rev=1b253a12705f84972cd76e8dc1cdaaccb233e5a5#1b253a12705f84972cd76e8dc1cdaaccb233e5a5"
source = "git+https://github.com/RustPython/RustPython.git?rev=77b821a1941019fe34f73ce17cea013ae1b98fd0#77b821a1941019fe34f73ce17cea013ae1b98fd0"
dependencies = [
"ascii",
"cfg-if 1.0.0",
@@ -2144,7 +2281,7 @@ dependencies = [
[[package]]
name = "rustpython-compiler-core"
version = "0.1.2"
source = "git+https://github.com/charliermarsh/RustPython.git?rev=1b253a12705f84972cd76e8dc1cdaaccb233e5a5#1b253a12705f84972cd76e8dc1cdaaccb233e5a5"
source = "git+https://github.com/RustPython/RustPython.git?rev=77b821a1941019fe34f73ce17cea013ae1b98fd0#77b821a1941019fe34f73ce17cea013ae1b98fd0"
dependencies = [
"bincode",
"bitflags",
@@ -2161,7 +2298,7 @@ dependencies = [
[[package]]
name = "rustpython-parser"
version = "0.1.2"
source = "git+https://github.com/charliermarsh/RustPython.git?rev=1b253a12705f84972cd76e8dc1cdaaccb233e5a5#1b253a12705f84972cd76e8dc1cdaaccb233e5a5"
source = "git+https://github.com/RustPython/RustPython.git?rev=77b821a1941019fe34f73ce17cea013ae1b98fd0#77b821a1941019fe34f73ce17cea013ae1b98fd0"
dependencies = [
"ahash",
"anyhow",
@@ -2549,6 +2686,12 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "textwrap"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
[[package]]
name = "thiserror"
version = "1.0.37"
@@ -2589,6 +2732,16 @@ dependencies = [
"crunchy",
]
[[package]]
name = "tinytemplate"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc"
dependencies = [
"serde",
"serde_json",
]
[[package]]
name = "tinyvec"
version = "1.6.0"

View File

@@ -1,6 +1,6 @@
[package]
name = "ruff"
version = "0.0.91"
version = "0.0.93"
edition = "2021"
[lib]
@@ -26,9 +26,9 @@ once_cell = { version = "1.13.1" }
path-absolutize = { version = "3.0.14", features = ["once_cell_cache", "use_unix_paths_on_wasm"] }
rayon = { version = "1.5.3" }
regex = { version = "1.6.0" }
rustpython-ast = { features = ["unparse"], git = "https://github.com/charliermarsh/RustPython.git", rev = "1b253a12705f84972cd76e8dc1cdaaccb233e5a5" }
rustpython-common = { git = "https://github.com/charliermarsh/RustPython.git", rev = "1b253a12705f84972cd76e8dc1cdaaccb233e5a5" }
rustpython-parser = { features = ["lalrpop"], git = "https://github.com/charliermarsh/RustPython.git", rev = "1b253a12705f84972cd76e8dc1cdaaccb233e5a5" }
rustpython-ast = { features = ["unparse"], git = "https://github.com/RustPython/RustPython.git", rev = "77b821a1941019fe34f73ce17cea013ae1b98fd0" }
rustpython-common = { git = "https://github.com/RustPython/RustPython.git", rev = "77b821a1941019fe34f73ce17cea013ae1b98fd0" }
rustpython-parser = { features = ["lalrpop"], git = "https://github.com/RustPython/RustPython.git", rev = "77b821a1941019fe34f73ce17cea013ae1b98fd0" }
serde = { version = "1.0.143", features = ["derive"] }
serde_json = { version = "1.0.83" }
strum = { version = "0.24.1", features = ["strum_macros"] }
@@ -51,6 +51,7 @@ getrandom = { version = "0.2.7", features = ["js"] }
[dev-dependencies]
assert_cmd = { version = "2.0.4" }
codegen = { version = "0.2.0" }
criterion = { version = "0.4.0" }
insta = { version = "1.19.1", features = ["yaml"] }
test-case = { version = "2.2.2" }
@@ -69,3 +70,7 @@ opt-level = 3
[profile.dev.package.similar]
opt-level = 3
[[bench]]
name = "source_code_locator"
harness = false

View File

@@ -89,7 +89,7 @@ Ruff also works with [pre-commit](https://pre-commit.com):
```yaml
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.91
rev: v0.0.93
hooks:
- id: ruff
```
@@ -272,7 +272,7 @@ The 🛠 emoji indicates that a rule is automatically fixable by the `--fix` com
| F634 | IfTuple | If test is a tuple, which is always `True` | |
| F701 | BreakOutsideLoop | `break` outside loop | |
| F702 | ContinueOutsideLoop | `continue` not properly in loop | |
| F704 | YieldOutsideFunction | `yield` or `yield from` statement outside of a function/method | |
| F704 | YieldOutsideFunction | `yield` or `yield from` statement outside of a function | |
| F706 | ReturnOutsideFunction | `return` statement outside of a function/method | |
| F707 | DefaultExceptNotLast | An `except:` block as not the last exception handler | |
| F722 | ForwardAnnotationSyntaxError | Syntax error in forward annotation: `...` | |
@@ -341,7 +341,7 @@ The 🛠 emoji indicates that a rule is automatically fixable by the `--fix` com
| D400 | EndsInPeriod | First line should end with a period | |
| D402 | NoSignature | First line should not be the function's signature | |
| D403 | FirstLineCapitalized | First word of the first line should be properly capitalized | |
| D404 | NoThisPrefix | First word of the docstring should not be `This` | |
| D404 | NoThisPrefix | First word of the docstring should not be 'This' | |
| D405 | CapitalizeSectionName | Section name should be properly capitalized ("returns") | 🛠 |
| D406 | NewLineAfterSectionName | Section name should end with a newline ("Returns") | 🛠 |
| D407 | DashedUnderlineAfterSection | Missing dashed underline after section ("Returns") | 🛠 |
@@ -355,7 +355,7 @@ The 🛠 emoji indicates that a rule is automatically fixable by the `--fix` com
| D415 | EndsInPunctuation | First line should end with a period, question mark, or exclamation point | |
| D416 | SectionNameEndsInColon | Section name should end with a colon ("Returns") | 🛠 |
| D417 | DocumentAllArguments | Missing argument descriptions in the docstring: `x`, `y` | |
| D418 | SkipDocstring | Function decorated with @overload shouldn't contain a docstring | |
| D418 | SkipDocstring | Function decorated with `@overload` shouldn't contain a docstring | |
| D419 | NonEmpty | Docstring is empty | |
### pyupgrade
@@ -417,6 +417,7 @@ The 🛠 emoji indicates that a rule is automatically fixable by the `--fix` com
| Code | Name | Message | Fix |
| ---- | ---- | ------- | --- |
| B002 | UnaryPrefixIncrement | Python does not support the unary prefix increment. | |
| B006 | MutableArgumentDefault | Do not use mutable data structures for argument defaults. | |
| B007 | UnusedLoopControlVariable | Loop control variable `i` not used within the loop body. | 🛠 |
| B011 | DoNotAssertFalse | Do not `assert False` (`python -O` removes these calls), raise `AssertionError()` | 🛠 |
| B013 | RedundantTupleInExceptionHandler | A length-one tuple literal is redundant. Write `except ValueError:` instead of `except (ValueError,):`. | |
@@ -544,7 +545,7 @@ Today, Ruff can be used to replace Flake8 when used with any of the following pl
- [`flake8-print`](https://pypi.org/project/flake8-print/)
- [`flake8-quotes`](https://pypi.org/project/flake8-quotes/)
- [`flake8-comprehensions`](https://pypi.org/project/flake8-comprehensions/)
- [`flake8-bugbear`](https://pypi.org/project/flake8-bugbear/) (9/32)
- [`flake8-bugbear`](https://pypi.org/project/flake8-bugbear/) (10/32)
Ruff also implements the functionality that you get from [`yesqa`](https://github.com/asottile/yesqa),
and a subset of the rules implemented in [`pyupgrade`](https://pypi.org/project/pyupgrade/) (8/34).

View File

@@ -0,0 +1,16 @@
use std::path::Path;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use ruff::fs;
use ruff::source_code_locator::compute_offsets;
fn criterion_benchmark(c: &mut Criterion) {
let contents = fs::read_file(Path::new("resources/test/fixtures/D.py")).unwrap();
c.bench_function("compute_offsets", |b| {
b.iter(|| compute_offsets(black_box(&contents)))
});
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);

187
resources/test/fixtures/B006_B008.py vendored Normal file
View File

@@ -0,0 +1,187 @@
import collections
import datetime as dt
import logging
import operator
import random
import re
import time
import types
from operator import attrgetter, itemgetter, methodcaller
from types import MappingProxyType
# B006
# Allow immutable literals/calls/comprehensions
def this_is_okay(value=(1, 2, 3)):
...
async def and_this_also(value=tuple()):
pass
def frozenset_also_okay(value=frozenset()):
pass
def mappingproxytype_okay(
value=MappingProxyType({}), value2=types.MappingProxyType({})
):
pass
def re_compile_ok(value=re.compile("foo")):
pass
def operators_ok(
v=operator.attrgetter("foo"),
v2=operator.itemgetter("foo"),
v3=operator.methodcaller("foo"),
):
pass
def operators_ok_unqualified(
v=attrgetter("foo"),
v2=itemgetter("foo"),
v3=methodcaller("foo"),
):
pass
def kwonlyargs_immutable(*, value=()):
...
# Flag mutable literals/comprehensions
def this_is_wrong(value=[1, 2, 3]):
...
def this_is_also_wrong(value={}):
...
def and_this(value=set()):
...
def this_too(value=collections.OrderedDict()):
...
async def async_this_too(value=collections.defaultdict()):
...
def dont_forget_me(value=collections.deque()):
...
# N.B. we're also flagging the function call in the comprehension
def list_comprehension_also_not_okay(default=[i**2 for i in range(3)]):
pass
def dict_comprehension_also_not_okay(default={i: i**2 for i in range(3)}):
pass
def set_comprehension_also_not_okay(default={i**2 for i in range(3)}):
pass
def kwonlyargs_mutable(*, value=[]):
...
# Recommended approach for mutable defaults
def do_this_instead(value=None):
if value is None:
value = set()
# B008
# Flag function calls as default args (including if they are part of a sub-expression)
def in_fact_all_calls_are_wrong(value=time.time()):
...
def f(when=dt.datetime.now() + dt.timedelta(days=7)):
pass
def can_even_catch_lambdas(a=(lambda x: x)()):
...
# Recommended approach for function calls as default args
LOGGER = logging.getLogger(__name__)
def do_this_instead_of_calls_in_defaults(logger=LOGGER):
# That makes it more obvious that this one value is reused.
...
# Handle inf/infinity/nan special case
def float_inf_okay(value=float("inf")):
pass
def float_infinity_okay(value=float("infinity")):
pass
def float_plus_infinity_okay(value=float("+infinity")):
pass
def float_minus_inf_okay(value=float("-inf")):
pass
def float_nan_okay(value=float("nan")):
pass
def float_minus_NaN_okay(value=float("-NaN")):
pass
def float_infinity_literal(value=float("1e999")):
pass
# But don't allow standard floats
def float_int_is_wrong(value=float(3)):
pass
def float_str_not_inf_or_nan_is_wrong(value=float("3.14")):
pass
# B006 and B008
# We should handle arbitrary nesting of these B008.
def nested_combo(a=[float(3), dt.datetime.now()]):
pass
# Don't flag nested B006 since we can't guarantee that
# it isn't made mutable by the outer operation.
def no_nested_b006(a=map(lambda s: s.upper(), ["a", "b", "c"])):
pass
# B008-ception.
def nested_b008(a=random.randint(0, dt.datetime.now().year)):
pass
# Ignore lambda contents since they are evaluated at call time.
def foo(f=lambda x: print(x)):
f(1)

View File

@@ -137,7 +137,7 @@ pub fn to_absolute(relative: &Location, base: &Location) -> Location {
if relative.row() == 1 {
Location::new(
relative.row() + base.row() - 1,
relative.column() + base.column() - 1,
relative.column() + base.column(),
)
} else {
Location::new(relative.row() + base.row() - 1, relative.column())

View File

@@ -1,7 +1,6 @@
use once_cell::unsync::OnceCell;
use rustpython_parser::ast::{Constant, Expr, ExprKind, Location, Stmt, StmtKind};
use rustpython_parser::ast::{Constant, Expr, ExprKind, Stmt, StmtKind};
use crate::ast::types::{BindingKind, Range, Scope};
use crate::ast::types::{BindingKind, Scope};
/// Extract the names bound to a given __all__ assignment.
pub fn extract_all_names(stmt: &Stmt, scope: &Scope) -> Vec<String> {
@@ -118,91 +117,3 @@ pub fn is_unpacking_assignment(stmt: &Stmt) -> bool {
}
false
}
/// Struct used to efficiently slice source code at (row, column) Locations.
pub struct SourceCodeLocator<'a> {
contents: &'a str,
offsets: OnceCell<Vec<Vec<usize>>>,
}
impl<'a> SourceCodeLocator<'a> {
pub fn new(contents: &'a str) -> Self {
SourceCodeLocator {
contents,
offsets: OnceCell::new(),
}
}
fn compute_offsets(content: &str) -> Vec<Vec<usize>> {
let mut offsets = vec![vec![]];
let mut line_index = 0;
for (i, char) in content.char_indices() {
offsets[line_index].push(i);
if char == '\n' {
line_index += 1;
offsets.push(vec![]);
}
}
offsets
}
fn get_or_init_offsets(&self) -> &Vec<Vec<usize>> {
self.offsets
.get_or_init(|| Self::compute_offsets(self.contents))
}
pub fn slice_source_code_at(&self, location: &Location) -> &'a str {
let offsets = self.get_or_init_offsets();
let offset = offsets[location.row() - 1][location.column() - 1];
&self.contents[offset..]
}
pub fn slice_source_code_range(&self, range: &Range) -> &'a str {
let offsets = self.get_or_init_offsets();
let start = offsets[range.location.row() - 1][range.location.column() - 1];
let end = offsets[range.end_location.row() - 1][range.end_location.column() - 1];
&self.contents[start..end]
}
pub fn partition_source_code_at(
&self,
outer: &Range,
inner: &Range,
) -> (&'a str, &'a str, &'a str) {
let offsets = self.get_or_init_offsets();
let outer_start = offsets[outer.location.row() - 1][outer.location.column() - 1];
let outer_end = offsets[outer.end_location.row() - 1][outer.end_location.column() - 1];
let inner_start = offsets[inner.location.row() - 1][inner.location.column() - 1];
let inner_end = offsets[inner.end_location.row() - 1][inner.end_location.column() - 1];
(
&self.contents[outer_start..inner_start],
&self.contents[inner_start..inner_end],
&self.contents[inner_end..outer_end],
)
}
}
#[cfg(test)]
mod tests {
use super::SourceCodeLocator;
#[test]
fn source_code_locator_init() {
let content = "x = 1\ny = 2\nz = x + y\n";
let locator = SourceCodeLocator::new(content);
let offsets = locator.get_or_init_offsets();
assert_eq!(offsets.len(), 4);
assert_eq!(offsets[0], [0, 1, 2, 3, 4, 5]);
assert_eq!(offsets[1], [6, 7, 8, 9, 10, 11]);
assert_eq!(offsets[2], [12, 13, 14, 15, 16, 17, 18, 19, 20, 21]);
assert!(offsets[3].is_empty());
let content = "# \u{4e9c}\nclass Foo:\n \"\"\".\"\"\"";
let locator = SourceCodeLocator::new(content);
let offsets = locator.get_or_init_offsets();
assert_eq!(offsets.len(), 3);
assert_eq!(offsets[0], [0, 1, 2, 5]);
assert_eq!(offsets[1], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
assert_eq!(offsets[2], [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27]);
}
}

View File

@@ -69,19 +69,18 @@ fn apply_fixes<'a>(fixes: impl Iterator<Item = &'a mut Fix>, contents: &str) ->
if fix.patch.location.row() > last_pos.row() {
if last_pos.row() > 0 || last_pos.column() > 0 {
output.push_str(&lines[last_pos.row() - 1][last_pos.column() - 1..]);
output.push_str(&lines[last_pos.row() - 1][last_pos.column()..]);
output.push('\n');
}
for line in &lines[last_pos.row()..fix.patch.location.row() - 1] {
output.push_str(line);
output.push('\n');
}
output
.push_str(&lines[fix.patch.location.row() - 1][..fix.patch.location.column() - 1]);
output.push_str(&lines[fix.patch.location.row() - 1][..fix.patch.location.column()]);
output.push_str(&fix.patch.content);
} else {
output.push_str(
&lines[last_pos.row() - 1][last_pos.column() - 1..fix.patch.location.column() - 1],
&lines[last_pos.row() - 1][last_pos.column()..fix.patch.location.column()],
);
output.push_str(&fix.patch.content);
}
@@ -95,7 +94,7 @@ fn apply_fixes<'a>(fixes: impl Iterator<Item = &'a mut Fix>, contents: &str) ->
&& (last_pos.row() - 1) < lines.len()
&& (last_pos.row() > 0 || last_pos.column() > 0)
{
output.push_str(&lines[last_pos.row() - 1][last_pos.column() - 1..]);
output.push_str(&lines[last_pos.row() - 1][last_pos.column()..]);
output.push('\n');
}
if last_pos.row() < lines.len() {
@@ -133,8 +132,8 @@ mod tests {
let mut fixes = vec![Fix {
patch: Patch {
content: "Bar".to_string(),
location: Location::new(1, 9),
end_location: Location::new(1, 15),
location: Location::new(1, 8),
end_location: Location::new(1, 14),
},
applied: false,
}];
@@ -159,8 +158,8 @@ mod tests {
let mut fixes = vec![Fix {
patch: Patch {
content: "".to_string(),
location: Location::new(1, 8),
end_location: Location::new(1, 16),
location: Location::new(1, 7),
end_location: Location::new(1, 15),
},
applied: false,
}];
@@ -186,16 +185,16 @@ mod tests {
Fix {
patch: Patch {
content: "".to_string(),
location: Location::new(1, 8),
end_location: Location::new(1, 17),
location: Location::new(1, 7),
end_location: Location::new(1, 16),
},
applied: false,
},
Fix {
patch: Patch {
content: "".to_string(),
location: Location::new(1, 17),
end_location: Location::new(1, 24),
location: Location::new(1, 16),
end_location: Location::new(1, 23),
},
applied: false,
},
@@ -222,16 +221,16 @@ mod tests {
Fix {
patch: Patch {
content: "".to_string(),
location: Location::new(1, 8),
end_location: Location::new(1, 16),
location: Location::new(1, 7),
end_location: Location::new(1, 15),
},
applied: false,
},
Fix {
patch: Patch {
content: "ignored".to_string(),
location: Location::new(1, 10),
end_location: Location::new(1, 12),
location: Location::new(1, 9),
end_location: Location::new(1, 11),
},
applied: false,
},

View File

@@ -82,8 +82,8 @@ pub fn remove_stmt(stmt: &Stmt, parent: Option<&Stmt>, deleted: &[&Stmt]) -> Res
// Otherwise, nuke the entire line.
// TODO(charlie): This logic assumes that there are no multi-statement physical lines.
Ok(Fix::deletion(
Location::new(stmt.location.row(), 1),
Location::new(stmt.end_location.unwrap().row() + 1, 1),
Location::new(stmt.location.row(), 0),
Location::new(stmt.end_location.unwrap().row() + 1, 0),
))
}
}

View File

@@ -12,7 +12,7 @@ use rustpython_parser::ast::{
use rustpython_parser::parser;
use crate::ast::helpers::{extract_handler_names, match_name_or_attr, SubscriptKind};
use crate::ast::operations::{extract_all_names, SourceCodeLocator};
use crate::ast::operations::extract_all_names;
use crate::ast::relocate::relocate_expr;
use crate::ast::types::{
Binding, BindingContext, BindingKind, CheckLocator, FunctionScope, ImportKind, Range, Scope,
@@ -27,6 +27,7 @@ use crate::python::builtins::{BUILTINS, MAGIC_GLOBALS};
use crate::python::future::ALL_FEATURE_NAMES;
use crate::settings::types::PythonVersion;
use crate::settings::Settings;
use crate::source_code_locator::SourceCodeLocator;
use crate::visibility::{module_visibility, transition_scope, Modifier, Visibility, VisibleScope};
use crate::{
docstrings, flake8_bugbear, flake8_builtins, flake8_comprehensions, flake8_print, pep8_naming,
@@ -386,7 +387,7 @@ where
}
StmtKind::Import { names } => {
if self.settings.enabled.contains(&CheckCode::E402) {
if self.seen_import_boundary && stmt.location.column() == 1 {
if self.seen_import_boundary && stmt.location.column() == 0 {
self.checks.push(Check::new(
CheckKind::ModuleImportNotAtTopOfFile,
self.locate_check(Range::from_located(stmt)),
@@ -492,7 +493,7 @@ where
level,
} => {
if self.settings.enabled.contains(&CheckCode::E402) {
if self.seen_import_boundary && stmt.location.column() == 1 {
if self.seen_import_boundary && stmt.location.column() == 0 {
self.checks.push(Check::new(
CheckKind::ModuleImportNotAtTopOfFile,
self.locate_check(Range::from_located(stmt)),
@@ -1502,6 +1503,9 @@ where
self.checks
.extend(pyflakes::checks::duplicate_arguments(arguments));
}
if self.settings.enabled.contains(&CheckCode::B006) {
flake8_bugbear::plugins::mutable_argument_default(self, arguments)
}
// Bind, but intentionally avoid walking default expressions, as we handle them upstream.
for arg in &arguments.posonlyargs {

View File

@@ -94,8 +94,8 @@ pub fn check_lines(
let check = Check::new(
CheckKind::LineTooLong(line_length, settings.line_length),
Range {
location: Location::new(lineno + 1, 1),
end_location: Location::new(lineno + 1, line_length + 1),
location: Location::new(lineno + 1, 0),
end_location: Location::new(lineno + 1, line_length),
},
);
@@ -164,14 +164,14 @@ pub fn check_lines(
let mut check = Check::new(
CheckKind::UnusedNOQA(None),
Range {
location: Location::new(row + 1, start + 1),
end_location: Location::new(row + 1, end + 1),
location: Location::new(row + 1, start),
end_location: Location::new(row + 1, end),
},
);
if autofix.patch() {
check.amend(Fix::deletion(
Location::new(row + 1, start + 1),
Location::new(row + 1, lines[row].chars().count() + 1),
Location::new(row + 1, start),
Location::new(row + 1, lines[row].chars().count()),
));
}
line_checks.push(check);
@@ -192,21 +192,21 @@ pub fn check_lines(
let mut check = Check::new(
CheckKind::UnusedNOQA(Some(invalid_codes)),
Range {
location: Location::new(row + 1, start + 1),
end_location: Location::new(row + 1, end + 1),
location: Location::new(row + 1, start),
end_location: Location::new(row + 1, end),
},
);
if autofix.patch() {
if valid_codes.is_empty() {
check.amend(Fix::deletion(
Location::new(row + 1, start + 1),
Location::new(row + 1, lines[row].chars().count() + 1),
Location::new(row + 1, start),
Location::new(row + 1, lines[row].chars().count()),
));
} else {
check.amend(Fix::replacement(
format!(" # noqa: {}", valid_codes.join(", ")),
Location::new(row + 1, start + 1),
Location::new(row + 1, lines[row].chars().count() + 1),
Location::new(row + 1, start),
Location::new(row + 1, lines[row].chars().count()),
));
}
}

View File

@@ -2,9 +2,9 @@
use rustpython_parser::lexer::{LexResult, Tok};
use crate::ast::operations::SourceCodeLocator;
use crate::checks::{Check, CheckCode};
use crate::flake8_quotes::docstring_detection::StateMachine;
use crate::source_code_locator::SourceCodeLocator;
use crate::{flake8_quotes, pycodestyle, Settings};
pub fn check_tokens(

View File

@@ -78,6 +78,7 @@ pub enum CheckCode {
A003,
// flake8-bugbear
B002,
B006,
B007,
B011,
B013,
@@ -287,6 +288,7 @@ pub enum CheckKind {
BuiltinAttributeShadowing(String),
// flake8-bugbear
UnaryPrefixIncrement,
MutableArgumentDefault,
UnusedLoopControlVariable(String),
DoNotAssertFalse,
RedundantTupleInExceptionHandler(String),
@@ -465,6 +467,7 @@ impl CheckCode {
CheckCode::A003 => CheckKind::BuiltinAttributeShadowing("...".to_string()),
// flake8-bugbear
CheckCode::B002 => CheckKind::UnaryPrefixIncrement,
CheckCode::B006 => CheckKind::MutableArgumentDefault,
CheckCode::B007 => CheckKind::UnusedLoopControlVariable("i".to_string()),
CheckCode::B011 => CheckKind::DoNotAssertFalse,
CheckCode::B013 => {
@@ -655,6 +658,7 @@ impl CheckCode {
CheckCode::A002 => CheckCategory::Flake8Builtins,
CheckCode::A003 => CheckCategory::Flake8Builtins,
CheckCode::B002 => CheckCategory::Flake8Bugbear,
CheckCode::B006 => CheckCategory::Flake8Bugbear,
CheckCode::B007 => CheckCategory::Flake8Bugbear,
CheckCode::B011 => CheckCategory::Flake8Bugbear,
CheckCode::B013 => CheckCategory::Flake8Bugbear,
@@ -811,6 +815,7 @@ impl CheckKind {
CheckKind::BuiltinAttributeShadowing(_) => &CheckCode::A003,
// flake8-bugbear
CheckKind::UnaryPrefixIncrement => &CheckCode::B002,
CheckKind::MutableArgumentDefault => &CheckCode::B006,
CheckKind::UnusedLoopControlVariable(_) => &CheckCode::B007,
CheckKind::DoNotAssertFalse => &CheckCode::B011,
CheckKind::RedundantTupleInExceptionHandler(_) => &CheckCode::B013,
@@ -1050,7 +1055,7 @@ impl CheckKind {
format!("Local variable `{name}` is assigned to but never used")
}
CheckKind::YieldOutsideFunction => {
"`yield` or `yield from` statement outside of a function/method".to_string()
"`yield` or `yield from` statement outside of a function".to_string()
}
// pycodestyle warnings
CheckKind::NoNewLineAtEndOfFile => "No newline at end of file".to_string(),
@@ -1067,6 +1072,7 @@ impl CheckKind {
}
// flake8-bugbear
CheckKind::UnaryPrefixIncrement => "Python does not support the unary prefix increment. Writing `++n` is equivalent to `+(+(n))`, which equals `n`. You meant `n += 1`.".to_string(),
CheckKind::MutableArgumentDefault => "Do not use mutable data structures for argument defaults.".to_string(),
CheckKind::UnusedLoopControlVariable(name) => format!("Loop control variable `{name}` not used within the loop body. If this is intended, start the name with an underscore."),
CheckKind::DoNotAssertFalse => {
"Do not `assert False` (`python -O` removes these calls), raise `AssertionError()`"
@@ -1191,7 +1197,7 @@ impl CheckKind {
}
CheckKind::UselessMetaclassType => "`__metaclass__ = type` is implied".to_string(),
CheckKind::DeprecatedUnittestAlias(alias, target) => {
format!("`{}` is deprecated, use `{}` instead", alias, target)
format!("`{alias}` is deprecated, use `{target}` instead")
}
CheckKind::UselessObjectInheritance(name) => {
format!("Class `{name}` inherits from object")
@@ -1261,10 +1267,10 @@ impl CheckKind {
CheckKind::PublicNestedClass => "Missing docstring in public nested class".to_string(),
CheckKind::PublicInit => "Missing docstring in `__init__`".to_string(),
CheckKind::NoThisPrefix => {
"First word of the docstring should not be `This`".to_string()
"First word of the docstring should not be 'This'".to_string()
}
CheckKind::SkipDocstring => {
"Function decorated with @overload shouldn't contain a docstring".to_string()
"Function decorated with `@overload` shouldn't contain a docstring".to_string()
}
CheckKind::CapitalizeSectionName(name) => {
format!("Section name should be properly capitalized (\"{name}\")")

View File

@@ -17,6 +17,7 @@ pub enum CheckCodePrefix {
B0,
B00,
B002,
B006,
B007,
B01,
B011,
@@ -247,6 +248,7 @@ impl CheckCodePrefix {
CheckCodePrefix::A003 => vec![CheckCode::A003],
CheckCodePrefix::B => vec![
CheckCode::B002,
CheckCode::B006,
CheckCode::B007,
CheckCode::B011,
CheckCode::B013,
@@ -256,6 +258,7 @@ impl CheckCodePrefix {
],
CheckCodePrefix::B0 => vec![
CheckCode::B002,
CheckCode::B006,
CheckCode::B007,
CheckCode::B011,
CheckCode::B013,
@@ -263,8 +266,9 @@ impl CheckCodePrefix {
CheckCode::B017,
CheckCode::B025,
],
CheckCodePrefix::B00 => vec![CheckCode::B002, CheckCode::B007],
CheckCodePrefix::B00 => vec![CheckCode::B002, CheckCode::B006, CheckCode::B007],
CheckCodePrefix::B002 => vec![CheckCode::B002],
CheckCodePrefix::B006 => vec![CheckCode::B006],
CheckCodePrefix::B007 => vec![CheckCode::B007],
CheckCodePrefix::B01 => vec![
CheckCode::B011,
@@ -887,6 +891,7 @@ impl CheckCodePrefix {
CheckCodePrefix::B0 => PrefixSpecificity::Hundreds,
CheckCodePrefix::B00 => PrefixSpecificity::Tens,
CheckCodePrefix::B002 => PrefixSpecificity::Explicit,
CheckCodePrefix::B006 => PrefixSpecificity::Explicit,
CheckCodePrefix::B007 => PrefixSpecificity::Explicit,
CheckCodePrefix::B01 => PrefixSpecificity::Tens,
CheckCodePrefix::B011 => PrefixSpecificity::Explicit,

View File

@@ -28,7 +28,7 @@ pub fn leading_space(line: &str) -> String {
pub fn indentation<'a>(checker: &'a Checker, docstring: &Expr) -> &'a str {
let range = Range::from_located(docstring);
checker.locator.slice_source_code_range(&Range {
location: Location::new(range.location.row(), 1),
location: Location::new(range.location.row(), 0),
end_location: Location::new(range.location.row(), range.location.column()),
})
}

View File

@@ -2,6 +2,7 @@ pub use assert_false::assert_false;
pub use assert_raises_exception::assert_raises_exception;
pub use duplicate_exceptions::duplicate_exceptions;
pub use duplicate_exceptions::duplicate_handler_exceptions;
pub use mutable_argument_default::mutable_argument_default;
pub use redundant_tuple_in_exception_handler::redundant_tuple_in_exception_handler;
pub use unary_prefix_increment::unary_prefix_increment;
pub use unused_loop_control_variable::unused_loop_control_variable;
@@ -9,6 +10,7 @@ pub use unused_loop_control_variable::unused_loop_control_variable;
mod assert_false;
mod assert_raises_exception;
mod duplicate_exceptions;
mod mutable_argument_default;
mod redundant_tuple_in_exception_handler;
mod unary_prefix_increment;
mod unused_loop_control_variable;

View File

@@ -0,0 +1,62 @@
use rustpython_ast::{Arguments, ExprKind};
use crate::ast::types::{CheckLocator, Range};
use crate::check_ast::Checker;
use crate::checks::{Check, CheckKind};
/// B006
pub fn mutable_argument_default(checker: &mut Checker, arguments: &Arguments) {
for expr in arguments
.defaults
.iter()
.chain(arguments.kw_defaults.iter())
{
match &expr.node {
ExprKind::List { .. }
| ExprKind::Dict { .. }
| ExprKind::Set { .. }
| ExprKind::ListComp { .. }
| ExprKind::DictComp { .. }
| ExprKind::SetComp { .. } => {
checker.add_check(Check::new(
CheckKind::MutableArgumentDefault,
checker.locate_check(Range::from_located(expr)),
));
}
ExprKind::Call { func, .. } => match &func.node {
ExprKind::Name { id, .. }
if id == "dict"
|| id == "list"
|| id == "set"
|| id == "Counter"
|| id == "OrderedDict"
|| id == "defaultdict"
|| id == "deque" =>
{
checker.add_check(Check::new(
CheckKind::MutableArgumentDefault,
checker.locate_check(Range::from_located(expr)),
));
}
ExprKind::Attribute { value, attr, .. }
if (attr == "Counter"
|| attr == "OrderedDict"
|| attr == "defaultdict"
|| attr == "deque") =>
{
match &value.node {
ExprKind::Name { id, .. } if id == "collections" => {
checker.add_check(Check::new(
CheckKind::MutableArgumentDefault,
checker.locate_check(Range::from_located(expr)),
));
}
_ => {}
}
}
_ => {}
},
_ => {}
}
}
}

View File

@@ -1,9 +1,9 @@
use rustpython_ast::Location;
use crate::ast::operations::SourceCodeLocator;
use crate::ast::types::Range;
use crate::checks::{Check, CheckKind};
use crate::flake8_quotes::settings::{Quote, Settings};
use crate::source_code_locator::SourceCodeLocator;
fn good_single(quote: &Quote) -> char {
match quote {

View File

@@ -6,45 +6,45 @@ expression: checks
BadQuotesMultilineString: single
location:
row: 5
column: 1
column: 0
end_location:
row: 7
column: 4
column: 3
fix: ~
- kind:
BadQuotesMultilineString: single
location:
row: 16
column: 5
column: 4
end_location:
row: 18
column: 8
column: 7
fix: ~
- kind:
BadQuotesMultilineString: single
location:
row: 21
column: 21
column: 20
end_location:
row: 22
column: 38
column: 37
fix: ~
- kind:
BadQuotesMultilineString: single
location:
row: 30
column: 9
column: 8
end_location:
row: 32
column: 12
column: 11
fix: ~
- kind:
BadQuotesMultilineString: single
location:
row: 35
column: 13
column: 12
end_location:
row: 37
column: 16
column: 15
fix: ~

View File

@@ -6,18 +6,18 @@ expression: checks
BadQuotesMultilineString: single
location:
row: 3
column: 5
column: 4
end_location:
row: 3
column: 28
column: 27
fix: ~
- kind:
BadQuotesMultilineString: single
location:
row: 5
column: 23
column: 22
end_location:
row: 5
column: 44
column: 43
fix: ~

View File

@@ -6,45 +6,45 @@ expression: checks
BadQuotesMultilineString: single
location:
row: 3
column: 5
column: 4
end_location:
row: 3
column: 27
column: 26
fix: ~
- kind:
BadQuotesMultilineString: single
location:
row: 11
column: 5
column: 4
end_location:
row: 11
column: 27
column: 26
fix: ~
- kind:
BadQuotesMultilineString: single
location:
row: 15
column: 39
column: 38
end_location:
row: 17
column: 3
fix: ~
- kind:
BadQuotesMultilineString: single
location:
row: 17
column: 4
fix: ~
- kind:
BadQuotesMultilineString: single
location:
row: 17
column: 5
end_location:
row: 17
column: 20
column: 19
fix: ~
- kind:
BadQuotesMultilineString: single
location:
row: 21
column: 5
column: 4
end_location:
row: 21
column: 28
column: 27
fix: ~

View File

@@ -6,18 +6,18 @@ expression: checks
BadQuotesMultilineString: single
location:
row: 4
column: 1
column: 0
end_location:
row: 6
column: 4
column: 3
fix: ~
- kind:
BadQuotesMultilineString: single
location:
row: 9
column: 1
column: 0
end_location:
row: 11
column: 4
column: 3
fix: ~

View File

@@ -6,18 +6,18 @@ expression: checks
BadQuotesMultilineString: single
location:
row: 2
column: 1
column: 0
end_location:
row: 2
column: 32
column: 31
fix: ~
- kind:
BadQuotesMultilineString: single
location:
row: 6
column: 1
column: 0
end_location:
row: 6
column: 32
column: 31
fix: ~

View File

@@ -6,27 +6,27 @@ expression: checks
BadQuotesDocstring: double
location:
row: 1
column: 1
column: 0
end_location:
row: 3
column: 4
column: 3
fix: ~
- kind:
BadQuotesDocstring: double
location:
row: 14
column: 5
column: 4
end_location:
row: 16
column: 8
column: 7
fix: ~
- kind:
BadQuotesDocstring: double
location:
row: 26
column: 9
column: 8
end_location:
row: 28
column: 12
column: 11
fix: ~

View File

@@ -6,27 +6,27 @@ expression: checks
BadQuotesDocstring: double
location:
row: 2
column: 5
column: 4
end_location:
row: 2
column: 54
fix: ~
- kind:
BadQuotesDocstring: double
location:
row: 6
column: 9
end_location:
row: 6
column: 58
fix: ~
- kind:
BadQuotesDocstring: double
location:
row: 9
column: 29
end_location:
row: 9
column: 53
fix: ~
- kind:
BadQuotesDocstring: double
location:
row: 6
column: 8
end_location:
row: 6
column: 57
fix: ~
- kind:
BadQuotesDocstring: double
location:
row: 9
column: 28
end_location:
row: 9
column: 52
fix: ~

View File

@@ -6,18 +6,18 @@ expression: checks
BadQuotesDocstring: double
location:
row: 2
column: 5
column: 4
end_location:
row: 2
column: 57
column: 56
fix: ~
- kind:
BadQuotesDocstring: double
location:
row: 8
column: 5
column: 4
end_location:
row: 10
column: 8
column: 7
fix: ~

View File

@@ -6,9 +6,9 @@ expression: checks
BadQuotesDocstring: double
location:
row: 1
column: 1
column: 0
end_location:
row: 3
column: 4
column: 3
fix: ~

View File

@@ -6,9 +6,9 @@ expression: checks
BadQuotesDocstring: double
location:
row: 1
column: 1
column: 0
end_location:
row: 1
column: 50
column: 49
fix: ~

View File

@@ -6,18 +6,18 @@ expression: checks
BadQuotesInlineString: single
location:
row: 1
column: 25
column: 24
end_location:
row: 1
column: 46
column: 45
fix: ~
- kind:
BadQuotesInlineString: single
location:
row: 2
column: 25
column: 24
end_location:
row: 2
column: 47
column: 46
fix: ~

View File

@@ -5,9 +5,9 @@ expression: checks
- kind: AvoidQuoteEscape
location:
row: 1
column: 26
column: 25
end_location:
row: 1
column: 48
column: 47
fix: ~

View File

@@ -6,9 +6,9 @@ expression: checks
BadQuotesMultilineString: single
location:
row: 1
column: 5
column: 4
end_location:
row: 3
column: 13
column: 12
fix: ~

View File

@@ -6,27 +6,27 @@ expression: checks
BadQuotesDocstring: single
location:
row: 1
column: 1
column: 0
end_location:
row: 3
column: 4
column: 3
fix: ~
- kind:
BadQuotesDocstring: single
location:
row: 12
column: 5
column: 4
end_location:
row: 14
column: 8
column: 7
fix: ~
- kind:
BadQuotesDocstring: single
location:
row: 24
column: 9
column: 8
end_location:
row: 26
column: 12
column: 11
fix: ~

View File

@@ -6,27 +6,27 @@ expression: checks
BadQuotesDocstring: single
location:
row: 2
column: 5
column: 4
end_location:
row: 2
column: 54
fix: ~
- kind:
BadQuotesDocstring: single
location:
row: 6
column: 9
end_location:
row: 6
column: 58
fix: ~
- kind:
BadQuotesDocstring: single
location:
row: 9
column: 29
end_location:
row: 9
column: 53
fix: ~
- kind:
BadQuotesDocstring: single
location:
row: 6
column: 8
end_location:
row: 6
column: 57
fix: ~
- kind:
BadQuotesDocstring: single
location:
row: 9
column: 28
end_location:
row: 9
column: 52
fix: ~

View File

@@ -6,18 +6,18 @@ expression: checks
BadQuotesDocstring: single
location:
row: 2
column: 5
column: 4
end_location:
row: 2
column: 57
column: 56
fix: ~
- kind:
BadQuotesDocstring: single
location:
row: 8
column: 5
column: 4
end_location:
row: 10
column: 8
column: 7
fix: ~

View File

@@ -6,9 +6,9 @@ expression: checks
BadQuotesDocstring: single
location:
row: 1
column: 1
column: 0
end_location:
row: 3
column: 4
column: 3
fix: ~

View File

@@ -6,9 +6,9 @@ expression: checks
BadQuotesDocstring: single
location:
row: 1
column: 1
column: 0
end_location:
row: 1
column: 50
column: 49
fix: ~

View File

@@ -6,54 +6,54 @@ expression: checks
BadQuotesMultilineString: double
location:
row: 5
column: 1
column: 0
end_location:
row: 7
column: 4
column: 3
fix: ~
- kind:
BadQuotesMultilineString: double
location:
row: 11
column: 21
column: 20
end_location:
row: 13
column: 4
column: 3
fix: ~
- kind:
BadQuotesMultilineString: double
location:
row: 18
column: 5
column: 4
end_location:
row: 20
column: 8
column: 7
fix: ~
- kind:
BadQuotesMultilineString: double
location:
row: 23
column: 21
column: 20
end_location:
row: 24
column: 38
column: 37
fix: ~
- kind:
BadQuotesMultilineString: double
location:
row: 32
column: 9
column: 8
end_location:
row: 34
column: 12
column: 11
fix: ~
- kind:
BadQuotesMultilineString: double
location:
row: 37
column: 13
column: 12
end_location:
row: 39
column: 16
column: 15
fix: ~

View File

@@ -6,18 +6,18 @@ expression: checks
BadQuotesMultilineString: double
location:
row: 3
column: 5
column: 4
end_location:
row: 3
column: 28
column: 27
fix: ~
- kind:
BadQuotesMultilineString: double
location:
row: 5
column: 23
column: 22
end_location:
row: 5
column: 44
column: 43
fix: ~

View File

@@ -6,45 +6,45 @@ expression: checks
BadQuotesMultilineString: double
location:
row: 3
column: 5
column: 4
end_location:
row: 3
column: 27
column: 26
fix: ~
- kind:
BadQuotesMultilineString: double
location:
row: 11
column: 5
column: 4
end_location:
row: 11
column: 27
column: 26
fix: ~
- kind:
BadQuotesMultilineString: double
location:
row: 15
column: 39
column: 38
end_location:
row: 17
column: 3
fix: ~
- kind:
BadQuotesMultilineString: double
location:
row: 17
column: 4
fix: ~
- kind:
BadQuotesMultilineString: double
location:
row: 17
column: 5
end_location:
row: 17
column: 20
column: 19
fix: ~
- kind:
BadQuotesMultilineString: double
location:
row: 21
column: 5
column: 4
end_location:
row: 21
column: 28
column: 27
fix: ~

View File

@@ -6,18 +6,18 @@ expression: checks
BadQuotesMultilineString: double
location:
row: 4
column: 1
column: 0
end_location:
row: 6
column: 4
column: 3
fix: ~
- kind:
BadQuotesMultilineString: double
location:
row: 9
column: 1
column: 0
end_location:
row: 11
column: 4
column: 3
fix: ~

View File

@@ -6,18 +6,18 @@ expression: checks
BadQuotesMultilineString: double
location:
row: 2
column: 1
column: 0
end_location:
row: 2
column: 32
column: 31
fix: ~
- kind:
BadQuotesMultilineString: double
location:
row: 6
column: 1
column: 0
end_location:
row: 6
column: 32
column: 31
fix: ~

View File

@@ -6,18 +6,18 @@ expression: checks
BadQuotesInlineString: double
location:
row: 1
column: 25
column: 24
end_location:
row: 1
column: 46
column: 45
fix: ~
- kind:
BadQuotesInlineString: double
location:
row: 2
column: 25
column: 24
end_location:
row: 2
column: 47
column: 46
fix: ~

View File

@@ -5,9 +5,9 @@ expression: checks
- kind: AvoidQuoteEscape
location:
row: 1
column: 26
column: 25
end_location:
row: 1
column: 48
column: 47
fix: ~

View File

@@ -6,9 +6,9 @@ expression: checks
BadQuotesMultilineString: double
location:
row: 1
column: 5
column: 4
end_location:
row: 3
column: 13
column: 12
fix: ~

View File

@@ -10,12 +10,12 @@ use settings::pyproject;
use settings::Settings;
use crate::autofix::fixer::Mode;
use crate::checks::Check;
use crate::linter::{check_path, tokenize};
use crate::message::Message;
use crate::settings::configuration::Configuration;
mod ast;
mod autofix;
pub mod autofix;
pub mod cache;
pub mod check_ast;
mod check_lines;
@@ -44,10 +44,11 @@ mod pyflakes;
mod python;
mod pyupgrade;
pub mod settings;
pub mod source_code_locator;
pub mod visibility;
/// Run ruff over Python source code directly.
pub fn check(path: &Path, contents: &str) -> Result<Vec<Message>> {
pub fn check(path: &Path, contents: &str) -> Result<Vec<Check>> {
// Find the project root and pyproject.toml.
let project_root = pyproject::find_project_root(&[path.to_path_buf()]);
match &project_root {
@@ -79,17 +80,5 @@ pub fn check(path: &Path, contents: &str) -> Result<Vec<Message>> {
&Mode::None,
)?;
// Convert to messages.
let messages: Vec<Message> = checks
.into_iter()
.map(|check| Message {
kind: check.kind,
fixed: check.fix.map(|fix| fix.applied).unwrap_or_default(),
location: check.location,
end_location: check.end_location,
filename: path.to_string_lossy().to_string(),
})
.collect();
Ok(messages)
Ok(checks)
}

View File

@@ -6,10 +6,12 @@ use std::path::Path;
use anyhow::Result;
#[cfg(not(target_family = "wasm"))]
use log::debug;
use rustpython_ast::{Mod, Suite};
use rustpython_parser::error::ParseError;
use rustpython_parser::lexer::LexResult;
use rustpython_parser::parser::Mode;
use rustpython_parser::{lexer, parser};
use crate::ast::operations::SourceCodeLocator;
use crate::ast::types::Range;
use crate::autofix::fixer;
use crate::autofix::fixer::fix_file;
@@ -21,6 +23,7 @@ use crate::code_gen::SourceGenerator;
use crate::message::Message;
use crate::noqa::add_noqa;
use crate::settings::Settings;
use crate::source_code_locator::SourceCodeLocator;
use crate::{cache, fs, noqa};
/// Collect tokens up to and including the first error.
@@ -36,6 +39,17 @@ pub(crate) fn tokenize(contents: &str) -> Vec<LexResult> {
tokens
}
/// Parse a full Python program from its tokens.
pub(crate) fn parse_program_tokens(
lxr: Vec<LexResult>,
source_path: &str,
) -> Result<Suite, ParseError> {
parser::parse_tokens(lxr, Mode::Module, source_path).map(|top| match top {
Mod::Module { body, .. } => body,
_ => unreachable!(),
})
}
pub(crate) fn check_path(
path: &Path,
contents: &str,
@@ -65,7 +79,7 @@ pub(crate) fn check_path(
.iter()
.any(|check_code| matches!(check_code.lint_source(), LintSource::AST))
{
match parser::parse_program_tokens(tokens, "<filename>") {
match parse_program_tokens(tokens, "<filename>") {
Ok(python_ast) => {
checks.extend(check_ast(&python_ast, &locator, settings, autofix, path))
}
@@ -220,7 +234,7 @@ pub fn autoformat_path(path: &Path) -> Result<()> {
let tokens: Vec<LexResult> = tokenize(&contents);
// Generate the AST.
let python_ast = parser::parse_program_tokens(tokens, "<filename>")?;
let python_ast = parse_program_tokens(tokens, "<filename>")?;
let mut generator: SourceGenerator = Default::default();
generator.unparse_suite(&python_ast)?;
write(path, generator.generate()?)?;
@@ -256,6 +270,7 @@ mod tests {
#[test_case(CheckCode::A002, Path::new("A002.py"); "A002")]
#[test_case(CheckCode::A003, Path::new("A003.py"); "A003")]
#[test_case(CheckCode::B002, Path::new("B002.py"); "B002")]
#[test_case(CheckCode::B006, Path::new("B006_B008.py"); "B006")]
#[test_case(CheckCode::B007, Path::new("B007.py"); "B007")]
#[test_case(CheckCode::B011, Path::new("B011.py"); "B011")]
#[test_case(CheckCode::B013, Path::new("B013.py"); "B013")]

View File

@@ -246,8 +246,8 @@ ghi
let checks = vec![Check::new(
CheckKind::UnusedVariable("x".to_string()),
Range {
location: Location::new(1, 1),
end_location: Location::new(1, 1),
location: Location::new(1, 0),
end_location: Location::new(1, 0),
},
)];
let contents = "x = 1";
@@ -260,15 +260,15 @@ ghi
Check::new(
CheckKind::AmbiguousVariableName("x".to_string()),
Range {
location: Location::new(1, 1),
end_location: Location::new(1, 1),
location: Location::new(1, 0),
end_location: Location::new(1, 0),
},
),
Check::new(
CheckKind::UnusedVariable("x".to_string()),
Range {
location: Location::new(1, 1),
end_location: Location::new(1, 1),
location: Location::new(1, 0),
end_location: Location::new(1, 0),
},
),
];
@@ -282,15 +282,15 @@ ghi
Check::new(
CheckKind::AmbiguousVariableName("x".to_string()),
Range {
location: Location::new(1, 1),
end_location: Location::new(1, 1),
location: Location::new(1, 0),
end_location: Location::new(1, 0),
},
),
Check::new(
CheckKind::UnusedVariable("x".to_string()),
Range {
location: Location::new(1, 1),
end_location: Location::new(1, 1),
location: Location::new(1, 0),
end_location: Location::new(1, 0),
},
),
];

View File

@@ -2,9 +2,9 @@ use itertools::izip;
use rustpython_ast::Location;
use rustpython_parser::ast::{Cmpop, Constant, Expr, ExprKind, Unaryop};
use crate::ast::operations::SourceCodeLocator;
use crate::ast::types::{CheckLocator, Range};
use crate::checks::{Check, CheckKind, RejectedCmpop};
use crate::source_code_locator::SourceCodeLocator;
fn is_ambiguous_name(name: &str) -> bool {
name == "l" || name == "I" || name == "O"

View File

@@ -35,8 +35,8 @@ pub fn not_missing(
checker.add_check(Check::new(
CheckKind::PublicModule,
Range {
location: Location::new(1, 1),
end_location: Location::new(1, 1),
location: Location::new(1, 0),
end_location: Location::new(1, 0),
},
));
}
@@ -47,8 +47,8 @@ pub fn not_missing(
checker.add_check(Check::new(
CheckKind::PublicPackage,
Range {
location: Location::new(1, 1),
end_location: Location::new(1, 1),
location: Location::new(1, 0),
end_location: Location::new(1, 0),
},
));
}
@@ -181,8 +181,8 @@ pub fn blank_before_after_function(checker: &mut Checker, definition: &Definitio
if checker.patch() {
// Delete the blank line before the docstring.
check.amend(Fix::deletion(
Location::new(docstring.location.row() - blank_lines_before, 1),
Location::new(docstring.location.row(), 1),
Location::new(docstring.location.row() - blank_lines_before, 0),
Location::new(docstring.location.row(), 0),
));
}
checker.add_check(check);
@@ -208,15 +208,13 @@ pub fn blank_before_after_function(checker: &mut Checker, definition: &Definitio
.skip(1)
.take_while(|line| line.trim().is_empty())
.count();
// Report a D202 violation if the docstring is followed by a blank line and the
// blank line is not itself followed by an inner function or class.
let expected_blank_lines_after =
if INNER_FUNCTION_OR_CLASS_REGEX.is_match(after) {
1
} else {
0
};
if blank_lines_after != expected_blank_lines_after {
// Avoid D202 violations for blank lines followed by inner functions or classes.
if blank_lines_after == 1 && INNER_FUNCTION_OR_CLASS_REGEX.is_match(after) {
return;
}
if blank_lines_after != 0 {
let mut check = Check::new(
CheckKind::NoBlankLineAfterFunction(blank_lines_after),
Range::from_located(docstring),
@@ -224,11 +222,8 @@ pub fn blank_before_after_function(checker: &mut Checker, definition: &Definitio
if checker.patch() {
// Delete the blank line after the docstring.
check.amend(Fix::deletion(
Location::new(
docstring.location.row() + 1 + expected_blank_lines_after,
1,
),
Location::new(docstring.location.row() + 1 + blank_lines_after, 1),
Location::new(docstring.location.row() + 1, 0),
Location::new(docstring.location.row() + 1 + blank_lines_after, 0),
));
}
checker.add_check(check);
@@ -273,8 +268,8 @@ pub fn blank_before_after_class(checker: &mut Checker, definition: &Definition)
if checker.patch() {
// Delete the blank line before the class.
check.amend(Fix::deletion(
Location::new(docstring.location.row() - blank_lines_before, 1),
Location::new(docstring.location.row(), 1),
Location::new(docstring.location.row() - blank_lines_before, 0),
Location::new(docstring.location.row(), 0),
));
}
checker.add_check(check);
@@ -290,8 +285,8 @@ pub fn blank_before_after_class(checker: &mut Checker, definition: &Definition)
// Insert one blank line before the class.
check.amend(Fix::replacement(
"\n".to_string(),
Location::new(docstring.location.row() - blank_lines_before, 1),
Location::new(docstring.location.row(), 1),
Location::new(docstring.location.row() - blank_lines_before, 0),
Location::new(docstring.location.row(), 0),
));
}
checker.add_check(check);
@@ -327,10 +322,10 @@ pub fn blank_before_after_class(checker: &mut Checker, definition: &Definition)
// Insert a blank line before the class (replacing any existing lines).
check.amend(Fix::replacement(
"\n".to_string(),
Location::new(docstring.end_location.unwrap().row() + 1, 1),
Location::new(docstring.end_location.unwrap().row() + 1, 0),
Location::new(
docstring.end_location.unwrap().row() + 1 + blank_lines_after,
1,
0,
),
));
}
@@ -369,8 +364,8 @@ pub fn blank_after_summary(checker: &mut Checker, definition: &Definition) {
// Insert one blank line after the summary (replacing any existing lines).
check.amend(Fix::replacement(
"\n".to_string(),
Location::new(docstring.location.row() + 1, 1),
Location::new(docstring.location.row() + 1 + blanks_count, 1),
Location::new(docstring.location.row() + 1, 0),
Location::new(docstring.location.row() + 1 + blanks_count, 0),
));
}
checker.add_check(check);
@@ -404,7 +399,8 @@ pub fn indent(checker: &mut Checker, definition: &Definition) {
// Omit empty lines, except for the last line, which is non-empty by way of
// containing the closing quotation marks.
if i < lines.len() - 1 && lines[i].trim().is_empty() {
let is_blank = lines[i].trim().is_empty();
if i < lines.len() - 1 && is_blank {
continue;
}
@@ -416,19 +412,19 @@ pub fn indent(checker: &mut Checker, definition: &Definition) {
if checker.settings.enabled.contains(&CheckCode::D207) {
// We report under-indentation on every line. This isn't great, but enables
// autofix.
if line_indent.len() < docstring_indent.len() {
if !is_blank && line_indent.len() < docstring_indent.len() {
let mut check = Check::new(
CheckKind::NoUnderIndentation,
Range {
location: Location::new(docstring.location.row() + i, 1),
end_location: Location::new(docstring.location.row() + i, 1),
location: Location::new(docstring.location.row() + i, 0),
end_location: Location::new(docstring.location.row() + i, 0),
},
);
if checker.patch() {
check.amend(Fix::replacement(
helpers::clean(&docstring_indent),
Location::new(docstring.location.row() + i, 1),
Location::new(docstring.location.row() + i, 1 + line_indent.len()),
Location::new(docstring.location.row() + i, 0),
Location::new(docstring.location.row() + i, line_indent.len()),
));
}
checker.add_check(check);
@@ -469,18 +465,15 @@ pub fn indent(checker: &mut Checker, definition: &Definition) {
let mut check = Check::new(
CheckKind::NoOverIndentation,
Range {
location: Location::new(docstring.location.row() + i, 1),
end_location: Location::new(docstring.location.row() + i, 1),
location: Location::new(docstring.location.row() + i, 0),
end_location: Location::new(docstring.location.row() + i, 0),
},
);
if checker.patch() {
check.amend(Fix::replacement(
helpers::clean(&docstring_indent),
Location::new(docstring.location.row() + i, 1),
Location::new(
docstring.location.row() + i,
1 + line_indent.len(),
),
Location::new(docstring.location.row() + i, 0),
Location::new(docstring.location.row() + i, line_indent.len()),
));
}
checker.add_check(check);
@@ -496,15 +489,15 @@ pub fn indent(checker: &mut Checker, definition: &Definition) {
let mut check = Check::new(
CheckKind::NoOverIndentation,
Range {
location: Location::new(docstring.location.row() + i, 1),
end_location: Location::new(docstring.location.row() + i, 1),
location: Location::new(docstring.location.row() + i, 0),
end_location: Location::new(docstring.location.row() + i, 0),
},
);
if checker.patch() {
check.amend(Fix::replacement(
helpers::clean(&docstring_indent),
Location::new(docstring.location.row() + i, 1),
Location::new(docstring.location.row() + i, 1 + line_indent.len()),
Location::new(docstring.location.row() + i, 0),
Location::new(docstring.location.row() + i, line_indent.len()),
));
}
checker.add_check(check);
@@ -925,7 +918,7 @@ fn blanks_and_section_underline(
);
check.amend(Fix::insertion(
content,
Location::new(docstring.location.row() + context.original_index + 1, 1),
Location::new(docstring.location.row() + context.original_index + 1, 0),
));
}
checker.add_check(check);
@@ -959,7 +952,7 @@ fn blanks_and_section_underline(
);
check.amend(Fix::insertion(
content,
Location::new(docstring.location.row() + context.original_index + 1, 1),
Location::new(docstring.location.row() + context.original_index + 1, 0),
));
}
checker.add_check(check);
@@ -975,13 +968,13 @@ fn blanks_and_section_underline(
if checker.patch() {
// Delete any blank lines between the header and content.
check.amend(Fix::deletion(
Location::new(docstring.location.row() + context.original_index + 1, 1),
Location::new(docstring.location.row() + context.original_index + 1, 0),
Location::new(
docstring.location.row()
+ context.original_index
+ 1
+ blank_lines_after_header,
1,
0,
),
));
}
@@ -998,13 +991,13 @@ fn blanks_and_section_underline(
if checker.patch() {
// Delete any blank lines between the header and the underline.
check.amend(Fix::deletion(
Location::new(docstring.location.row() + context.original_index + 1, 1),
Location::new(docstring.location.row() + context.original_index + 1, 0),
Location::new(
docstring.location.row()
+ context.original_index
+ 1
+ blank_lines_after_header,
1,
0,
),
));
}
@@ -1040,7 +1033,7 @@ fn blanks_and_section_underline(
+ context.original_index
+ 1
+ blank_lines_after_header,
1,
0,
),
Location::new(
docstring.location.row()
@@ -1048,7 +1041,7 @@ fn blanks_and_section_underline(
+ 1
+ blank_lines_after_header
+ 1,
1,
0,
),
));
};
@@ -1073,7 +1066,7 @@ fn blanks_and_section_underline(
+ context.original_index
+ 1
+ blank_lines_after_header,
1,
0,
),
Location::new(
docstring.location.row()
@@ -1121,7 +1114,7 @@ fn blanks_and_section_underline(
+ context.original_index
+ 1
+ line_after_dashes_index,
1,
0,
),
Location::new(
docstring.location.row()
@@ -1129,7 +1122,7 @@ fn blanks_and_section_underline(
+ 1
+ line_after_dashes_index
+ blank_lines_after_dashes,
1,
0,
),
));
}
@@ -1183,11 +1176,11 @@ fn common_section(
capitalized_section_name,
Location::new(
docstring.location.row() + context.original_index,
1 + section_name_start,
*section_name_start,
),
Location::new(
docstring.location.row() + context.original_index,
1 + section_name_start + section_name_length,
section_name_start + section_name_length,
),
))
}
@@ -1209,10 +1202,10 @@ fn common_section(
// Replace the existing indentation with whitespace of the appropriate length.
check.amend(Fix::replacement(
helpers::clean(&indentation),
Location::new(docstring.location.row() + context.original_index, 1),
Location::new(docstring.location.row() + context.original_index, 0),
Location::new(
docstring.location.row() + context.original_index,
1 + leading_space.len(),
leading_space.len(),
),
));
};
@@ -1241,7 +1234,7 @@ fn common_section(
+ context.original_index
+ 1
+ context.following_lines.len(),
1,
0,
),
));
}
@@ -1262,7 +1255,7 @@ fn common_section(
+ context.original_index
+ 1
+ context.following_lines.len(),
1,
0,
),
));
}
@@ -1281,7 +1274,7 @@ fn common_section(
// Add a blank line before the section.
check.amend(Fix::insertion(
"\n".to_string(),
Location::new(docstring.location.row() + context.original_index, 1),
Location::new(docstring.location.row() + context.original_index, 0),
));
}
checker.add_check(check)
@@ -1448,11 +1441,11 @@ fn numpy_section(checker: &mut Checker, definition: &Definition, context: &Secti
check.amend(Fix::deletion(
Location::new(
docstring.location.row() + context.original_index,
1 + suffix_start,
*suffix_start,
),
Location::new(
docstring.location.row() + context.original_index,
1 + suffix_start + suffix_length,
suffix_start + suffix_length,
),
));
}
@@ -1498,11 +1491,11 @@ fn google_section(checker: &mut Checker, definition: &Definition, context: &Sect
":".to_string(),
Location::new(
docstring.location.row() + context.original_index,
1 + suffix_start,
*suffix_start,
),
Location::new(
docstring.location.row() + context.original_index,
1 + suffix_start + suffix_length,
suffix_start + suffix_length,
),
));
}

View File

@@ -2,10 +2,10 @@ use anyhow::Result;
use libcst_native::{Codegen, ImportNames, NameOrAttribute, SmallStatement, Statement};
use rustpython_ast::Stmt;
use crate::ast::operations::SourceCodeLocator;
use crate::ast::types::Range;
use crate::autofix::{helpers, Fix};
use crate::cst::helpers::compose_module_path;
use crate::source_code_locator::SourceCodeLocator;
/// Generate a Fix to remove any unused imports from an `import` statement.
pub fn remove_unused_imports(

View File

@@ -4,9 +4,9 @@ use rustpython_parser::lexer;
use rustpython_parser::lexer::Tok;
use crate::ast::helpers;
use crate::ast::operations::SourceCodeLocator;
use crate::ast::types::Range;
use crate::autofix::Fix;
use crate::source_code_locator::SourceCodeLocator;
/// Generate a fix to remove a base from a ClassDef statement.
pub fn remove_class_def_base(

View File

@@ -6,162 +6,162 @@ expression: checks
BuiltinVariableShadowing: sum
location:
row: 1
column: 1
column: 0
end_location:
row: 1
column: 19
column: 18
fix: ~
- kind:
BuiltinVariableShadowing: int
location:
row: 2
column: 1
column: 0
end_location:
row: 2
column: 30
column: 29
fix: ~
- kind:
BuiltinVariableShadowing: print
location:
row: 4
column: 1
column: 0
end_location:
row: 4
column: 6
column: 5
fix: ~
- kind:
BuiltinVariableShadowing: copyright
location:
row: 5
column: 1
column: 0
end_location:
row: 5
column: 10
column: 9
fix: ~
- kind:
BuiltinVariableShadowing: complex
location:
row: 6
column: 2
column: 1
end_location:
row: 6
column: 14
column: 13
fix: ~
- kind:
BuiltinVariableShadowing: float
location:
row: 7
column: 1
column: 0
end_location:
row: 7
column: 6
column: 5
fix: ~
- kind:
BuiltinVariableShadowing: object
location:
row: 7
column: 9
column: 8
end_location:
row: 7
column: 15
column: 14
fix: ~
- kind:
BuiltinVariableShadowing: min
location:
row: 8
column: 1
column: 0
end_location:
row: 8
column: 4
column: 3
fix: ~
- kind:
BuiltinVariableShadowing: max
location:
row: 8
column: 6
column: 5
end_location:
row: 8
column: 9
column: 8
fix: ~
- kind:
BuiltinVariableShadowing: bytes
location:
row: 10
column: 1
column: 0
end_location:
row: 13
column: 1
column: 0
fix: ~
- kind:
BuiltinVariableShadowing: slice
location:
row: 13
column: 1
column: 0
end_location:
row: 16
column: 1
column: 0
fix: ~
- kind:
BuiltinVariableShadowing: ValueError
location:
row: 18
column: 1
column: 0
end_location:
row: 21
column: 1
column: 0
fix: ~
- kind:
BuiltinVariableShadowing: memoryview
location:
row: 21
column: 5
column: 4
end_location:
row: 21
column: 15
column: 14
fix: ~
- kind:
BuiltinVariableShadowing: bytearray
location:
row: 21
column: 18
column: 17
end_location:
row: 21
column: 27
column: 26
fix: ~
- kind:
BuiltinVariableShadowing: str
location:
row: 24
column: 22
column: 21
end_location:
row: 24
column: 25
column: 24
fix: ~
- kind:
BuiltinVariableShadowing: all
location:
row: 24
column: 45
column: 44
end_location:
row: 24
column: 48
column: 47
fix: ~
- kind:
BuiltinVariableShadowing: any
location:
row: 24
column: 50
column: 49
end_location:
row: 24
column: 53
column: 52
fix: ~
- kind:
BuiltinVariableShadowing: sum
location:
row: 27
column: 8
column: 7
end_location:
row: 27
column: 11
column: 10
fix: ~

View File

@@ -6,63 +6,63 @@ expression: checks
BuiltinArgumentShadowing: str
location:
row: 1
column: 11
column: 10
end_location:
row: 1
column: 14
column: 13
fix: ~
- kind:
BuiltinArgumentShadowing: type
location:
row: 1
column: 19
column: 18
end_location:
row: 1
column: 23
column: 22
fix: ~
- kind:
BuiltinArgumentShadowing: complex
location:
row: 1
column: 26
column: 25
end_location:
row: 1
column: 33
column: 32
fix: ~
- kind:
BuiltinArgumentShadowing: Exception
location:
row: 1
column: 35
column: 34
end_location:
row: 1
column: 44
column: 43
fix: ~
- kind:
BuiltinArgumentShadowing: getattr
location:
row: 1
column: 48
column: 47
end_location:
row: 1
column: 55
column: 54
fix: ~
- kind:
BuiltinArgumentShadowing: bytes
location:
row: 5
column: 17
column: 16
end_location:
row: 5
column: 22
column: 21
fix: ~
- kind:
BuiltinArgumentShadowing: float
location:
row: 9
column: 16
column: 15
end_location:
row: 9
column: 21
column: 20
fix: ~

View File

@@ -6,18 +6,18 @@ expression: checks
BuiltinAttributeShadowing: ImportError
location:
row: 2
column: 5
column: 4
end_location:
row: 2
column: 16
column: 15
fix: ~
- kind:
BuiltinAttributeShadowing: str
location:
row: 7
column: 5
column: 4
end_location:
row: 9
column: 1
column: 0
fix: ~

View File

@@ -5,17 +5,17 @@ expression: checks
- kind: UnaryPrefixIncrement
location:
row: 15
column: 9
column: 8
end_location:
row: 15
column: 12
column: 11
fix: ~
- kind: UnaryPrefixIncrement
location:
row: 20
column: 12
column: 11
end_location:
row: 20
column: 15
column: 14
fix: ~

View File

@@ -0,0 +1,93 @@
---
source: src/linter.rs
expression: checks
---
- kind: MutableArgumentDefault
location:
row: 60
column: 24
end_location:
row: 60
column: 33
fix: ~
- kind: MutableArgumentDefault
location:
row: 64
column: 29
end_location:
row: 64
column: 31
fix: ~
- kind: MutableArgumentDefault
location:
row: 68
column: 19
end_location:
row: 68
column: 24
fix: ~
- kind: MutableArgumentDefault
location:
row: 72
column: 19
end_location:
row: 72
column: 44
fix: ~
- kind: MutableArgumentDefault
location:
row: 76
column: 31
end_location:
row: 76
column: 56
fix: ~
- kind: MutableArgumentDefault
location:
row: 80
column: 25
end_location:
row: 80
column: 44
fix: ~
- kind: MutableArgumentDefault
location:
row: 85
column: 45
end_location:
row: 85
column: 69
fix: ~
- kind: MutableArgumentDefault
location:
row: 89
column: 45
end_location:
row: 89
column: 72
fix: ~
- kind: MutableArgumentDefault
location:
row: 93
column: 44
end_location:
row: 93
column: 68
fix: ~
- kind: MutableArgumentDefault
location:
row: 97
column: 32
end_location:
row: 97
column: 34
fix: ~
- kind: MutableArgumentDefault
location:
row: 170
column: 19
end_location:
row: 170
column: 48
fix: ~

View File

@@ -6,72 +6,72 @@ expression: checks
UnusedLoopControlVariable: i
location:
row: 6
column: 5
column: 4
end_location:
row: 6
column: 6
column: 5
fix:
patch:
content: _i
location:
row: 6
column: 5
column: 4
end_location:
row: 6
column: 6
column: 5
applied: false
- kind:
UnusedLoopControlVariable: k
location:
row: 18
column: 13
column: 12
end_location:
row: 18
column: 14
column: 13
fix:
patch:
content: _k
location:
row: 18
column: 13
column: 12
end_location:
row: 18
column: 14
column: 13
applied: false
- kind:
UnusedLoopControlVariable: i
location:
row: 30
column: 5
column: 4
end_location:
row: 30
column: 6
column: 5
fix:
patch:
content: _i
location:
row: 30
column: 5
column: 4
end_location:
row: 30
column: 6
column: 5
applied: false
- kind:
UnusedLoopControlVariable: k
location:
row: 30
column: 13
column: 12
end_location:
row: 30
column: 14
column: 13
fix:
patch:
content: _k
location:
row: 30
column: 13
column: 12
end_location:
row: 30
column: 14
column: 13
applied: false

View File

@@ -5,35 +5,35 @@ expression: checks
- kind: DoNotAssertFalse
location:
row: 8
column: 8
column: 7
end_location:
row: 8
column: 13
column: 12
fix:
patch:
content: raise AssertionError()
location:
row: 8
column: 1
column: 0
end_location:
row: 8
column: 13
column: 12
applied: false
- kind: DoNotAssertFalse
location:
row: 10
column: 8
column: 7
end_location:
row: 10
column: 13
column: 12
fix:
patch:
content: "raise AssertionError('message')"
location:
row: 10
column: 1
column: 0
end_location:
row: 10
column: 24
column: 23
applied: false

View File

@@ -6,9 +6,9 @@ expression: checks
RedundantTupleInExceptionHandler: ValueError
location:
row: 3
column: 9
column: 8
end_location:
row: 3
column: 20
column: 19
fix: ~

View File

@@ -7,56 +7,56 @@ expression: checks
- OSError
location:
row: 17
column: 9
column: 8
end_location:
row: 17
column: 25
column: 24
fix:
patch:
content: "OSError,"
location:
row: 17
column: 9
column: 8
end_location:
row: 17
column: 25
column: 24
applied: false
- kind:
DuplicateHandlerException:
- MyError
location:
row: 28
column: 9
column: 8
end_location:
row: 28
column: 25
column: 24
fix:
patch:
content: "MyError,"
location:
row: 28
column: 9
column: 8
end_location:
row: 28
column: 25
column: 24
applied: false
- kind:
DuplicateHandlerException:
- re.error
location:
row: 49
column: 9
column: 8
end_location:
row: 49
column: 27
column: 26
fix:
patch:
content: "re.error,"
location:
row: 49
column: 9
column: 8
end_location:
row: 49
column: 27
column: 26
applied: false

View File

@@ -5,9 +5,9 @@ expression: checks
- kind: NoAssertRaisesException
location:
row: 22
column: 9
column: 8
end_location:
row: 25
column: 5
column: 4
fix: ~

View File

@@ -6,36 +6,36 @@ expression: checks
DuplicateTryBlockException: ValueError
location:
row: 15
column: 1
column: 0
end_location:
row: 22
column: 1
column: 0
fix: ~
- kind:
DuplicateTryBlockException: pickle.PickleError
location:
row: 22
column: 1
column: 0
end_location:
row: 31
column: 1
column: 0
fix: ~
- kind:
DuplicateTryBlockException: TypeError
location:
row: 31
column: 1
column: 0
end_location:
row: 39
column: 1
column: 0
fix: ~
- kind:
DuplicateTryBlockException: ValueError
location:
row: 31
column: 1
column: 0
end_location:
row: 39
column: 1
column: 0
fix: ~

View File

@@ -5,9 +5,9 @@ expression: checks
- kind: UnnecessaryGeneratorList
location:
row: 1
column: 5
column: 4
end_location:
row: 1
column: 30
column: 29
fix: ~

View File

@@ -5,9 +5,9 @@ expression: checks
- kind: UnnecessaryGeneratorSet
location:
row: 1
column: 5
column: 4
end_location:
row: 1
column: 29
column: 28
fix: ~

View File

@@ -5,9 +5,9 @@ expression: checks
- kind: UnnecessaryGeneratorDict
location:
row: 1
column: 1
column: 0
end_location:
row: 1
column: 31
column: 30
fix: ~

View File

@@ -5,9 +5,9 @@ expression: checks
- kind: UnnecessaryListComprehensionSet
location:
row: 1
column: 5
column: 4
end_location:
row: 1
column: 31
column: 30
fix: ~

View File

@@ -5,9 +5,9 @@ expression: checks
- kind: UnnecessaryListComprehensionDict
location:
row: 1
column: 1
column: 0
end_location:
row: 1
column: 33
column: 32
fix: ~

View File

@@ -6,36 +6,36 @@ expression: checks
UnnecessaryLiteralSet: list
location:
row: 1
column: 6
column: 5
end_location:
row: 1
column: 17
column: 16
fix: ~
- kind:
UnnecessaryLiteralSet: tuple
location:
row: 2
column: 6
column: 5
end_location:
row: 2
column: 17
column: 16
fix: ~
- kind:
UnnecessaryLiteralSet: list
location:
row: 3
column: 6
column: 5
end_location:
row: 3
column: 13
column: 12
fix: ~
- kind:
UnnecessaryLiteralSet: tuple
location:
row: 4
column: 6
column: 5
end_location:
row: 4
column: 13
column: 12
fix: ~

View File

@@ -6,36 +6,36 @@ expression: checks
UnnecessaryLiteralDict: list
location:
row: 1
column: 6
column: 5
end_location:
row: 1
column: 20
column: 19
fix: ~
- kind:
UnnecessaryLiteralDict: tuple
location:
row: 2
column: 6
column: 5
end_location:
row: 2
column: 21
column: 20
fix: ~
- kind:
UnnecessaryLiteralDict: list
location:
row: 3
column: 6
column: 5
end_location:
row: 3
column: 14
column: 13
fix: ~
- kind:
UnnecessaryLiteralDict: tuple
location:
row: 4
column: 6
column: 5
end_location:
row: 4
column: 14
column: 13
fix: ~

View File

@@ -6,36 +6,36 @@ expression: checks
UnnecessaryCollectionCall: tuple
location:
row: 1
column: 5
column: 4
end_location:
row: 1
column: 12
column: 11
fix: ~
- kind:
UnnecessaryCollectionCall: list
location:
row: 2
column: 5
column: 4
end_location:
row: 2
column: 10
fix: ~
- kind:
UnnecessaryCollectionCall: dict
location:
row: 3
column: 5
end_location:
row: 3
column: 11
fix: ~
- kind:
UnnecessaryCollectionCall: dict
location:
row: 3
column: 6
end_location:
row: 3
column: 12
fix: ~
- kind:
UnnecessaryCollectionCall: dict
location:
row: 4
column: 6
column: 5
end_location:
row: 4
column: 15
column: 14
fix: ~

View File

@@ -6,27 +6,27 @@ expression: checks
UnnecessaryLiteralWithinTupleCall: list
location:
row: 1
column: 6
column: 5
end_location:
row: 1
column: 19
column: 18
fix: ~
- kind:
UnnecessaryLiteralWithinTupleCall: tuple
location:
row: 2
column: 6
column: 5
end_location:
row: 2
column: 19
column: 18
fix: ~
- kind:
UnnecessaryLiteralWithinTupleCall: list
location:
row: 3
column: 6
column: 5
end_location:
row: 3
column: 15
column: 14
fix: ~

View File

@@ -6,36 +6,36 @@ expression: checks
UnnecessaryLiteralWithinListCall: list
location:
row: 1
column: 6
column: 5
end_location:
row: 1
column: 18
column: 17
fix: ~
- kind:
UnnecessaryLiteralWithinListCall: tuple
location:
row: 2
column: 6
column: 5
end_location:
row: 2
column: 18
column: 17
fix: ~
- kind:
UnnecessaryLiteralWithinListCall: list
location:
row: 3
column: 6
column: 5
end_location:
row: 3
column: 14
column: 13
fix: ~
- kind:
UnnecessaryLiteralWithinListCall: tuple
location:
row: 4
column: 6
column: 5
end_location:
row: 4
column: 14
column: 13
fix: ~

View File

@@ -5,9 +5,9 @@ expression: checks
- kind: UnnecessaryListCall
location:
row: 2
column: 1
column: 0
end_location:
row: 2
column: 21
column: 20
fix: ~

View File

@@ -6,27 +6,27 @@ expression: checks
UnnecessaryCallAroundSorted: list
location:
row: 2
column: 1
column: 0
end_location:
row: 2
column: 16
column: 15
fix: ~
- kind:
UnnecessaryCallAroundSorted: reversed
location:
row: 3
column: 1
column: 0
end_location:
row: 3
column: 20
column: 19
fix: ~
- kind:
UnnecessaryCallAroundSorted: reversed
location:
row: 4
column: 1
column: 0
end_location:
row: 4
column: 34
column: 33
fix: ~

View File

@@ -8,76 +8,76 @@ expression: checks
- list
location:
row: 2
column: 1
column: 0
end_location:
row: 2
column: 14
fix: ~
- kind:
UnnecessaryDoubleCastOrProcess:
- tuple
- list
location:
row: 3
column: 1
end_location:
row: 3
column: 15
fix: ~
- kind:
UnnecessaryDoubleCastOrProcess:
- list
- tuple
location:
row: 4
column: 1
end_location:
row: 4
column: 15
fix: ~
- kind:
UnnecessaryDoubleCastOrProcess:
- tuple
- tuple
location:
row: 5
column: 1
end_location:
row: 5
column: 16
fix: ~
- kind:
UnnecessaryDoubleCastOrProcess:
- set
- set
location:
row: 6
column: 1
end_location:
row: 6
column: 12
fix: ~
- kind:
UnnecessaryDoubleCastOrProcess:
- list
- set
location:
row: 7
column: 1
end_location:
row: 7
column: 13
fix: ~
- kind:
UnnecessaryDoubleCastOrProcess:
- tuple
- list
location:
row: 3
column: 0
end_location:
row: 3
column: 14
fix: ~
- kind:
UnnecessaryDoubleCastOrProcess:
- list
- tuple
location:
row: 4
column: 0
end_location:
row: 4
column: 14
fix: ~
- kind:
UnnecessaryDoubleCastOrProcess:
- tuple
- tuple
location:
row: 5
column: 0
end_location:
row: 5
column: 15
fix: ~
- kind:
UnnecessaryDoubleCastOrProcess:
- set
- set
location:
row: 6
column: 0
end_location:
row: 6
column: 11
fix: ~
- kind:
UnnecessaryDoubleCastOrProcess:
- list
- set
location:
row: 7
column: 0
end_location:
row: 7
column: 12
fix: ~
- kind:
UnnecessaryDoubleCastOrProcess:
- tuple
- set
location:
row: 8
column: 1
column: 0
end_location:
row: 8
column: 14
column: 13
fix: ~
- kind:
UnnecessaryDoubleCastOrProcess:
@@ -85,10 +85,10 @@ expression: checks
- set
location:
row: 9
column: 1
column: 0
end_location:
row: 9
column: 15
column: 14
fix: ~
- kind:
UnnecessaryDoubleCastOrProcess:
@@ -96,10 +96,10 @@ expression: checks
- set
location:
row: 10
column: 1
column: 0
end_location:
row: 10
column: 17
column: 16
fix: ~
- kind:
UnnecessaryDoubleCastOrProcess:
@@ -107,10 +107,10 @@ expression: checks
- sorted
location:
row: 11
column: 1
column: 0
end_location:
row: 11
column: 16
column: 15
fix: ~
- kind:
UnnecessaryDoubleCastOrProcess:
@@ -118,10 +118,10 @@ expression: checks
- sorted
location:
row: 12
column: 1
column: 0
end_location:
row: 12
column: 17
column: 16
fix: ~
- kind:
UnnecessaryDoubleCastOrProcess:
@@ -129,10 +129,10 @@ expression: checks
- sorted
location:
row: 13
column: 1
column: 0
end_location:
row: 13
column: 18
column: 17
fix: ~
- kind:
UnnecessaryDoubleCastOrProcess:
@@ -140,9 +140,9 @@ expression: checks
- sorted
location:
row: 14
column: 1
column: 0
end_location:
row: 14
column: 20
column: 19
fix: ~

View File

@@ -6,36 +6,36 @@ expression: checks
UnnecessarySubscriptReversal: set
location:
row: 2
column: 5
column: 4
end_location:
row: 2
column: 19
column: 18
fix: ~
- kind:
UnnecessarySubscriptReversal: reversed
location:
row: 3
column: 5
column: 4
end_location:
row: 3
column: 24
column: 23
fix: ~
- kind:
UnnecessarySubscriptReversal: sorted
location:
row: 4
column: 5
column: 4
end_location:
row: 4
column: 22
column: 21
fix: ~
- kind:
UnnecessarySubscriptReversal: sorted
location:
row: 5
column: 5
column: 4
end_location:
row: 5
column: 36
column: 35
fix: ~

View File

@@ -6,18 +6,18 @@ expression: checks
UnnecessaryComprehension: list
location:
row: 2
column: 1
column: 0
end_location:
row: 2
column: 15
column: 14
fix: ~
- kind:
UnnecessaryComprehension: set
location:
row: 3
column: 1
column: 0
end_location:
row: 3
column: 15
column: 14
fix: ~

View File

@@ -6,72 +6,72 @@ expression: checks
UnnecessaryMap: generator
location:
row: 2
column: 1
column: 0
end_location:
row: 2
column: 27
column: 26
fix: ~
- kind:
UnnecessaryMap: generator
location:
row: 3
column: 1
column: 0
end_location:
row: 3
column: 28
column: 27
fix: ~
- kind:
UnnecessaryMap: list
location:
row: 4
column: 1
end_location:
row: 4
column: 33
fix: ~
- kind:
UnnecessaryMap: generator
location:
row: 4
column: 6
column: 0
end_location:
row: 4
column: 32
fix: ~
- kind:
UnnecessaryMap: generator
location:
row: 4
column: 5
end_location:
row: 4
column: 31
fix: ~
- kind:
UnnecessaryMap: set
location:
row: 5
column: 1
column: 0
end_location:
row: 5
column: 37
column: 36
fix: ~
- kind:
UnnecessaryMap: generator
location:
row: 5
column: 5
column: 4
end_location:
row: 5
column: 36
column: 35
fix: ~
- kind:
UnnecessaryMap: dict
location:
row: 6
column: 1
column: 0
end_location:
row: 6
column: 37
column: 36
fix: ~
- kind:
UnnecessaryMap: generator
location:
row: 6
column: 6
column: 5
end_location:
row: 6
column: 36
column: 35
fix: ~

View File

@@ -5,9 +5,9 @@ expression: checks
- kind: PublicModule
location:
row: 1
column: 1
column: 0
end_location:
row: 1
column: 1
column: 0
fix: ~

View File

@@ -5,9 +5,9 @@ expression: checks
- kind: PublicClass
location:
row: 14
column: 1
column: 0
end_location:
row: 67
column: 1
column: 0
fix: ~

View File

@@ -5,25 +5,25 @@ expression: checks
- kind: PublicMethod
location:
row: 22
column: 5
column: 4
end_location:
row: 25
column: 5
column: 4
fix: ~
- kind: PublicMethod
location:
row: 51
column: 5
column: 4
end_location:
row: 54
column: 5
column: 4
fix: ~
- kind: PublicMethod
location:
row: 63
column: 5
column: 4
end_location:
row: 67
column: 1
column: 0
fix: ~

View File

@@ -5,9 +5,9 @@ expression: checks
- kind: PublicFunction
location:
row: 395
column: 1
column: 0
end_location:
row: 396
column: 1
column: 0
fix: ~

View File

@@ -5,9 +5,9 @@ expression: checks
- kind: MagicMethod
location:
row: 59
column: 5
column: 4
end_location:
row: 62
column: 5
column: 4
fix: ~

View File

@@ -5,17 +5,17 @@ expression: checks
- kind: PublicInit
location:
row: 55
column: 5
column: 4
end_location:
row: 58
column: 5
column: 4
fix: ~
- kind: PublicInit
location:
row: 529
column: 5
column: 4
end_location:
row: 533
column: 1
column: 0
fix: ~

View File

@@ -6,36 +6,36 @@ expression: checks
NoBlankLineBeforeFunction: 1
location:
row: 132
column: 5
column: 4
end_location:
row: 132
column: 25
column: 24
fix:
patch:
content: ""
location:
row: 131
column: 1
column: 0
end_location:
row: 132
column: 1
column: 0
applied: false
- kind:
NoBlankLineBeforeFunction: 1
location:
row: 146
column: 5
column: 4
end_location:
row: 146
column: 38
column: 37
fix:
patch:
content: ""
location:
row: 145
column: 1
column: 0
end_location:
row: 146
column: 1
column: 0
applied: false

View File

@@ -2,76 +2,40 @@
source: src/linter.rs
expression: checks
---
- kind:
NoBlankLineAfterFunction: 0
location:
row: 79
column: 5
end_location:
row: 79
column: 33
fix:
patch:
content: ""
location:
row: 81
column: 1
end_location:
row: 80
column: 1
applied: false
- kind:
NoBlankLineAfterFunction: 1
location:
row: 137
column: 5
column: 4
end_location:
row: 137
column: 25
fix:
patch:
content: ""
location:
row: 138
column: 1
end_location:
row: 139
column: 1
applied: false
- kind:
NoBlankLineAfterFunction: 1
location:
row: 146
column: 5
end_location:
row: 146
column: 38
fix:
patch:
content: ""
location:
row: 147
column: 1
end_location:
row: 148
column: 1
applied: false
- kind:
NoBlankLineAfterFunction: 0
location:
row: 453
column: 5
end_location:
row: 453
column: 24
fix:
patch:
content: ""
location:
row: 455
column: 1
row: 138
column: 0
end_location:
row: 454
column: 1
row: 139
column: 0
applied: false
- kind:
NoBlankLineAfterFunction: 1
location:
row: 146
column: 4
end_location:
row: 146
column: 37
fix:
patch:
content: ""
location:
row: 147
column: 0
end_location:
row: 148
column: 0
applied: false

View File

@@ -6,54 +6,54 @@ expression: checks
OneBlankLineBeforeClass: 0
location:
row: 156
column: 5
column: 4
end_location:
row: 156
column: 33
column: 32
fix:
patch:
content: "\n"
location:
row: 156
column: 1
column: 0
end_location:
row: 156
column: 1
column: 0
applied: false
- kind:
OneBlankLineBeforeClass: 0
location:
row: 187
column: 5
column: 4
end_location:
row: 187
column: 46
column: 45
fix:
patch:
content: "\n"
location:
row: 187
column: 1
column: 0
end_location:
row: 187
column: 1
column: 0
applied: false
- kind:
OneBlankLineBeforeClass: 0
location:
row: 521
column: 5
column: 4
end_location:
row: 527
column: 8
column: 7
fix:
patch:
content: "\n"
location:
row: 521
column: 1
column: 0
end_location:
row: 521
column: 1
column: 0
applied: false

View File

@@ -6,36 +6,36 @@ expression: checks
OneBlankLineAfterClass: 0
location:
row: 176
column: 5
column: 4
end_location:
row: 176
column: 25
column: 24
fix:
patch:
content: "\n"
location:
row: 177
column: 1
column: 0
end_location:
row: 177
column: 1
column: 0
applied: false
- kind:
OneBlankLineAfterClass: 0
location:
row: 187
column: 5
column: 4
end_location:
row: 187
column: 46
column: 45
fix:
patch:
content: "\n"
location:
row: 188
column: 1
column: 0
end_location:
row: 188
column: 1
column: 0
applied: false

View File

@@ -5,35 +5,35 @@ expression: checks
- kind: BlankLineAfterSummary
location:
row: 195
column: 5
column: 4
end_location:
row: 198
column: 8
column: 7
fix:
patch:
content: "\n"
location:
row: 196
column: 1
column: 0
end_location:
row: 196
column: 1
column: 0
applied: false
- kind: BlankLineAfterSummary
location:
row: 205
column: 5
column: 4
end_location:
row: 210
column: 8
column: 7
fix:
patch:
content: "\n"
location:
row: 206
column: 1
column: 0
end_location:
row: 208
column: 1
column: 0
applied: false

View File

@@ -5,69 +5,35 @@ expression: checks
- kind: NoUnderIndentation
location:
row: 227
column: 1
column: 0
end_location:
row: 227
column: 1
column: 0
fix:
patch:
content: " "
location:
row: 227
column: 1
column: 0
end_location:
row: 227
column: 1
applied: false
- kind: NoUnderIndentation
location:
row: 238
column: 1
end_location:
row: 238
column: 1
fix:
patch:
content: " "
location:
row: 238
column: 1
end_location:
row: 238
column: 1
column: 0
applied: false
- kind: NoUnderIndentation
location:
row: 435
column: 1
column: 0
end_location:
row: 435
column: 1
column: 0
fix:
patch:
content: " "
location:
row: 435
column: 1
column: 0
end_location:
row: 435
column: 5
applied: false
- kind: NoUnderIndentation
location:
row: 436
column: 1
end_location:
row: 436
column: 1
fix:
patch:
content: " "
location:
row: 436
column: 1
end_location:
row: 436
column: 5
column: 4
applied: false

View File

@@ -5,52 +5,52 @@ expression: checks
- kind: NoOverIndentation
location:
row: 247
column: 1
column: 0
end_location:
row: 247
column: 1
column: 0
fix:
patch:
content: " "
location:
row: 247
column: 1
column: 0
end_location:
row: 247
column: 7
applied: false
- kind: NoOverIndentation
location:
row: 259
column: 0
end_location:
row: 259
column: 0
fix:
patch:
content: " "
location:
row: 259
column: 0
end_location:
row: 259
column: 8
applied: false
- kind: NoOverIndentation
location:
row: 259
column: 1
end_location:
row: 259
column: 1
fix:
patch:
content: " "
location:
row: 259
column: 1
end_location:
row: 259
column: 9
applied: false
- kind: NoOverIndentation
location:
row: 267
column: 1
column: 0
end_location:
row: 267
column: 1
column: 0
fix:
patch:
content: " "
location:
row: 267
column: 1
column: 0
end_location:
row: 267
column: 9
column: 8
applied: false

View File

@@ -5,18 +5,18 @@ expression: checks
- kind: NewLineAfterLastParagraph
location:
row: 276
column: 5
column: 4
end_location:
row: 278
column: 20
column: 19
fix:
patch:
content: "\n "
location:
row: 278
column: 17
column: 16
end_location:
row: 278
column: 17
column: 16
applied: false

View File

@@ -5,52 +5,52 @@ expression: checks
- kind: NoSurroundingWhitespace
location:
row: 283
column: 5
column: 4
end_location:
row: 283
column: 34
column: 33
fix:
patch:
content: Whitespace at the end.
location:
row: 283
column: 8
column: 7
end_location:
row: 283
column: 31
column: 30
applied: false
- kind: NoSurroundingWhitespace
location:
row: 288
column: 5
column: 4
end_location:
row: 288
column: 38
column: 37
fix:
patch:
content: Whitespace at everywhere.
location:
row: 288
column: 8
column: 7
end_location:
row: 288
column: 35
column: 34
applied: false
- kind: NoSurroundingWhitespace
location:
row: 294
column: 5
column: 4
end_location:
row: 297
column: 8
column: 7
fix:
patch:
content: Whitespace at the beginning.
location:
row: 294
column: 8
column: 7
end_location:
row: 294
column: 37
column: 36
applied: false

View File

@@ -6,36 +6,36 @@ expression: checks
NoBlankLineBeforeClass: 1
location:
row: 165
column: 5
column: 4
end_location:
row: 165
column: 30
column: 29
fix:
patch:
content: ""
location:
row: 164
column: 1
column: 0
end_location:
row: 165
column: 1
column: 0
applied: false
- kind:
NoBlankLineBeforeClass: 1
location:
row: 176
column: 5
column: 4
end_location:
row: 176
column: 25
column: 24
fix:
patch:
content: ""
location:
row: 175
column: 1
column: 0
end_location:
row: 176
column: 1
column: 0
applied: false

View File

@@ -5,9 +5,9 @@ expression: checks
- kind: MultiLineSummaryFirstLine
location:
row: 124
column: 5
column: 4
end_location:
row: 126
column: 8
column: 7
fix: ~

View File

@@ -5,129 +5,129 @@ expression: checks
- kind: MultiLineSummarySecondLine
location:
row: 195
column: 5
column: 4
end_location:
row: 198
column: 8
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 205
column: 5
column: 4
end_location:
row: 210
column: 8
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 215
column: 5
column: 4
end_location:
row: 219
column: 8
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 225
column: 5
column: 4
end_location:
row: 229
column: 8
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 235
column: 5
column: 4
end_location:
row: 239
column: 4
column: 3
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 245
column: 5
column: 4
end_location:
row: 249
column: 8
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 255
column: 5
column: 4
end_location:
row: 259
column: 12
column: 11
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 265
column: 5
column: 4
end_location:
row: 269
column: 8
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 276
column: 5
column: 4
end_location:
row: 278
column: 20
column: 19
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 294
column: 5
column: 4
end_location:
row: 297
column: 8
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 338
column: 5
column: 4
end_location:
row: 343
column: 8
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 378
column: 5
column: 4
end_location:
row: 381
column: 8
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 387
column: 5
column: 4
end_location:
row: 391
column: 8
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 433
column: 37
column: 36
end_location:
row: 436
column: 8
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 445
column: 5
column: 4
end_location:
row: 449
column: 8
column: 7
fix: ~
- kind: MultiLineSummarySecondLine
location:
row: 521
column: 5
column: 4
end_location:
row: 527
column: 8
column: 7
fix: ~

View File

@@ -6,18 +6,18 @@ expression: checks
SectionNotOverIndented: Returns
location:
row: 135
column: 5
column: 4
end_location:
row: 141
column: 8
column: 7
fix:
patch:
content: " "
location:
row: 137
column: 1
column: 0
end_location:
row: 137
column: 9
column: 8
applied: false

View File

@@ -6,16 +6,16 @@ expression: checks
SectionUnderlineNotOverIndented: Returns
location:
row: 147
column: 5
column: 4
end_location:
row: 153
column: 8
column: 7
fix:
patch:
content: " "
location:
row: 150
column: 1
column: 0
end_location:
row: 150
column: 9
@@ -24,16 +24,16 @@ expression: checks
SectionUnderlineNotOverIndented: Returns
location:
row: 161
column: 5
column: 4
end_location:
row: 165
column: 8
column: 7
fix:
patch:
content: " "
location:
row: 164
column: 1
column: 0
end_location:
row: 164
column: 9

View File

@@ -5,41 +5,41 @@ expression: checks
- kind: UsesTripleQuotes
location:
row: 302
column: 5
column: 4
end_location:
row: 302
column: 20
column: 19
fix: ~
- kind: UsesTripleQuotes
location:
row: 307
column: 5
column: 4
end_location:
row: 307
column: 20
column: 19
fix: ~
- kind: UsesTripleQuotes
location:
row: 312
column: 5
column: 4
end_location:
row: 312
column: 16
column: 15
fix: ~
- kind: UsesTripleQuotes
location:
row: 317
column: 5
column: 4
end_location:
row: 317
column: 16
column: 15
fix: ~
- kind: UsesTripleQuotes
location:
row: 323
column: 5
column: 4
end_location:
row: 323
column: 17
column: 16
fix: ~

Some files were not shown because too many files have changed in this diff Show More