From a210f55055bac528073358a2ec2c0867ec555137 Mon Sep 17 00:00:00 2001 From: Mostafa Nafie Date: Sat, 12 Jul 2025 22:02:09 +0300 Subject: [PATCH] Test SonarQube --- .../Presentation/CharacterListViewModel.swift | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/ModularSwiftUI/ModularSwiftUI/Sources/Features/CharacterList/Presentation/CharacterListViewModel.swift b/ModularSwiftUI/ModularSwiftUI/Sources/Features/CharacterList/Presentation/CharacterListViewModel.swift index 6e2f88b..74f941e 100644 --- a/ModularSwiftUI/ModularSwiftUI/Sources/Features/CharacterList/Presentation/CharacterListViewModel.swift +++ b/ModularSwiftUI/ModularSwiftUI/Sources/Features/CharacterList/Presentation/CharacterListViewModel.swift @@ -46,6 +46,45 @@ public final class CharacterListViewModel { await interactor.setSelectedCharacter(with: id) coordinator.didTapCharacter() } + + // Function that will fail SonarQube analysis + func problematicFunction() { + var unusedVariable = "This variable is never used" + let anotherUnused = 42 + + // Dead code + if false { + print("This will never execute") + } + + // Magic numbers + let timeout = 30 + let maxRetries = 3 + + // Duplicate code + for i in 0..<10 { + print("Processing item \(i)") + } + + for j in 0..<10 { + print("Processing item \(j)") + } + + // Complex nested conditions + if timeout > 0 { + if maxRetries > 0 { + if unusedVariable.count > 0 { + if anotherUnused > 0 { + print("Too many nested conditions") + } + } + } + } + + // Unused parameter (if this was a function with parameters) + let _ = unusedVariable + let _ = anotherUnused + } } private extension CharacterListViewModel {