This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 796
feat: warnings as errors #1838
Merged
Merged
feat: warnings as errors #1838
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
123de71
feat: warnings as errors
jatkz 6bf0a92
changed the bool arg to Severity and updated its traits
jatkz be14b4c
reformat the test based on the linter
jatkz 3a4ffdf
renamed variable based on property type change and changed a few refs
jatkz b9f0ecc
updated changelog
jatkz 50464e9
Merge branch 'master' into warnings-as-errors
gakonst 8b68913
revert changelog iden change
gakonst db200ff
added test for combining compiler severity filter and ignored error c…
jatkz 8db929f
Merge branch 'warnings-as-errors' of https://github.com/JaredTokuz/et…
jatkz 90923c9
adjusted has_error to utilize ge functionality in case of info errors
jatkz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,7 +3,7 @@ | |||||
use crate::{ | ||||||
artifacts::{ | ||||||
contract::{CompactContractBytecode, CompactContractRef, Contract}, | ||||||
Error, | ||||||
Error, Severity, | ||||||
}, | ||||||
buildinfo::RawBuildInfo, | ||||||
info::ContractInfoRef, | ||||||
|
@@ -31,8 +31,8 @@ pub struct ProjectCompileOutput<T: ArtifactOutput = ConfigurableArtifacts> { | |||||
pub(crate) cached_artifacts: Artifacts<T::Artifact>, | ||||||
/// errors that should be omitted | ||||||
pub(crate) ignored_error_codes: Vec<u64>, | ||||||
/// treat warnings as errors | ||||||
pub(crate) warnings_as_errors: bool, | ||||||
/// set level of severity that is treated as an error | ||||||
pub(crate) warnings_as_errors: Severity, | ||||||
} | ||||||
|
||||||
impl<T: ArtifactOutput> ProjectCompileOutput<T> { | ||||||
|
@@ -199,7 +199,7 @@ impl<T: ArtifactOutput> ProjectCompileOutput<T> { | |||||
|
||||||
/// Whether there were errors | ||||||
pub fn has_compiler_errors(&self) -> bool { | ||||||
self.compiler_output.has_error(self.warnings_as_errors) | ||||||
self.compiler_output.has_error(&self.warnings_as_errors) | ||||||
} | ||||||
|
||||||
/// Whether there were warnings | ||||||
|
@@ -400,7 +400,7 @@ impl<T: ArtifactOutput> fmt::Display for ProjectCompileOutput<T> { | |||||
if self.compiler_output.is_unchanged() { | ||||||
f.write_str("Nothing to compile") | ||||||
} else { | ||||||
self.compiler_output.diagnostics(&self.ignored_error_codes, self.warnings_as_errors).fmt(f) | ||||||
self.compiler_output.diagnostics(&self.ignored_error_codes, &self.warnings_as_errors).fmt(f) | ||||||
} | ||||||
} | ||||||
} | ||||||
|
@@ -428,14 +428,8 @@ impl AggregatedCompilerOutput { | |||||
} | ||||||
|
||||||
/// Whether the output contains a compiler error | ||||||
pub fn has_error(&self, warnings_as_errors: bool) -> bool { | ||||||
self.errors.iter().any(|err| { | ||||||
if warnings_as_errors { | ||||||
true | ||||||
} else { | ||||||
err.severity.is_error() | ||||||
} | ||||||
}) | ||||||
pub fn has_error(&self, warnings_as_errors: &Severity) -> bool { | ||||||
self.errors.iter().any(|err| warnings_as_errors.ge(&err.severity)) | ||||||
} | ||||||
|
||||||
/// Whether the output contains a compiler warning | ||||||
|
@@ -449,7 +443,7 @@ impl AggregatedCompilerOutput { | |||||
}) | ||||||
} | ||||||
|
||||||
pub fn diagnostics<'a>(&'a self, ignored_error_codes: &'a [u64], warnings_as_errors: bool) -> OutputDiagnostics { | ||||||
pub fn diagnostics<'a>(&'a self, ignored_error_codes: &'a [u64], warnings_as_errors: &'a Severity) -> OutputDiagnostics { | ||||||
OutputDiagnostics { compiler_output: self, ignored_error_codes, warnings_as_errors } | ||||||
} | ||||||
|
||||||
|
@@ -711,7 +705,7 @@ pub struct OutputDiagnostics<'a> { | |||||
/// the error codes to ignore | ||||||
ignored_error_codes: &'a [u64], | ||||||
/// treat warnings as errors | ||||||
warnings_as_errors: bool, | ||||||
warnings_as_errors: &'a Severity, | ||||||
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.
Suggested change
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. please rename to something akin to severity |
||||||
} | ||||||
|
||||||
impl<'a> OutputDiagnostics<'a> { | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -311,7 +311,7 @@ impl<'a, T: ArtifactOutput> CompiledState<'a, T> { | |
ctx, | ||
&project.paths, | ||
) | ||
} else if output.has_error(project.warnings_as_errors) { | ||
} else if output.has_error(&project.warnings_as_errors) { | ||
trace!("skip writing cache file due to solc errors: {:?}", output.errors); | ||
project.artifacts_handler().output_to_artifacts( | ||
&output.contracts, | ||
|
@@ -360,14 +360,15 @@ impl<'a, T: ArtifactOutput> ArtifactsState<'a, T> { | |
let ArtifactsState { output, cache, compiled_artifacts } = self; | ||
let project = cache.project(); | ||
let ignored_error_codes = project.ignored_error_codes.clone(); | ||
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. perhaps follow convention here and change to:
|
||
let skip_write_to_disk = project.no_artifacts || output.has_error(project.warnings_as_errors); | ||
let warnings_as_errors = project.warnings_as_errors.clone(); | ||
let skip_write_to_disk = project.no_artifacts || output.has_error(&warnings_as_errors); | ||
let cached_artifacts = cache.consume(&compiled_artifacts, !skip_write_to_disk)?; | ||
Ok(ProjectCompileOutput { | ||
compiler_output: output, | ||
compiled_artifacts, | ||
cached_artifacts, | ||
ignored_error_codes, | ||
warnings_as_errors: project.warnings_as_errors | ||
warnings_as_errors | ||
}) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
no need to take this as ref