Count lines in a file
(path: &Path)
| 3294 | |
| 3295 | /// Count lines in a file |
| 3296 | fn count_lines(path: &Path) -> Result<usize> { |
| 3297 | if !path.exists() { |
| 3298 | return Ok(0); |
| 3299 | } |
| 3300 | |
| 3301 | let raw = fs::read(path)?; |
| 3302 | let content = String::from_utf8_lossy(&raw); |
| 3303 | Ok(content.lines().filter(|line| !line.trim().is_empty()).count()) |
| 3304 | } |
| 3305 | |
| 3306 | /// Parse JSON outputs in object-per-line or full JSON formats and return JSON objects. |
| 3307 | fn parse_json_objects_from_content(content: &str) -> Vec<serde_json::Value> { |
no outgoing calls
no test coverage detected