diff --git a/Cargo.toml b/Cargo.toml index 8d016144..65b41c73 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ libraries = [ { git = "https://github.com/trailofbits/dylint", pattern = "examples/restriction/collapsible_unwrap" }, { git = "https://github.com/trailofbits/dylint", pattern = "examples/restriction/const_path_join" }, { git = "https://github.com/trailofbits/dylint", pattern = "examples/restriction/inconsistent_qualification" }, + { git = "https://github.com/trailofbits/dylint", pattern = "examples/restriction/misleading_variable_name" }, { git = "https://github.com/trailofbits/dylint", pattern = "examples/restriction/question_mark_in_expression" }, { git = "https://github.com/trailofbits/dylint", pattern = "examples/restriction/ref_aware_redundant_closure_for_method_calls" }, { git = "https://github.com/trailofbits/dylint", pattern = "examples/restriction/suboptimal_pattern" }, diff --git a/core/src/backup.rs b/core/src/backup.rs index 2b50e790..51f31903 100644 --- a/core/src/backup.rs +++ b/core/src/backup.rs @@ -90,7 +90,7 @@ fn sibling_tempfile(path: &Path) -> Result { fn mtime_is_updated() { let tempfile = NamedTempFile::new().unwrap(); - let backup = Backup::new(&tempfile); + let backup = Backup::new(&tempfile).unwrap(); let before = mtime(tempfile.path()).unwrap(); diff --git a/core/src/core.rs b/core/src/core.rs index 15eb2c7e..b8ede68f 100644 --- a/core/src/core.rs +++ b/core/src/core.rs @@ -324,10 +324,10 @@ fn process_options(opts: &mut Necessist) -> Result<()> { } fn default_config(context: &LightContext, root: &Path) -> Result<()> { - let path = root.join("necessist.toml"); + let path_buf = root.join("necessist.toml"); - if path.try_exists()? { - bail!("A configuration file already exists at {:?}", path); + if path_buf.try_exists()? { + bail!("A configuration file already exists at {:?}", path_buf); } warn( @@ -339,13 +339,13 @@ fn default_config(context: &LightContext, root: &Path) -> Result<()> { let toml = toml::to_string(&Config::default())?; - write(path, toml).map_err(Into::into) + write(path_buf, toml).map_err(Into::into) } fn read_config(context: &LightContext, root: &Path) -> Result { - let path = root.join("necessist.toml"); + let path_buf = root.join("necessist.toml"); - if !path.try_exists()? { + if !path_buf.try_exists()? { return Ok(Config::default()); } @@ -356,7 +356,7 @@ fn read_config(context: &LightContext, root: &Path) -> Result { WarnFlags::empty(), )?; - let contents = read_to_string(path)?; + let contents = read_to_string(path_buf)?; toml::from_str(&contents).map_err(Into::into) } @@ -390,14 +390,14 @@ fn canonicalize_test_files(context: &LightContext) -> Result> { .test_files .iter() .map(|path| { - let path = path.canonicalize()?; + let path_buf = path.canonicalize()?; ensure!( - path.starts_with(context.root), + path_buf.starts_with(context.root), "{:?} is not in {:?}", - path, + path_buf, context.root ); - Ok(path) + Ok(path_buf) }) .collect::>>() } diff --git a/core/src/offset_calculator/impls.rs b/core/src/offset_calculator/impls.rs index e9ecc4f1..0b0b5710 100644 --- a/core/src/offset_calculator/impls.rs +++ b/core/src/offset_calculator/impls.rs @@ -81,6 +81,10 @@ impl<'original> Interface for CachingOffsetCalculator<'original> { } impl<'original> Interface for StatelessOffsetCalculator<'original> { + #[cfg_attr( + dylint_lib = "misleading_variable_name", + allow(misleading_variable_name) + )] fn offset_from_line_column(&mut self, line_column: LineColumn) -> (usize, bool) { let mut lines = self.original.split('\n'); let mut offset = 0; diff --git a/core/src/sqlite.rs b/core/src/sqlite.rs index 0dcff3be..496bb003 100644 --- a/core/src/sqlite.rs +++ b/core/src/sqlite.rs @@ -67,18 +67,18 @@ pub(crate) fn init( reset: bool, ) -> Result<(Sqlite, Vec)> { let root = Rc::new(root.to_path_buf()); - let path = root.join("necessist.db"); + let path_buf = root.join("necessist.db"); - let exists = path.try_exists()?; + let exists = path_buf.try_exists()?; if must_not_exist && exists { bail!( "Found an sqlite database at {:?}; please pass either --reset or --resume", - path + path_buf ); } - let database_url = format!("sqlite://{}", path.to_string_lossy()); + let database_url = format!("sqlite://{}", path_buf.to_string_lossy()); let mut connection = SqliteConnection::establish(&database_url)?; if reset && exists {