Skip to content
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

Fix clippy warnings #951

Merged
merged 1 commit into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust-code-analysis-cli/src/formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl Format {
let format_path = output_path.as_ref().unwrap().join(filename);

// Create directories
create_dir_all(&format_path.parent().unwrap()).unwrap();
create_dir_all(format_path.parent().unwrap()).unwrap();

let mut format_file = File::create(format_path)?;
match self {
Expand Down
11 changes: 4 additions & 7 deletions src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn read_file(path: &Path) -> std::io::Result<Vec<u8>> {
/// read_file_with_eol(&path).unwrap();
/// ```
pub fn read_file_with_eol(path: &Path) -> std::io::Result<Option<Vec<u8>>> {
let file_size = fs::metadata(&path).map_or(1024 * 1024, |m| m.len() as usize);
let file_size = fs::metadata(path).map_or(1024 * 1024, |m| m.len() as usize);
if file_size <= 3 {
// this file is very likely almost empty... so nothing to do on it
return Ok(None);
Expand Down Expand Up @@ -198,7 +198,7 @@ pub fn guess_language<P: AsRef<Path>>(buf: &[u8], path: P) -> (Option<LANG>, Str
.unwrap_or_else(|| "".to_string());
let from_ext = get_from_ext(&ext);

let mode = get_emacs_mode(buf).unwrap_or_else(|| "".to_string());
let mode = get_emacs_mode(buf).unwrap_or_default();

let from_mode = get_from_emacs_mode(&mode);

Expand All @@ -225,10 +225,7 @@ pub fn guess_language<P: AsRef<Path>>(buf: &[u8], path: P) -> (Option<LANG>, Str
fake::get_true(&ext, &mode).unwrap_or_else(|| lang_mode.get_name().to_string()),
)
} else {
(
None,
fake::get_true(&ext, &mode).unwrap_or_else(|| "".to_string()),
)
(None, fake::get_true(&ext, &mode).unwrap_or_default())
}
}

Expand Down Expand Up @@ -317,7 +314,7 @@ pub(crate) fn guess_file<S: ::std::hash::BuildHasher>(

if let Some(parent) = current_path.parent() {
for p in possibilities.iter() {
if p.starts_with(&parent) && current_path != p {
if p.starts_with(parent) && current_path != p {
new_possibilities.push(p.clone());
}
}
Expand Down
4 changes: 2 additions & 2 deletions tree-sitter-ccomment/bindings/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() {
let src_dir = Path::new("src");

let mut c_config = cc::Build::new();
c_config.include(&src_dir);
c_config.include(src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-Wno-unused-but-set-variable")
Expand All @@ -18,7 +18,7 @@ fn main() {

let mut cpp_config = cc::Build::new();
cpp_config.cpp(true);
cpp_config.include(&src_dir);
cpp_config.include(src_dir);
cpp_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-Wno-unused-but-set-variable");
Expand Down
4 changes: 2 additions & 2 deletions tree-sitter-mozcpp/bindings/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() {
let src_dir = Path::new("src");

let mut c_config = cc::Build::new();
c_config.include(&src_dir);
c_config.include(src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-Wno-unused-but-set-variable")
Expand All @@ -18,7 +18,7 @@ fn main() {

let mut cpp_config = cc::Build::new();
cpp_config.cpp(true);
cpp_config.include(&src_dir);
cpp_config.include(src_dir);
cpp_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-Wno-unused-but-set-variable");
Expand Down
2 changes: 1 addition & 1 deletion tree-sitter-mozjs/bindings/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() {
let src_dir = Path::new("src");

let mut c_config = cc::Build::new();
c_config.include(&src_dir);
c_config.include(src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-Wno-unused-but-set-variable")
Expand Down
4 changes: 2 additions & 2 deletions tree-sitter-preproc/bindings/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() {
let src_dir = Path::new("src");

let mut c_config = cc::Build::new();
c_config.include(&src_dir);
c_config.include(src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-Wno-unused-but-set-variable")
Expand All @@ -18,7 +18,7 @@ fn main() {

let mut cpp_config = cc::Build::new();
cpp_config.cpp(true);
cpp_config.include(&src_dir);
cpp_config.include(src_dir);
cpp_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-Wno-unused-but-set-variable");
Expand Down