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

Clean up filenames produced by rust-code-analysis-cli #400

Merged
merged 1 commit into from
Dec 23, 2020
Merged
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
18 changes: 12 additions & 6 deletions rust-code-analysis-cli/src/formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,23 @@ impl Format {
Format::Yaml => ".yml",
};

// Remove . / \ .. symbols from a path to create a unique filename
// Remove root /
let path = path.strip_prefix("/").unwrap_or(path);

// Remove root ./
let path = path.strip_prefix("./").unwrap_or(path);

// Replace .. symbol with "_" to create a unique filename
let cleaned_path: Vec<&str> = path
.iter()
.filter(|v| {
if let Some(s) = v.to_str() {
![".", ".."].contains(&s)
.map(|os_str| {
let s_str = os_str.to_str().unwrap();
if s_str == ".." {
"_"
} else {
false
s_str
}
})
.map(|s| s.to_str().unwrap())
.collect();

// Create the filename
Expand Down