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

chore: sonarcloud updates #845

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 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
10 changes: 9 additions & 1 deletion .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ jobs:
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
uses: sonarsource/sonarqube-scan-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: https://sonarcloud.io./
- name: SonarQube Quality Gate check
id: sonarqube-quality-gate-check
uses: sonarsource/sonarqube-quality-gate-action@master
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: https://sonarcloud.io./
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@
BlueprintName = "PrimerSDKTests"
ReferencedContainer = "container:">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "HUC_TokenizationViewModelTests">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
</TestAction>
Expand Down
104 changes: 52 additions & 52 deletions Debug App/Primer.io Debug App.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Debug App/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if let url = userActivity.webpageURL {
let handled = AppetizeUrlHandler.handleUrl(url)
if handled == true {
if handled {
return handled
}
}
Expand Down
2 changes: 1 addition & 1 deletion Debug App/Sources/Model/CreateClientToken.swift
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ struct ClientSessionRequestBody {
dic["extraMerchantData"] = extraMerchantData
}

if let captureVaultedCardCvv = captureVaultedCardCvv, captureVaultedCardCvv == true {
if let captureVaultedCardCvv = captureVaultedCardCvv, captureVaultedCardCvv {
dic["captureVaultedCardCvv"] = captureVaultedCardCvv
}

Expand Down
2 changes: 1 addition & 1 deletion Debug App/Sources/Utilities/AppetizeConfigProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class AppetizeConfigProvider {
}

func fetchConfig() -> SessionConfiguration? {
guard payloadProvider.isAppetize == true,
guard let isAppetize = payloadProvider.isAppetize, isAppetize,
let jwt = payloadProvider.configJwt,
let config = getConfig(from: jwt) else {
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ class MerchantSessionAndSettingsViewController: UIViewController {
func populateSessionSettingsFields() {
clientSession = MerchantMockDataManager.getClientSession(sessionType: paymentSessionType)

enableCVVRecaptureFlowSwitch.isOn = clientSession.paymentMethod?.options?.PAYMENT_CARD?.captureVaultedCardCvv == true
enableCVVRecaptureFlowSwitch.isOn = clientSession.paymentMethod?.options?.PAYMENT_CARD?.captureVaultedCardCvv ?? false

currencyTextField.text = clientSession.currencyCode?.code
countryCodeTextField.text = clientSession.order?.countryCode?.rawValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal class Connectivity {
if needsConnection { return .none }
if !isReachable { return .none }

if flags.contains(.isWWAN) == true {
if flags.contains(.isWWAN) {
return .cellular
} else {
return .wifi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ final class BanksTokenizationComponent: NSObject, LogReporter {

func handleDecodedClientTokenIfNeeded(_ decodedJWTToken: DecodedJWTToken) -> Promise<String?> {
return Promise { seal in
if decodedJWTToken.intent?.contains("_REDIRECTION") == true {
if let intent = decodedJWTToken.intent, intent.contains("_REDIRECTION") {
if let redirectUrlStr = decodedJWTToken.redirectUrl,
let redirectUrl = URL(string: redirectUrlStr),
let statusUrlStr = decodedJWTToken.statusUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ extension PrimerHeadlessKlarnaComponent: PrimerKlarnaProviderAuthorizationDelega
*/
public func primerKlarnaWrapperAuthorized(approved: Bool, authToken: String?, finalizeRequired: Bool) {
isFinalizationRequired = finalizeRequired
if approved == false {
if finalizeRequired == true {
if approved {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • ⚠️ Opening braces should be preceded by a single space and on the same line as the declaration. (opening_brace)

if finalizeRequired {
let step = KlarnaStep.paymentSessionFinalizationRequired
stepDelegate?.didReceiveStep(step: step)
} else {
createSessionError(.klarnaAuthorizationFailed)
}
}
if let authToken = authToken, approved == true {
if let authToken = authToken, approved {
if PrimerInternal.shared.sdkIntegrationType == .headless {
finalizeSession(token: authToken, fromAuthorization: true)
} else {
Expand All @@ -80,7 +80,7 @@ extension PrimerHeadlessKlarnaComponent: PrimerKlarnaProviderAuthorizationDelega
self.stepDelegate?.didReceiveStep(step: step)
}
}
if finalizeRequired == true {
if finalizeRequired {
let step = KlarnaStep.paymentSessionFinalizationRequired
stepDelegate?.didReceiveStep(step: step)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ extension PrimerHeadlessKlarnaComponent: PrimerKlarnaProviderFinalizationDelegat
* - `authToken` - An optional `String` containing the authorization token, which is returned only if `approved` is `true`.
*/
public func primerKlarnaWrapperFinalized(approved: Bool, authToken: String?) {
if approved == false {
if approved {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • ⚠️ Opening braces should be preceded by a single space and on the same line as the declaration. (opening_brace)

createSessionError(.klarnaFinalizationFailed)
}
if let authToken = authToken, approved == true {
if let authToken = authToken, approved {
if PrimerInternal.shared.sdkIntegrationType == .headless {
finalizeSession(token: authToken, fromAuthorization: false)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ Make sure you call the decision handler otherwise the SDK will hang.
seal.reject(err)
}

} else if decodedJWTToken.intent?.contains("_REDIRECTION") == true {
} else if let intent = decodedJWTToken.intent, intent.contains("_REDIRECTION") {
if let redirectUrlStr = decodedJWTToken.redirectUrl,
let redirectUrl = URL(string: redirectUrlStr),
let statusUrlStr = decodedJWTToken.statusUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ Make sure you call the decision handler otherwise the SDK will hang."
seal.reject(err)
}

} else if decodedJWTToken.intent?.contains("_REDIRECTION") == true {
} else if let intent = decodedJWTToken.intent, intent.contains("_REDIRECTION") {
if let statusUrlStr = decodedJWTToken.statusUrl,
let statusUrl = URL(string: statusUrlStr),
decodedJWTToken.intent != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ extension PrimerHeadlessUniversalCheckout {
seal.reject(err)
}

} else if decodedJWTToken.intent?.contains("_REDIRECTION") == true {
} else if let intent = decodedJWTToken.intent, intent.contains("_REDIRECTION") {
if let statusUrlStr = decodedJWTToken.statusUrl,
let statusUrl = URL(string: statusUrlStr),
decodedJWTToken.intent != nil {
Expand Down
2 changes: 1 addition & 1 deletion Sources/PrimerSDK/Classes/Data Models/ClientToken.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ struct DecodedJWTToken: Codable {
try? container.encode(expDate?.timeIntervalSince1970, forKey: .expiration)
try? container.encode(expDate?.timeIntervalSince1970, forKey: .exp)

if qrCode?.isHttpOrHttpsURL == true {
if let qrCode = qrCode, qrCode.isHttpOrHttpsURL {
try? container.encode(qrCode, forKey: .qrCodeUrl)
} else {
try? container.encode(qrCode, forKey: .qrCode)
Expand Down
2 changes: 1 addition & 1 deletion Sources/PrimerSDK/Classes/Data Models/OrderItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal struct OrderItem: Codable {
let tmpTaxAmount = taxAmount ?? 0
let tmpTotalOrderItemAmount = tmpAmount - tmpDiscountAmount + tmpTaxAmount

if AppState.current.currency?.isZeroDecimal == true {
if let currency = AppState.current.currency, currency.isZeroDecimal {
applePayItemAmount = NSDecimalNumber(value: tmpTotalOrderItemAmount)
} else {
applePayItemAmount = NSDecimalNumber(value: tmpTotalOrderItemAmount).dividing(by: 100)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ extension Response.Body {

let supportedNetworks = ApplePayUtils.supportedPKPaymentNetworks()
var canMakePayment: Bool
if PrimerSettings.current.paymentMethodOptions.applePayOptions?.checkProvidedNetworks == true {
if let options = PrimerSettings.current.paymentMethodOptions.applePayOptions, options.checkProvidedNetworks {
canMakePayment = PKPaymentAuthorizationController.canMakePayments(usingNetworks: supportedNetworks)
} else {
canMakePayment = PKPaymentAuthorizationController.canMakePayments()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ extension KeyedDecodingContainer {
guard contains(key) else {
return nil
}
guard try decodeNil(forKey: key) == false else {
guard try decodeNil(forKey: key) else {
return nil
}
return try decode(type, forKey: key)
Expand All @@ -85,7 +85,7 @@ extension KeyedDecodingContainer {
guard contains(key) else {
return nil
}
guard try decodeNil(forKey: key) == false else {
guard try decodeNil(forKey: key) else {
return nil
}
return try decode(type, forKey: key)
Expand Down Expand Up @@ -117,7 +117,7 @@ extension UnkeyedDecodingContainer {

mutating func decode(_ type: Array<Any>.Type) throws -> [Any] {
var array: [Any] = []
while isAtEnd == false {
while isAtEnd {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • ⚠️ Opening braces should be preceded by a single space and on the same line as the declaration. (opening_brace)

// See if the current value in the JSON array is `null` first and prevent infite recursion with nested arrays.
if try decodeNil() {
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ class ImageFileProcessor {
}

let coloredImageFile = paymentMethodImageFiles
.filter({ $0.fileName.contains("dark") == false && $0.fileName.contains("light") == false }).first
.filter({ $0.fileName.contains("dark") && $0.fileName.contains("light") }).first
let darkImageFile = paymentMethodImageFiles
.filter({ $0.fileName.contains("dark") == true }).first
.filter({ $0.fileName.contains("dark") }).first
let lightImageFile = paymentMethodImageFiles
.filter({ $0.fileName.contains("light") == true }).first
.filter({ $0.fileName.contains("light") }).first

let baseImage = PrimerTheme.BaseImage(
colored: coloredImageFile?.image,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ClientSessionActionsModule: ClientSessionActionsProtocol {
return
}

if (PrimerAPIConfigurationModule.apiConfiguration?.hasSurchargeEnabled ?? false) == false {
if (PrimerAPIConfigurationModule.apiConfiguration?.hasSurchargeEnabled ?? false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • ⚠️ Opening braces should be preceded by a single space and on the same line as the declaration. (opening_brace)
  • ⚠️ if, for, guard, switch, while, and catch statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses. (control_statement)

seal.fulfill()
return
}
Expand Down Expand Up @@ -65,7 +65,7 @@ class ClientSessionActionsModule: ClientSessionActionsProtocol {
return
}

if (PrimerAPIConfigurationModule.apiConfiguration?.hasSurchargeEnabled ?? false) == false {
if (PrimerAPIConfigurationModule.apiConfiguration?.hasSurchargeEnabled ?? false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • ⚠️ Opening braces should be preceded by a single space and on the same line as the declaration. (opening_brace)
  • ⚠️ if, for, guard, switch, while, and catch statements shouldn't unnecessarily wrap their conditionals or arguments in parentheses. (control_statement)

seal.fulfill()
return
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/PrimerSDK/Classes/Modules/ImageManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ internal class ImageFile: File {
var bundledImage: UIImage? {
let paymentMethodType = ImageFile.getPaymentMethodType(fromFileName: self.fileName) ?? self.fileName

if self.fileName.contains("dark") == true {
if self.fileName.contains("dark") {
if let paymentMethodLogoFileName = ImageFile.getBundledImageFileName(forPaymentMethodType: paymentMethodType,
themeMode: .dark,
assetType: .logo),
Expand All @@ -81,7 +81,7 @@ internal class ImageFile: File {
compatibleWith: nil) {
return image
}
} else if self.fileName.contains("light") == true {
} else if self.fileName.contains("light") {
if let paymentMethodLogoFileName = ImageFile.getBundledImageFileName(forPaymentMethodType: paymentMethodType,
themeMode: .light,
assetType: .logo),
Expand All @@ -94,7 +94,7 @@ internal class ImageFile: File {
compatibleWith: nil) {
return image
}
} else if self.fileName.contains("colored") == true {
} else if self.fileName.contains("colored") {
if let paymentMethodLogoFileName = ImageFile.getBundledImageFileName(forPaymentMethodType: paymentMethodType,
themeMode: .colored,
assetType: .logo),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ class UserInterfaceModule: NSObject, UserInterfaceModuleProtocol {
}()

var isSubmitButtonAnimating: Bool {
submitButton?.isAnimating == true
submitButton?.isAnimating ?? false
}

// MARK: - INITIALIZATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ internal class URLSessionStack: NetworkService, LogReporter {
}
#endif

if endpoint.shouldParseResponseBody == false, httpResponse?.statusCode == 200 {
if endpoint.shouldParseResponseBody , httpResponse?.statusCode == 200 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • ⚠️ There should be no space before and one after any comma. (comma)

guard let dummyRes: T = DummySuccess(success: true) as? T
else {
fatalError()
Expand Down
Loading
Loading