Skip to content

Commit 0cd3a78

Browse files
authored
chore(lint): correct some spans (#10610)
* chore(lint): correct some spans * update
1 parent e9496f6 commit 0cd3a78

File tree

14 files changed

+50
-59
lines changed

14 files changed

+50
-59
lines changed

crates/forge/tests/cli/lint.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ forgetest!(can_use_config_ignore, |prj, cmd| {
7070
});
7171
cmd.arg("lint").assert_success().stderr_eq(str![[r#"
7272
note[mixed-case-variable]: mutable variables should use mixedCase
73-
[FILE]:6:9
73+
[FILE]:6:17
7474
|
7575
6 | uint256 VARIABLE_MIXED_CASE_INFO;
76-
| ---------------------------------
76+
| ------------------------
7777
|
7878
7979
@@ -104,10 +104,10 @@ forgetest!(can_override_config_severity, |prj, cmd| {
104104
});
105105
cmd.arg("lint").args(["--severity", "info"]).assert_success().stderr_eq(str![[r#"
106106
note[mixed-case-variable]: mutable variables should use mixedCase
107-
[FILE]:6:9
107+
[FILE]:6:17
108108
|
109109
6 | uint256 VARIABLE_MIXED_CASE_INFO;
110-
| ---------------------------------
110+
| ------------------------
111111
|
112112
113113

crates/lint/src/sol/gas/keccak.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
use solar_ast::{Expr, ExprKind};
2-
use solar_interface::kw;
3-
41
use super::AsmKeccak256;
52
use crate::{
63
declare_forge_lint,
74
linter::EarlyLintPass,
85
sol::{Severity, SolLint},
96
};
7+
use solar_ast::{Expr, ExprKind};
8+
use solar_interface::kw;
109

1110
declare_forge_lint!(
1211
ASM_KECCAK256,

crates/lint/src/sol/gas/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
mod keccak;
2-
use keccak::ASM_KECCAK256;
3-
41
use crate::{
52
register_lints,
63
sol::{EarlyLintPass, SolLint},
74
};
85

6+
mod keccak;
7+
use keccak::ASM_KECCAK256;
8+
99
register_lints!((AsmKeccak256, (ASM_KECCAK256)));

crates/lint/src/sol/high/incorrect_shift.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
use solar_ast::{BinOp, BinOpKind, Expr, ExprKind};
2-
31
use super::IncorrectShift;
42
use crate::{
53
declare_forge_lint,
64
linter::{EarlyLintPass, LintContext},
75
sol::{Severity, SolLint},
86
};
7+
use solar_ast::{BinOp, BinOpKind, Expr, ExprKind};
98

109
declare_forge_lint!(
1110
INCORRECT_SHIFT,

crates/lint/src/sol/high/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
mod incorrect_shift;
2-
use incorrect_shift::INCORRECT_SHIFT;
3-
41
use crate::{
52
register_lints,
63
sol::{EarlyLintPass, SolLint},
74
};
85

6+
mod incorrect_shift;
7+
use incorrect_shift::INCORRECT_SHIFT;
8+
99
register_lints!((IncorrectShift, (INCORRECT_SHIFT)));

crates/lint/src/sol/info/mixed_case.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
use solar_ast::{ItemFunction, VariableDefinition};
2-
31
use super::{MixedCaseFunction, MixedCaseVariable};
42
use crate::{
53
declare_forge_lint,
64
linter::{EarlyLintPass, LintContext},
75
sol::{Severity, SolLint},
86
};
7+
use solar_ast::{ItemFunction, VariableDefinition};
98

109
declare_forge_lint!(
1110
MIXED_CASE_FUNCTION,
@@ -18,9 +17,8 @@ declare_forge_lint!(
1817
impl<'ast> EarlyLintPass<'ast> for MixedCaseFunction {
1918
fn check_item_function(&mut self, ctx: &LintContext<'_>, func: &'ast ItemFunction<'ast>) {
2019
if let Some(name) = func.header.name {
21-
let name = name.as_str();
22-
if !is_mixed_case(name, true) {
23-
ctx.emit(&MIXED_CASE_FUNCTION, func.body_span);
20+
if !is_mixed_case(name.as_str(), true) {
21+
ctx.emit(&MIXED_CASE_FUNCTION, name.span);
2422
}
2523
}
2624
}
@@ -41,9 +39,8 @@ impl<'ast> EarlyLintPass<'ast> for MixedCaseVariable {
4139
) {
4240
if var.mutability.is_none() {
4341
if let Some(name) = var.name {
44-
let name = name.as_str();
45-
if !is_mixed_case(name, false) {
46-
ctx.emit(&MIXED_CASE_VARIABLE, var.span);
42+
if !is_mixed_case(name.as_str(), false) {
43+
ctx.emit(&MIXED_CASE_VARIABLE, name.span);
4744
}
4845
}
4946
}

crates/lint/src/sol/info/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
use crate::{
2+
register_lints,
3+
sol::{EarlyLintPass, SolLint},
4+
};
5+
16
mod mixed_case;
27
use mixed_case::{MIXED_CASE_FUNCTION, MIXED_CASE_VARIABLE};
38

@@ -7,11 +12,6 @@ use pascal_case::PASCAL_CASE_STRUCT;
712
mod screaming_snake_case;
813
use screaming_snake_case::{SCREAMING_SNAKE_CASE_CONSTANT, SCREAMING_SNAKE_CASE_IMMUTABLE};
914

10-
use crate::{
11-
register_lints,
12-
sol::{EarlyLintPass, SolLint},
13-
};
14-
1515
register_lints!(
1616
(PascalCaseStruct, (PASCAL_CASE_STRUCT)),
1717
(MixedCaseVariable, (MIXED_CASE_VARIABLE)),

crates/lint/src/sol/info/pascal_case.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
use solar_ast::ItemStruct;
2-
31
use super::PascalCaseStruct;
42
use crate::{
53
declare_forge_lint,
64
linter::{EarlyLintPass, LintContext},
75
sol::{Severity, SolLint},
86
};
7+
use solar_ast::ItemStruct;
98

109
declare_forge_lint!(
1110
PASCAL_CASE_STRUCT,
@@ -18,7 +17,7 @@ declare_forge_lint!(
1817
impl<'ast> EarlyLintPass<'ast> for PascalCaseStruct {
1918
fn check_item_struct(&mut self, ctx: &LintContext<'_>, strukt: &'ast ItemStruct<'ast>) {
2019
let name = strukt.name.as_str();
21-
if !is_pascal_case(name) && name.len() > 1 {
20+
if name.len() > 1 && !is_pascal_case(name) {
2221
ctx.emit(&PASCAL_CASE_STRUCT, strukt.name.span);
2322
}
2423
}

crates/lint/src/sol/info/screaming_snake_case.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
use solar_ast::{VarMut, VariableDefinition};
2-
31
use super::ScreamingSnakeCase;
42
use crate::{
53
declare_forge_lint,
64
linter::{EarlyLintPass, LintContext},
75
sol::{Severity, SolLint},
86
};
7+
use solar_ast::{VarMut, VariableDefinition};
98

109
declare_forge_lint!(
1110
SCREAMING_SNAKE_CASE_CONSTANT,

crates/lint/src/sol/med/div_mul.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
use solar_ast::{BinOp, BinOpKind, Expr, ExprKind};
2-
31
use super::DivideBeforeMultiply;
42
use crate::{
53
declare_forge_lint,
64
linter::{EarlyLintPass, LintContext},
75
sol::{Severity, SolLint},
86
};
7+
use solar_ast::{BinOp, BinOpKind, Expr, ExprKind};
98

109
declare_forge_lint!(
1110
DIVIDE_BEFORE_MULTIPLY,

0 commit comments

Comments
 (0)