Code Quality: Make sonar happier

by removing some code smells
This commit is contained in:
manuroe
2020-08-25 18:48:09 +02:00
parent 1325607bf3
commit efbca319f0
29 changed files with 20 additions and 271 deletions

1
.gitignore vendored
View File

@@ -34,5 +34,6 @@ fastlane/report.xml
fastlane/Reports
fastlane/README.md
fastlane/Preview.html
fastlane/metadata/
provisioning_profiles/

View File

@@ -24,7 +24,8 @@ Translations:
*
Others:
* Ignore fastlane/Preview.html
* Ignore fastlane/Preview.html
* SonarCloud: Fix some code smells.
Build:
*

View File

@@ -74,7 +74,7 @@ extern NSString *const AppDelegateUniversalLinkDidChangeNotification;
/**
Let the AppDelegate handle and display self verification requests.
Default is YES;
Default is YES.
*/
@property (nonatomic) BOOL handleSelfVerificationRequest;

View File

@@ -413,23 +413,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
NSLog(@"[AppDelegate] didFinishLaunchingWithOptions");
#endif
// User credentials (in MXKAccount) are no more stored in NSUserDefaults but in a file
// as advised at https://forums.developer.apple.com/thread/15685#45849.
// So, there is no more need to loop (sometimes forever) until
// [application isProtectedDataAvailable] becomes YES.
// But, as we are not so sure, loop but no more than 10s.
// // TODO: Remove this loop.
// NSUInteger loopCount = 0;
//
// // Check whether the content protection is active before going further.
// // Should fix the spontaneous logout.
// while (![application isProtectedDataAvailable] && loopCount++ < 50)
// {
// // Wait for protected data.
// [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.2f]];
// }
//
// NSLog(@"[AppDelegate] didFinishLaunchingWithOptions: isProtectedDataAvailable: %@ (%tu)", @([application isProtectedDataAvailable]), loopCount);
NSLog(@"[AppDelegate] didFinishLaunchingWithOptions: isProtectedDataAvailable: %@", @([application isProtectedDataAvailable]));
_configuration = [AppConfiguration new];
@@ -1995,14 +1978,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
// Use MXFileStore as MXStore to permanently store events.
accountManager.storeClass = [MXFileStore class];
// Disable APNS use.
// if (accountManager.apnsDeviceToken)
// {
// // We use now Pushkit, unregister for all remote notifications received via Apple Push Notification service.
// [[UIApplication sharedApplication] unregisterForRemoteNotifications];
// [accountManager setApnsDeviceToken:nil];
// }
// Observers have been defined, we can start a matrix session for each enabled accounts.
NSLog(@"[AppDelegate] initMatrixSessions: prepareSessionForActiveAccounts (app state: %tu)", [[UIApplication sharedApplication] applicationState]);
@@ -2432,6 +2407,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
// Stay in launching during the first server sync if the store is empty.
isLaunching = (mainSession.rooms.count == 0 && launchAnimationContainerView);
default:
isLaunching = NO;
break;
}

View File

@@ -135,7 +135,8 @@ internal struct ImageAsset {
#if os(iOS) || os(tvOS)
let image = Image(named: name, in: bundle, compatibleWith: nil)
#elseif os(macOS)
let image = bundle.image(forResource: NSImage.Name(name))
let name = NSImage.Name(self.name)
let image = (bundle == .main) ? NSImage(named: name) : bundle.image(forResource: name)
#elseif os(watchOS)
let image = Image(named: name)
#endif

View File

@@ -52,8 +52,7 @@ internal enum InfoPlist {
// MARK: - Implementation Details
private func arrayFromPlist<T>(at path: String) -> [T] {
let bundle = BundleToken.bundle
guard let url = bundle.url(forResource: path, withExtension: nil),
guard let url = BundleToken.bundle.url(forResource: path, withExtension: nil),
let data = NSArray(contentsOf: url) as? [T] else {
fatalError("Unable to load PLIST at path: \(path)")
}
@@ -64,8 +63,7 @@ private struct PlistDocument {
let data: [String: Any]
init(path: String) {
let bundle = BundleToken.bundle
guard let url = bundle.url(forResource: path, withExtension: nil),
guard let url = BundleToken.bundle.url(forResource: path, withExtension: nil),
let data = NSDictionary(contentsOf: url) as? [String: Any] else {
fatalError("Unable to load PLIST at path: \(path)")
}

View File

@@ -221,10 +221,6 @@
[super viewWillDisappear:animated];
}
- (void)dealloc
{
}
#pragma mark - override MXKViewController
- (void)destroy
@@ -366,7 +362,7 @@
{
// Detect if we should display the prompt to fallback to the STUN server defined
// in the app plist if the homeserver does not provide STUN or TURN servers.
// We should if the call ends while we were in connecting state
// We should display it if the call ends while we were in connecting state
if (!self.mainSession.callManager.turnServers
&& !self.mainSession.callManager.fallbackSTUNServer
&& !RiotSettings.shared.isAllowStunServerFallbackHasBeenSetOnce)
@@ -388,6 +384,7 @@
}
default:
// There is nothing to do for other states
break;
}
}

View File

@@ -30,8 +30,7 @@ final class CameraAccessAlertPresenter {
let alert = UIAlertController(title: VectorL10n.camera, message: VectorL10n.cameraAccessNotGranted(appDisplayName), preferredStyle: .alert)
let cancelActionTitle = Bundle.mxk_localizedString(forKey: "ok")
let cancelAction = UIAlertAction(title: cancelActionTitle, style: .cancel, handler: { _ in
})
let cancelAction = UIAlertAction(title: cancelActionTitle, style: .cancel, handler: nil)
let settingsActionTitle = Bundle.mxk_localizedString(forKey: "settings")
let settingsAction = UIAlertAction(title: settingsActionTitle, style: .default, handler: { _ in

View File

@@ -615,48 +615,6 @@
currentAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
// [currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"room_recents_start_chat_with", @"Vector", nil)
// style:UIAlertActionStyleDefault
// handler:^(UIAlertAction * action) {
//
// if (weakSelf)
// {
// typeof(self) self = weakSelf;
// self->currentAlert = nil;
//
// [self performSegueWithIdentifier:@"presentStartChat" sender:self];
// }
//
// }]];
//
// [currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"room_recents_create_empty_room", @"Vector", nil)
// style:UIAlertActionStyleDefault
// handler:^(UIAlertAction * action) {
//
// if (weakSelf)
// {
// typeof(self) self = weakSelf;
// self->currentAlert = nil;
//
// [self createAnEmptyRoom];
// }
//
// }]];
//
// [currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"room_recents_join_room", @"Vector", nil)
// style:UIAlertActionStyleDefault
// handler:^(UIAlertAction * action) {
//
// if (weakSelf)
// {
// typeof(self) self = weakSelf;
// self->currentAlert = nil;
//
// [self joinARoom];
// }
//
// }]];
[currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
@@ -676,76 +634,6 @@
[self presentViewController:currentAlert animated:YES completion:nil];
}
//- (void)joinARoom
//{
// [currentAlert dismissViewControllerAnimated:NO completion:nil];
//
// __weak typeof(self) weakSelf = self;
//
// // Prompt the user to type a room id or room alias
// currentAlert = [UIAlertController alertControllerWithTitle:NSLocalizedStringFromTable(@"room_recents_join_room_title", @"Vector", nil)
// message:NSLocalizedStringFromTable(@"room_recents_join_room_prompt", @"Vector", nil)
// preferredStyle:UIAlertControllerStyleAlert];
//
// [currentAlert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
//
// textField.secureTextEntry = NO;
// textField.placeholder = nil;
// textField.keyboardType = UIKeyboardTypeDefault;
// }];
//
// [currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"]
// style:UIAlertActionStyleDefault
// handler:^(UIAlertAction * action) {
//
// if (weakSelf)
// {
// typeof(self) self = weakSelf;
// self->currentAlert = nil;
// }
//
// }]];
//
// [currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"join", @"Vector", nil)
// style:UIAlertActionStyleDefault
// handler:^(UIAlertAction * action) {
//
// if (weakSelf)
// {
// typeof(self) self = weakSelf;
//
// NSString *roomAliasOrId = [self->currentAlert textFields].firstObject.text;
//
// self->currentAlert = nil;
//
// [self.activityIndicator startAnimating];
//
// self->currentRequest = [self.mainSession joinRoom:roomAliasOrId success:^(MXRoom *room) {
//
// self->currentRequest = nil;
// [self.activityIndicator stopAnimating];
//
// // Show the room
// [[AppDelegate theDelegate] showRoom:room.roomId andEventId:nil withMatrixSession:self.mainSession];
//
// } failure:^(NSError *error) {
//
// NSLog(@"[RecentsViewController] Join joinARoom (%@) failed", roomAliasOrId);
//
// self->currentRequest = nil;
// [self.activityIndicator stopAnimating];
//
// // Alert user
// [[AppDelegate theDelegate] showErrorAsAlert:error];
// }];
// }
//
// }]];
//
// [currentAlert mxk_setAccessibilityIdentifier:@"RecentsVCJoinARoomAlert"];
// [self presentViewController:currentAlert animated:YES completion:nil];
//}
#pragma mark - Table view scrolling
- (void)scrollToTop:(BOOL)animated

View File

@@ -577,25 +577,6 @@
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
//- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
//{
// NSMutableArray* actions;
//
// // @TODO Add the swipe to remove this room from the community if the current user is admin
// actions = [[NSMutableArray alloc] init];
//
// // Patch: Force the width of the button by adding whitespace characters into the title string.
// UITableViewRowAction *leaveAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@" " handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
//
// // @TODO Remove the room
//
// }];
//
// leaveAction.backgroundColor = [MXKTools convertImageToPatternColor:@"remove_icon_blue" backgroundColor:ThemeService.shared.theme.headerBackgroundColor patternSize:CGSizeMake(74, 74) resourceSize:CGSizeMake(24, 24)];
// [actions insertObject:leaveAction atIndex:0];
//
// return actions;
//}
#pragma mark - UISearchBar delegate

View File

@@ -66,11 +66,6 @@
}
}
- (void)dealloc
{
}
- (void)destroy
{
[super destroy];

View File

@@ -114,11 +114,6 @@
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}
- (void)dealloc
{
}
- (void)destroy
{
[super destroy];

View File

@@ -349,7 +349,7 @@ NSString *const kIntegrationManagerAddIntegrationScreen = @"add_integ";
if (!widget_id)
{
[self sendLocalisedError:@"widget_integration_unable_to_create" toRequest:requestId]; // new Error("Missing required widget fields."));
[self sendLocalisedError:@"widget_integration_unable_to_create" toRequest:requestId];
return;
}

View File

@@ -213,10 +213,12 @@ static const NSString *kJitsiDataErrorKey = @"error";
- (void)conferenceWillJoin:(NSDictionary *)data
{
// Nothing to do
}
- (void)conferenceJoined:(NSDictionary *)data
{
// Nothing to do
}
- (void)conferenceTerminated:(NSDictionary *)data

View File

@@ -40,8 +40,6 @@ final class KeyBackupRecoverFromPrivateKeyViewModel: KeyBackupRecoverFromPrivate
self.keyBackupVersion = keyBackupVersion
}
deinit {
}
// MARK: - Public

View File

@@ -53,9 +53,6 @@ final class KeyVerificationScanConfirmationViewModel: KeyVerificationScanConfirm
self.verificationKind = verificationKind
}
deinit {
}
// MARK: - Public
func process(viewAction: KeyVerificationScanConfirmationViewAction) {

View File

@@ -46,9 +46,6 @@ final class KeyVerificationVerifyBySASViewModel: KeyVerificationVerifyBySASViewM
self.verificationKind = verificationKind
}
deinit {
}
// MARK: - Public
func process(viewAction: KeyVerificationVerifyBySASViewAction) {

View File

@@ -51,10 +51,7 @@ final class DeviceVerificationIncomingViewModel: DeviceVerificationIncomingViewM
self.mediaManager = session.mediaManager
}
deinit {
}
// MARK: - Public
func process(viewAction: DeviceVerificationIncomingViewAction) {

View File

@@ -45,9 +45,6 @@ final class KeyVerificationSelfVerifyStartViewModel: KeyVerificationSelfVerifySt
self.keyVerificationService = KeyVerificationService()
}
deinit {
}
// MARK: - Public
func process(viewAction: KeyVerificationSelfVerifyStartViewAction) {

View File

@@ -45,9 +45,6 @@ final class DeviceVerificationStartViewModel: DeviceVerificationStartViewModelTy
self.otherDevice = otherDevice
}
deinit {
}
// MARK: - Public
func process(viewAction: DeviceVerificationStartViewAction) {

View File

@@ -59,9 +59,6 @@ final class UserVerificationStartViewModel: UserVerificationStartViewModelType {
self.keyVerificationService = KeyVerificationService()
}
deinit {
}
// MARK: - Public
func process(viewAction: UserVerificationStartViewAction) {

View File

@@ -134,8 +134,7 @@ final class UserVerificationCoordinator: NSObject, UserVerificationCoordinatorTy
message: VectorL10n.keyVerificationBootstrapNotSetupMessage,
preferredStyle: .alert)
let cancelAction = UIAlertAction(title: Bundle.mxk_localizedString(forKey: "ok"), style: .cancel, handler: { _ in
})
let cancelAction = UIAlertAction(title: Bundle.mxk_localizedString(forKey: "ok"), style: .cancel, handler: nil)
alert.addAction(cancelAction)
self.presenter.toPresentable().present(alert, animated: true, completion: nil)

View File

@@ -64,8 +64,7 @@ final class SingleImagePickerPresenter: NSObject {
self.presentPhotoLibray(sourceView: sourceView, sourceRect: sourceRect, animated: animated)
})
let cancelAction = UIAlertAction(title: VectorL10n.cancel, style: .cancel, handler: { _ in
})
let cancelAction = UIAlertAction(title: VectorL10n.cancel, style: .cancel, handler: nil)
alert.addAction(cameraAction)
alert.addAction(photoLibraryAction)

View File

@@ -792,8 +792,8 @@
// Refresh here the preview header according to the coming screen orientation.
// Retrieve the affine transform indicating the amount of rotation being applied to the interface.
// This transform is the identity transform when no rotation is applied;
// otherwise, it is a transform that applies a 90 degree, -90 degree, or 180 degree rotation.
// This transform is the identity transform when no rotation is applied.
// Otherwise, it is a transform that applies a 90 degree, -90 degree, or 180 degree rotation.
CGAffineTransform transform = coordinator.targetTransform;
// Consider here only the transform that applies a +/- 90 degree.

View File

@@ -248,14 +248,6 @@
#pragma mark - HPGrowingTextView delegate
//- (BOOL)growingTextViewShouldReturn:(HPGrowingTextView *)hpGrowingTextView
//{
// // The return sends the message rather than giving a carriage return.
// [self onTouchUpInside:self.rightInputToolbarButton];
//
// return NO;
//}
- (void)growingTextViewDidChange:(HPGrowingTextView *)hpGrowingTextView
{
// Clean the carriage return added on return press

View File

@@ -84,11 +84,6 @@
}
}
- (void)dealloc
{
}
- (void)destroy
{
[super destroy];

View File

@@ -48,9 +48,6 @@ final class ServiceTermsModalScreenViewModel: ServiceTermsModalScreenViewModelTy
self.outOfContext = outOfContext
}
deinit {
}
// MARK: - Public
func process(viewAction: ServiceTermsModalScreenViewAction) {

View File

@@ -732,7 +732,6 @@ enum {
{
NSLog(@"[ManageSessionVC] Delete device (%@) failed, auth session flow type is not supported", self->device.deviceId);
[self.activityIndicator stopAnimating];
//[[AppDelegate theDelegate] showErrorAsAlert:error];
}
} failure:^(NSError *error) {

View File

@@ -93,12 +93,6 @@ enum
NOTIFICATION_SETTINGS_GLOBAL_SETTINGS_INDEX,
NOTIFICATION_SETTINGS_PIN_MISSED_NOTIFICATIONS_INDEX,
NOTIFICATION_SETTINGS_PIN_UNREAD_INDEX,
//NOTIFICATION_SETTINGS_CONTAINING_MY_USER_NAME_INDEX,
//NOTIFICATION_SETTINGS_CONTAINING_MY_DISPLAY_NAME_INDEX,
//NOTIFICATION_SETTINGS_SENT_TO_ME_INDEX,
//NOTIFICATION_SETTINGS_INVITED_TO_ROOM_INDEX,
//NOTIFICATION_SETTINGS_PEOPLE_LEAVE_JOIN_INDEX,
//NOTIFICATION_SETTINGS_CALL_INVITATION_INDEX,
};
enum
@@ -3014,46 +3008,6 @@ TableViewSectionsDelegate>
[self pushViewController:newPhoneNumberCountryPicker];
}
//- (void)onRuleUpdate:(id)sender
//{
// MXPushRule* pushRule = nil;
// MXSession* session = [[AppDelegate theDelegate].mxSessions objectAtIndex:0];
//
// NSInteger row = ((UIView*)sender).tag;
//
// if (row == NOTIFICATION_SETTINGS_CONTAINING_MY_DISPLAY_NAME_INDEX)
// {
// pushRule = [session.notificationCenter ruleById:kMXNotificationCenterContainDisplayNameRuleID];
// }
// else if (row == NOTIFICATION_SETTINGS_CONTAINING_MY_USER_NAME_INDEX)
// {
// pushRule = [session.notificationCenter ruleById:kMXNotificationCenterContainUserNameRuleID];
// }
// else if (row == NOTIFICATION_SETTINGS_SENT_TO_ME_INDEX)
// {
// pushRule = [session.notificationCenter ruleById:kMXNotificationCenterOneToOneRoomRuleID];
// }
// else if (row == NOTIFICATION_SETTINGS_INVITED_TO_ROOM_INDEX)
// {
// pushRule = [session.notificationCenter ruleById:kMXNotificationCenterInviteMeRuleID];
// }
// else if (row == NOTIFICATION_SETTINGS_PEOPLE_LEAVE_JOIN_INDEX)
// {
// pushRule = [session.notificationCenter ruleById:kMXNotificationCenterMemberEventRuleID];
// }
// else if (row == NOTIFICATION_SETTINGS_CALL_INVITATION_INDEX)
// {
// pushRule = [session.notificationCenter ruleById:kMXNotificationCenterCallRuleID];
// }
//
// if (pushRule)
// {
// // toggle the rule
// [session.notificationCenter enableRule:pushRule isEnabled:!pushRule.enabled];
// }
//}
- (void)onSave:(id)sender
{
// sanity check