Rewrite your app in Rust, piece by piece, checked against the original at every step. Works with TypeScript, JavaScript, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, PowerShell and Swift.
Rust agent-skillsclaude-codeclicode-migrationcodexffigolangjavajavascriptmcpmigrationnapiperformanceportingpyo3pythonrewriterubyrusttypescript
analyze: count a Swift or PowerShell clock call once (#1425)
jakalijey7796b33f6b54
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 769fb83f..3c70060d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -287,6 +287,9 @@- PowerShell: a parameter typed `[decimal]`, `[uint64]` or `[ulong]` keeps its function inPowerShell, with the reasons C# gives for the same types, instead of bridging it as `f64` or`i64`. `[uint32]`, `[double]` and `[single]` bridge as before (#1341 by @jakalijey).+- `analyze` counts a Swift or PowerShell clock call once: `Date()`, `.random`, `Get-Date`,+ `Get-Random` and `New-Guid` were counted by both the syntax scan and the text list, which made+ one call read "Clock and random numbers (2)" (#1401 by @jakalijey).- TS/JS: `bridge` keeps a function that calls `os.tmpdir()` or `os.userInfo()`, and `analyze` flags`process.cwd()`, `os.homedir()`, `os.hostname()`, `os.tmpdir()` and `os.userInfo()` as stateoutside the arguments, as it did `process.env` (#1408 by @jakalijey).diff --git a/src/lang/effects.rs b/src/lang/effects.rsindex a383dec7..a263f4ce 100644--- a/src/lang/effects.rs+++ b/src/lang/effects.rs@@ -1163,8 +1163,13 @@ pub fn scan_risks(lang: Lang, source: &str, facts: &mut crate::ts::scan::FileFac};find_all(line, &needle).next().is_some()});+ // The Swift and PowerShell syntax scans already add some of these calls (`Date(`,+ // `Get-Date`): one call is one hit, not one per pass (#1401).if hit {- facts.risks.entry(*risk).or_default().push(line_no);+ let lines = facts.risks.entry(*risk).or_default();+ if !lines.contains(&line_no) {+ lines.push(line_no);+ }}}}@@ -1662,6 +1667,22 @@ mod tests {#[test]fn scans_list_environment_clock_and_hash_order_in_every_spelling() {use crate::risks::Risk;+ // A call the syntax scan and the text list both know is counted once (#1401).+ for (lang, path, code) in [+ (+ Lang::Swift,+ "T.swift",+ "func f() -> Date { return Date() }\n",+ ),+ (Lang::Powershell, "Stamp.psm1", "function F { Get-Date }\n"),+ ] {+ let facts = crate::lang::scan(lang, path, code);+ assert_eq!(+ facts.risks.get(&Risk::ClockAndRandom),+ Some(&vec![1]),+ "{lang:?}: {code}"+ );+ }let cases: &[(Lang, &str, &str, Risk)] = &[(Lang::Csharp,