Fix various warnings raised by sonarcloud

This commit is contained in:
Stefan Ceriu 2022-05-12 13:09:19 +03:00 committed by Stefan Ceriu
parent fd23649f95
commit 5fc10c26a8
9 changed files with 29 additions and 29 deletions

View File

@ -35,20 +35,20 @@ final class ActivityIndicatorPresenter: ActivityIndicatorPresenterType {
private weak var presentingView: UIView? private weak var presentingView: UIView?
var isPresenting: Bool { var isPresenting: Bool {
return self.activityIndicatorView != nil activityIndicatorView != nil
} }
// MARK: - Public // MARK: - Public
func presentActivityIndicator(on view: UIView, animated: Bool, completion: (() -> Void)? = nil) { func presentActivityIndicator(on view: UIView, animated: Bool, completion: (() -> Void)? = nil) {
if self.presentingView != nil { if presentingView != nil {
if let completion = completion { if let completion = completion {
completion() completion()
} }
return return
} }
self.presentingView = view presentingView = view
view.isUserInteractionEnabled = false view.isUserInteractionEnabled = false
@ -77,11 +77,11 @@ final class ActivityIndicatorPresenter: ActivityIndicatorPresenterType {
} }
if animated { if animated {
UIView.animate(withDuration: Constants.animationDuration, animations: { UIView.animate(withDuration: Constants.animationDuration) {
animationInstructions() animationInstructions()
}, completion: { _ in } completion: { _ in
completion?() completion?()
}) }
} else { } else {
animationInstructions() animationInstructions()
completion?() completion?()
@ -109,11 +109,11 @@ final class ActivityIndicatorPresenter: ActivityIndicatorPresenterType {
} }
if animated { if animated {
UIView.animate(withDuration: Constants.animationDuration, animations: { UIView.animate(withDuration: Constants.animationDuration) {
animationInstructions() animationInstructions()
}, completion: { _ in } completion: { _ in
animationCompletionInstructions() animationCompletionInstructions()
}) }
} else { } else {
animationInstructions() animationInstructions()
animationCompletionInstructions() animationCompletionInstructions()
@ -134,7 +134,7 @@ private extension UIView {
/// Add a subview matching parent view using autolayout /// Add a subview matching parent view using autolayout
@objc func vc_addSubViewMatchingParent(_ subView: UIView) { @objc func vc_addSubViewMatchingParent(_ subView: UIView) {
self.addSubview(subView) addSubview(subView)
subView.translatesAutoresizingMaskIntoConstraints = false subView.translatesAutoresizingMaskIntoConstraints = false
let views = ["view": subView] let views = ["view": subView]
["H:|[view]|", "V:|[view]|"].forEach { vfl in ["H:|[view]|", "V:|[view]|"].forEach { vfl in

View File

@ -25,10 +25,10 @@ protocol ActivityIndicatorPresenterType {
// `ActivityIndicatorPresenterType` default implementation // `ActivityIndicatorPresenterType` default implementation
extension ActivityIndicatorPresenterType { extension ActivityIndicatorPresenterType {
func presentActivityIndicator(on view: UIView, animated: Bool) { func presentActivityIndicator(on view: UIView, animated: Bool) {
self.presentActivityIndicator(on: view, animated: animated, completion: nil) presentActivityIndicator(on: view, animated: animated, completion: nil)
} }
func removeCurrentActivityIndicator(animated: Bool) { func removeCurrentActivityIndicator(animated: Bool) {
self.removeCurrentActivityIndicator(animated: animated, completion: nil) removeCurrentActivityIndicator(animated: animated, completion: nil)
} }
} }

View File

@ -46,7 +46,7 @@ final class ActivityIndicatorView: UIView {
// MARK: - Setup // MARK: - Setup
private func commonInit() { private func commonInit() {
self.activityIndicatorBackgroundView.layer.masksToBounds = true activityIndicatorBackgroundView.layer.masksToBounds = true
} }
convenience init() { convenience init() {
@ -55,37 +55,37 @@ final class ActivityIndicatorView: UIView {
required init?(coder aDecoder: NSCoder) { required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder) super.init(coder: aDecoder)
self.loadNibContent() loadNibContent()
self.commonInit() commonInit()
} }
override init(frame: CGRect) { override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
self.loadNibContent() loadNibContent()
self.commonInit() commonInit()
} }
// MARK: - Overrides // MARK: - Overrides
override var intrinsicContentSize: CGSize { override var intrinsicContentSize: CGSize {
return CGSize(width: self.activityIndicatorView.intrinsicContentSize.width + Constants.activityIndicatorMargin.width, return CGSize(width: activityIndicatorView.intrinsicContentSize.width + Constants.activityIndicatorMargin.width,
height: self.activityIndicatorView.intrinsicContentSize.height + Constants.activityIndicatorMargin.height) height: activityIndicatorView.intrinsicContentSize.height + Constants.activityIndicatorMargin.height)
} }
override func layoutSubviews() { override func layoutSubviews() {
super.layoutSubviews() super.layoutSubviews()
self.activityIndicatorBackgroundView.layer.cornerRadius = Constants.cornerRadius activityIndicatorBackgroundView.layer.cornerRadius = Constants.cornerRadius
} }
// MARK: - Public // MARK: - Public
func startAnimating() { func startAnimating() {
self.activityIndicatorView.startAnimating() activityIndicatorView.startAnimating()
} }
func stopAnimating() { func stopAnimating() {
self.activityIndicatorView.stopAnimating() activityIndicatorView.stopAnimating()
} }
} }
@ -98,7 +98,7 @@ private extension UIView {
let layoutAttributes: [NSLayoutConstraint.Attribute] = [.top, .leading, .bottom, .trailing] let layoutAttributes: [NSLayoutConstraint.Attribute] = [.top, .leading, .bottom, .trailing]
for case let view as UIView in type(of: self).nib.instantiate(withOwner: self, options: nil) { for case let view as UIView in type(of: self).nib.instantiate(withOwner: self, options: nil) {
view.translatesAutoresizingMaskIntoConstraints = false view.translatesAutoresizingMaskIntoConstraints = false
self.addSubview(view) addSubview(view)
NSLayoutConstraint.activate(layoutAttributes.map { attribute in NSLayoutConstraint.activate(layoutAttributes.map { attribute in
NSLayoutConstraint( NSLayoutConstraint(
item: view, attribute: attribute, item: view, attribute: attribute,

View File

@ -52,7 +52,7 @@ final class LabelledActivityIndicatorView: UIView {
}() }()
private let label: UILabel = { private let label: UILabel = {
return UILabel() UILabel()
}() }()
init(text: String) { init(text: String) {

View File

@ -58,7 +58,7 @@ class RoundedToastView: UIView {
}() }()
private let label: UILabel = { private let label: UILabel = {
return UILabel() UILabel()
}() }()
init(viewState: ToastViewState) { init(viewState: ToastViewState) {

View File

@ -37,6 +37,6 @@ public class StaticUserIndicatorPresentationContext: UserIndicatorPresentationCo
public private(set) weak var indicatorPresentingViewController: UIViewController? public private(set) weak var indicatorPresentingViewController: UIViewController?
public init(viewController: UIViewController) { public init(viewController: UIViewController) {
self.indicatorPresentingViewController = viewController indicatorPresentingViewController = viewController
} }
} }

View File

@ -49,7 +49,7 @@ class UserIndicatorTypePresenter: UserIndicatorTypePresenterProtocol {
init(presentationContext: UserIndicatorPresentationContext) { init(presentationContext: UserIndicatorPresentationContext) {
self.presentationContext = presentationContext self.presentationContext = presentationContext
self.queue = UserIndicatorQueue() queue = UserIndicatorQueue()
} }
convenience init(presentingViewController: UIViewController) { convenience init(presentingViewController: UIViewController) {

View File

@ -27,7 +27,7 @@ typealias UserIndicatorCancel = () -> Void
init(presenter: UserIndicatorTypePresenterProtocol) { init(presenter: UserIndicatorTypePresenterProtocol) {
self.presenter = presenter self.presenter = presenter
self.indicators = [] indicators = []
} }
/// Present a new type of user indicator, such as loading spinner or success message. /// Present a new type of user indicator, such as loading spinner or success message.

View File

@ -64,7 +64,7 @@ final class TemplateSimpleScreenCoordinator: Coordinator, Presentable {
} }
func toPresentable() -> UIViewController { func toPresentable() -> UIViewController {
return self.templateSimpleScreenHostingController templateSimpleScreenHostingController
} }
// MARK: - Private // MARK: - Private