Skip to content

Commit

Permalink
chore: added sonarcloud analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
pallabmaiti authored Mar 16, 2024
1 parent 7efaa61 commit a7eff6b
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 40 deletions.
4 changes: 2 additions & 2 deletions .github/workflow/build.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
workflow_id: ${{ github.event.workflow.id }}

build:
name: 'Tests & Coverage(v2)'
name: 'Tests & Coverage'
needs: cancel_previous
runs-on: macos-latest
env:
Expand All @@ -33,7 +33,7 @@ jobs:

- name: Run tests(iOS)
run: |
xcodebuild -project FindingFalcon.xcodeproj -scheme FindingFalconTests test -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15' -enableCodeCoverage YES -derivedDataPath build | xcpretty
xcodebuild -project FindingFalcon.xcodeproj -scheme FindingFalconTests test -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -enableCodeCoverage YES -derivedDataPath build | xcpretty
- name: Collect coverage into one XML report
run: |
Expand Down
12 changes: 6 additions & 6 deletions FindingFalcon.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
Expand Down Expand Up @@ -666,7 +666,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
Expand Down Expand Up @@ -696,7 +696,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.0.0;
PRODUCT_BUNDLE_IDENTIFIER = com.pallab.FindingFalcon;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -725,7 +725,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.0.0;
PRODUCT_BUNDLE_IDENTIFIER = com.pallab.FindingFalcon;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -743,7 +743,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 53MFN587RT;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.pallab.FindingFalconTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -763,7 +763,7 @@
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 53MFN587RT;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.pallab.FindingFalconTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
8 changes: 2 additions & 6 deletions FindingFalcon/FindFalcon/FindFalconView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ struct FindFalconView: View {
var interactor: FindFalconBusinessLogic?
var router: FindFalconRouter?

@State private var dataStore = FindFalconDataStore()
@State private var dataModel = FindFalconDataModel()
@ObservedObject private var dataStore = FindFalconDataStore()
@ObservedObject private var dataModel = FindFalconDataModel()

var body: some View {
NavigationView {
Expand Down Expand Up @@ -125,7 +125,3 @@ extension FindFalconView {
print(error.localizedDescription)
}
}

//#Preview {
// FindFalconView().configureView()
//}
24 changes: 13 additions & 11 deletions FindingFalcon/FindFalcon/Models/FindFalconDataModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ enum DestinationType {
case four
}

@Observable
final class Destination: Identifiable {
var planetList: [Planet] = []
var vehicleList: [Vehicle] = []
var selectedVehicle: Vehicle?
var selectedPlanet: Planet?
final class Destination: ObservableObject, Identifiable {
@Published var planetList: [Planet] = []
@Published var vehicleList: [Vehicle] = []
@Published var selectedVehicle: Vehicle?
@Published var selectedPlanet: Planet?
let id = UUID()

var timeTaken: Int {
Expand Down Expand Up @@ -55,9 +54,8 @@ final class Destination: Identifiable {
}
}

@Observable
final class FindFalconDataModel {
var destinations: [Destination]
final class FindFalconDataModel: ObservableObject {
@Published var destinations: [Destination]

var totalTimeTaken: Int {
return destinations.map{ $0.timeTaken }.reduce(0) { $0 + $1 }
Expand Down Expand Up @@ -92,12 +90,14 @@ final class FindFalconDataModel {
for i in (index + 1)..<destinations.count {
destinations[i].resetVehicle()
}
destinations[index + 1].vehicleList = destination.vehicleList.map{ Vehicle(
let nextDestination = destinations[index + 1]
nextDestination.vehicleList = destination.vehicleList.map{ Vehicle(
name: $0.name,
totalNo: ($0.name == destination.selectedVehicle?.name) ? ($0.totalNo - 1) : $0.totalNo,
maxDistance: $0.maxDistance,
speed: $0.speed
) }
destinations[index + 1] = nextDestination
}
}

Expand All @@ -106,9 +106,11 @@ final class FindFalconDataModel {
for i in (index + 1)..<destinations.count {
destinations[i].resetPlanet()
}
let nextDestination = destinations[index + 1]
var pList = destination.planetList.map{ Planet(name: $0.name, distance: $0.distance) }
pList.removeAll(where: { $0.name == destination.selectedPlanet?.name })
destinations[index + 1].planetList = pList
nextDestination.planetList = pList
destinations[index + 1] = nextDestination
}
}
}
11 changes: 5 additions & 6 deletions FindingFalcon/FindFalcon/Models/FindFalconDataStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

import Foundation

@Observable
final class FindFalconDataStore {
var planetList: [Planet] = []
var vehicleList: [Vehicle] = []
var token: Token?
var isLoading = true
final class FindFalconDataStore: ObservableObject {
@Published var planetList: [Planet] = []
@Published var vehicleList: [Vehicle] = []
@Published var token: Token?
@Published var isLoading = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SwiftUI
import Combine

struct DestinationView: View {
var destination: Destination
@ObservedObject var destination: Destination
var onVehicleSelect: (() -> Void)?
var onPlanetSelect: (() -> Void)?

Expand Down
2 changes: 1 addition & 1 deletion FindingFalcon/Networking/APIResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ enum Status {
}

var needsRetry: Bool {
return self == .unauthorized ? true : false
return self == .unauthorized
}
}
6 changes: 3 additions & 3 deletions FindingFalconTests/FindFalcon/FindFalconDataModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ final class FindFalconDataModelTests: XCTestCase {

func test_DataModel() {
let planet1: Planet = .mockRandom(name: .mockRandom(), distance: 200)
var planet2: Planet = .mockRandom(name: .mockRandom(), distance: 300)
let planet2: Planet = .mockRandom(name: .mockRandom(), distance: 300)
let planet3: Planet = .mockRandom(name: .mockRandom(), distance: 100)

var planets: [Planet] = [planet1, planet2, planet3]
let planets: [Planet] = [planet1, planet2, planet3]

let vehicle1: Vehicle = .mockRandom(name: .mockRandom(), totalNo: 2, maxDistance: 200, speed: 2)
let vehicle2: Vehicle = .mockRandom(name: .mockRandom(), totalNo: 1, maxDistance: 300, speed: 2)
let vehicle3: Vehicle = .mockRandom(name: .mockRandom(), totalNo: 1, maxDistance: 100, speed: 2)

var vehicles: [Vehicle] = [vehicle1, vehicle2, vehicle3]
let vehicles: [Vehicle] = [vehicle1, vehicle2, vehicle3]

let destination1: Destination = .mockRandom(name: .mockRandom(), planetList: [], vehicleList: [], selectedVehicle: nil, selectedPlanet: nil)
let destination2: Destination = .mockRandom(name: .mockRandom(), planetList: [], vehicleList: [], selectedVehicle: nil, selectedPlanet: nil)
Expand Down
4 changes: 2 additions & 2 deletions FindingFalconTests/FindFalcon/FindFalconViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import XCTest
@testable import FindingFalcon

final class FindFalconViewTests: XCTestCase {
func test_retrieveToken() async {
@MainActor func test_retrieveToken() async {
var view = FindFalconView()

let interactor = FindFalconInteractorMock()
Expand All @@ -20,7 +20,7 @@ final class FindFalconViewTests: XCTestCase {
XCTAssertTrue(interactor.retrieveTokenCalled)
}

func test_getPlanetsAndVehicles() async {
@MainActor func test_getPlanetsAndVehicles() async {
var view = FindFalconView()

let interactor = FindFalconInteractorMock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Foundation
class FindFalconInteractorMock: FindFalconBusinessLogic {
var retrieveTokenCalled = false
var getPlanetsAndVehiclesCalled = false
var startAgainCalled = false

func retrieveToken() async throws {
retrieveTokenCalled = true
Expand All @@ -19,4 +20,8 @@ class FindFalconInteractorMock: FindFalconBusinessLogic {
func getPlanetsAndVehicles() async throws {
getPlanetsAndVehiclesCalled = true
}

func startAgain() {
startAgainCalled = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class FoundFalconInteractorTests: XCTestCase {

interactor.startAgain()

wait(for: [expectation])
waitForExpectations(timeout: 1.0)
}

@MainActor func test_getTotalTimeTaken() async throws {
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sonar.coverageReportPaths=generic-coverage.xml
sonar.sources=RudderCore/Sources

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
sonar.sources=FindingFalcon/FindingFalcon,FindingFalcon/FoundFalcon,FindingFalcon/Networking
sonar.sources=FindingFalcon/FindFalcon,FindingFalcon/FoundFalcon,FindingFalcon/Networking

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8

0 comments on commit a7eff6b

Please sign in to comment.