Skip to content

Commit fe80b8e

Browse files
committed
Initialize Ruby code ranges directly
Fixes the clippy::needless_late_init lint error reported by Clippy 1.98. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: aaf47101-2cb9-4d38-9f6a-e492c4da4135
1 parent f4cfb56 commit fe80b8e

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

‎ruby/extractor/src/extractor.rs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,8 @@ pub fn run(options: Options) -> std::io::Result<()> {
114114
let src_archive_file = file_paths::path_for(&src_archive_dir, &path, "", path_transformer.as_ref());
115115
let mut source = std::fs::read(&path)?;
116116
let mut needs_conversion = false;
117-
let code_ranges;
118117
let mut trap_writer = trap::Writer::new();
119-
if path.extension().is_some_and(|x| x == "erb") {
118+
let code_ranges = if path.extension().is_some_and(|x| x == "erb") {
120119
tracing::info!("scanning: {}", path.display());
121120
extractor::extract(
122121
&erb,
@@ -142,7 +141,7 @@ pub fn run(options: Options) -> std::io::Result<()> {
142141
source[i] = b'\n';
143142
}
144143
}
145-
code_ranges = ranges;
144+
ranges
146145
} else {
147146
if let Some(encoding_name) = scan_coding_comment(&source) {
148147
// If the input is already UTF-8 then there is no need to recode the source
@@ -204,8 +203,8 @@ pub fn run(options: Options) -> std::io::Result<()> {
204203
}
205204
}
206205
}
207-
code_ranges = vec![];
208-
}
206+
vec![]
207+
};
209208
extractor::extract(
210209
&language,
211210
"ruby",

0 commit comments

Comments
 (0)