-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix(lint): lint only files that we build #11247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
36ad52d
b105232
10fbdc8
ccea4c9
2123e13
c5bb8df
bb7987e
7722419
3e2a4a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,13 +118,13 @@ impl BuildArgs { | |
|
||
// Only run the `SolidityLinter` if there are no compilation errors | ||
if !output.output().errors.iter().any(|e| e.is_error()) { | ||
self.lint(&project, &config).map_err(|err| eyre!("Lint failed: {err}"))?; | ||
self.lint(&project, &config, &self.paths).map_err(|err| eyre!("Lint failed: {err}"))?; | ||
grandizzy marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we not get the paths from the compiler output instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure we want this as will mean that we won't lint contracts that are already built, e.g. we will show lint errors only first time for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's true for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with that we can simply pass the paths from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm, isn't this the same, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can do both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DaniPopes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, that is fine then |
||
} | ||
|
||
Ok(output) | ||
} | ||
|
||
fn lint(&self, project: &Project, config: &Config) -> Result<()> { | ||
fn lint(&self, project: &Project, config: &Config, files: &Option<Vec<PathBuf>>) -> Result<()> { | ||
grandizzy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let format_json = shell::is_json(); | ||
if project.compiler.solc.is_some() && !shell::is_quiet() { | ||
let linter = SolidityLinter::new(config.project_paths()) | ||
|
@@ -160,8 +160,17 @@ impl BuildArgs { | |
.project_paths::<SolcLanguage>() | ||
.input_files_iter() | ||
.filter(|p| { | ||
skip.is_match(p) | ||
&& !(ignored.contains(p) || ignored.contains(&curr_dir.join(p))) | ||
// Lint only specified build files, if any. | ||
if let Some(files) = files { | ||
return files.iter().any(|file| &curr_dir.join(file) == p); | ||
} | ||
let include = if ignored.is_empty() { | ||
// Default to source contracts only if lint ignore not configured. | ||
p.starts_with(&config.src) | ||
} else { | ||
!(ignored.contains(p) || ignored.contains(&curr_dir.join(p))) | ||
}; | ||
skip.is_match(p) && include | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the condition above can be merged with this one: config.lint.lint_on_build &&
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, simplified in 7722419