insideapp-oss / sonar-apple Goto Github PK
View Code? Open in Web Editor NEWSonarQube plugin for Swift / Objective-C
License: Other
SonarQube plugin for Swift / Objective-C
License: Other
Mac OS 14.0
The latest version of sonar-apple plug-in, the installation location is no problem
Latest version of SonarQube
In the root directory of the project, execute the sonar-scanner command.
After success, no code smell related to OC and Swift can be seen on the SonarQube platform.
Only js, HTML, and css languages are detected. Why?
Highlight issues reported into log files.
Text ranges are set outside file boundaries.
$ sonar-scanner
10:47:35.836 WARN: Unexpected error creating text range on file nextcloud:iOSClient/PushNotification/NCPushNotification.m for token @end on (217, 0) - (356, 4)
java.lang.IllegalArgumentException: 356 is not a valid line for pointer. File iOSClient/PushNotification/NCPushNotification.m has 218 line(s)
at org.sonar.api.utils.Preconditions.checkArgument(Preconditions.java:43)
at org.sonar.api.batch.fs.internal.DefaultInputFile.checkValid(DefaultInputFile.java:336)
at org.sonar.api.batch.fs.internal.DefaultInputFile.newPointer(DefaultInputFile.java:272)
at org.sonar.api.batch.fs.internal.DefaultInputFile.newRange(DefaultInputFile.java:288)
at fr.insideapp.sonarqube.apple.commons.antlr.HighlighterVisitor.fillContext(HighlighterVisitor.java:127)
at fr.insideapp.sonarqube.objc.antlr.ObjectiveCHighlighterVisitor.fillContext(ObjectiveCHighlighterVisitor.java:135)
at fr.insideapp.sonarqube.apple.commons.antlr.CustomTreeVisitor.fillContext(CustomTreeVisitor.java:52)
at fr.insideapp.sonarqube.apple.commons.antlr.ParseTreeAnalyzer.lambda$analyze$0(ParseTreeAnalyzer.java:67)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Source file used:
//
// NCPushNotification.m
// Nextcloud
//
// Created by Marino Faggiana on 26/12/20.
// Copyright © 2020 Marino Faggiana. All rights reserved.
//
// Author Marino Faggiana <[email protected]>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#import <UserNotifications/UserNotifications.h>
#import "NCBridgeSwift.h"
#import "NCPushNotification.h"
#import "NCPushNotificationEncryption.h"
#import "NCEndToEndEncryption.h"
#import "CCUtility.h"
@interface NCPushNotification ()
{
AppDelegate *appDelegate;
}
@end
@implementation NCPushNotification
+ (instancetype)shared
{
static NCPushNotification *pushNotification = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
pushNotification = [self new];
pushNotification->appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
});
return pushNotification;
}
- (void)pushNotification
{
if (self.pushKitToken.length == 0) { return; }
for (tableAccount *result in [[NCManageDatabase shared] getAllAccount]) {
NSString *token = [CCUtility getPushNotificationToken:result.account];
if (![token isEqualToString:self.pushKitToken]) {
if (token != nil) {
// unsubscribing + subscribing
[self unsubscribingNextcloudServerPushNotification:result.account urlBase:result.urlBase user:result.user withSubscribing:true];
} else {
[self subscribingNextcloudServerPushNotification:result.account urlBase:result.urlBase user:result.user];
}
}
}
}
- (void)applicationdidReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
NSString *message = [userInfo objectForKey:@"subject"];
if (message) {
NSArray *results = [[NCManageDatabase shared] getAllAccount];
for (tableAccount *result in results) {
if ([CCUtility getPushNotificationPrivateKey:result.account]) {
NSData *decryptionKey = [CCUtility getPushNotificationPrivateKey:result.account];
NSString *decryptedMessage = [[NCPushNotificationEncryption shared] decryptPushNotification:message withDevicePrivateKey:decryptionKey];
if (decryptedMessage) {
NSData *data = [decryptedMessage dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSInteger nid = [[json objectForKey:@"nid"] integerValue];
BOOL delete = [[json objectForKey:@"delete"] boolValue];
BOOL deleteAll = [[json objectForKey:@"delete-all"] boolValue];
if (delete) {
[[NCPushNotification shared] removeNotificationWithNotificationId:nid usingDecryptionKey:decryptionKey];
} else if (deleteAll) {
[[NCPushNotification shared] cleanAllNotifications];
}
}
}
}
}
completionHandler(UIBackgroundFetchResultNoData);
}
- (void)subscribingNextcloudServerPushNotification:(NSString *)account urlBase:(NSString *)urlBase user:(NSString *)user
{
if (appDelegate.account == nil || appDelegate.account.length == 0 || self.pushKitToken.length == 0) { return; }
[[NCPushNotificationEncryption shared] generatePushNotificationsKeyPair:account];
NSString *pushTokenHash = [[NCEndToEndEncryption sharedManager] createSHA512:self.pushKitToken];
NSData *pushPublicKey = [CCUtility getPushNotificationPublicKey:account];
NSString *pushDevicePublicKey = [[NSString alloc] initWithData:pushPublicKey encoding:NSUTF8StringEncoding];
NSString *proxyServerPath = [NCBrandOptions shared].pushNotificationServerProxy;
[[NCCommunication shared] subscribingPushNotificationWithServerUrl:urlBase account:account user:user password:[CCUtility getPassword:account] pushTokenHash:pushTokenHash devicePublicKey:pushDevicePublicKey proxyServerUrl:proxyServerPath customUserAgent:nil addCustomHeaders:nil queue:dispatch_get_main_queue() completionHandler:^(NSString *account, NSString *deviceIdentifier, NSString *signature, NSString *publicKey, NSInteger errorCode, NSString *errorDescription) {
if (errorCode == 0) {
NSString *userAgent = [NSString stringWithFormat:@"%@ (Strict VoIP)", [CCUtility getUserAgent]];
[[NCCommunication shared] subscribingPushProxyWithProxyServerUrl:proxyServerPath pushToken:self.pushKitToken deviceIdentifier:deviceIdentifier signature:signature publicKey:publicKey userAgent:userAgent queue:dispatch_get_main_queue() completionHandler:^(NSInteger errorCode, NSString *errorDescription) {
if (errorCode == 0) {
[[NCCommunicationCommon shared] writeLog:@"Subscribed to Push Notification server & proxy successfully"];
[CCUtility setPushNotificationToken:account token:self.pushKitToken];
[CCUtility setPushNotificationDeviceIdentifier:account deviceIdentifier:deviceIdentifier];
[CCUtility setPushNotificationDeviceIdentifierSignature:account deviceIdentifierSignature:signature];
[CCUtility setPushNotificationSubscribingPublicKey:account publicKey:publicKey];
}
}];
}
}];
}
- (void)unsubscribingNextcloudServerPushNotification:(NSString *)account urlBase:(NSString *)urlBase user:(NSString *)user withSubscribing:(BOOL)subscribing
{
if (appDelegate.account == nil || appDelegate.account.length == 0) { return; }
NSString *deviceIdentifier = [CCUtility getPushNotificationDeviceIdentifier:account];
NSString *signature = [CCUtility getPushNotificationDeviceIdentifierSignature:account];
NSString *publicKey = [CCUtility getPushNotificationSubscribingPublicKey:account];
[[NCCommunication shared] unsubscribingPushNotificationWithServerUrl:urlBase account:account user:user password:[CCUtility getPassword:account] customUserAgent:nil addCustomHeaders:nil queue:dispatch_get_main_queue() completionHandler:^(NSString *account, NSInteger errorCode, NSString *errorDescription) {
if (errorCode == 0) {
NSString *userAgent = [NSString stringWithFormat:@"%@ (Strict VoIP)", [CCUtility getUserAgent]];
NSString *proxyServerPath = [NCBrandOptions shared].pushNotificationServerProxy;
[[NCCommunication shared] unsubscribingPushProxyWithProxyServerUrl:proxyServerPath deviceIdentifier:deviceIdentifier signature:signature publicKey:publicKey userAgent:userAgent queue:dispatch_get_main_queue() completionHandler:^(NSInteger errorCode, NSString *errorDescription) {
if (errorCode == 0) {
[[NCCommunicationCommon shared] writeLog:@"Unsubscribed to Push Notification server & proxy successfully."];
[CCUtility setPushNotificationPublicKey:account data:nil];
[CCUtility setPushNotificationSubscribingPublicKey:account publicKey:nil];
[CCUtility setPushNotificationPrivateKey:account data:nil];
[CCUtility setPushNotificationToken:account token:nil];
[CCUtility setPushNotificationDeviceIdentifier:account deviceIdentifier:nil];
[CCUtility setPushNotificationDeviceIdentifierSignature:account deviceIdentifierSignature:nil];
if (self.pushKitToken != nil && subscribing) {
[self subscribingNextcloudServerPushNotification:account urlBase:urlBase user:user];
}
}
}];
}
}];
}
- (void)cleanAllNotifications
{
[[UNUserNotificationCenter currentNotificationCenter] removeAllDeliveredNotifications];
}
- (void)removeNotificationWithNotificationId:(NSInteger)notificationId usingDecryptionKey:(NSData *)key
{
// Check in pending notifications
[[UNUserNotificationCenter currentNotificationCenter] getPendingNotificationRequestsWithCompletionHandler:^(NSArray<UNNotificationRequest *> * _Nonnull requests) {
for (UNNotificationRequest *notificationRequest in requests) {
NSString *message = [notificationRequest.content.userInfo objectForKey:@"subject"];
NSString *decryptedMessage = [[NCPushNotificationEncryption shared] decryptPushNotification:message withDevicePrivateKey:key];
if (decryptedMessage) {
NSData *data = [decryptedMessage dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSInteger nid = [[json objectForKey:@"nid"] integerValue];
if (nid == notificationId) {
[[UNUserNotificationCenter currentNotificationCenter] removePendingNotificationRequestsWithIdentifiers:@[notificationRequest.identifier]];
}
}
}
}];
// Check in delivered notifications
[[UNUserNotificationCenter currentNotificationCenter] getDeliveredNotificationsWithCompletionHandler:^(NSArray<UNNotification *> * _Nonnull notifications) {
for (UNNotification *notification in notifications) {
NSString *message = [notification.request.content.userInfo objectForKey:@"subject"];
NSString *decryptedMessage = [[NCPushNotificationEncryption shared] decryptPushNotification:message withDevicePrivateKey:key];
if (decryptedMessage) {
NSData *data = [decryptedMessage dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSInteger nid = [[json objectForKey:@"nid"] integerValue];
if (nid == notificationId) {
[[UNUserNotificationCenter currentNotificationCenter] removeDeliveredNotificationsWithIdentifiers:@[notification.request.identifier]];
}
}
}
}];
}
- (void)registerForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
self.pushKitToken = [self stringWithDeviceToken:deviceToken];
[self pushNotification];
}
- (NSString *)stringWithDeviceToken:(NSData *)deviceToken
{
const char *data = [deviceToken bytes];
NSMutableString *token = [NSMutableString string];
for (NSUInteger i = 0; i < [deviceToken length]; i++) {
[token appendFormat:@"%02.2hhX", data[i]];
}
return [token copy];
}
@end
SonarQube Community Edition Version 9.4 (build 54424)
I Install the latest "0.2.0" version of the plugin on my sonar and restart then.
I can saw plugin install on list of plugin (admin section).
however the plugin break all pipeline even if language is not "Swift and Objective-C".
ERROR: Error during SonarScanner execution org.picocontainer.PicoCompositionException: Either the specified parameters do not match any of the following constructors: [fr.insideapp.sonarqube.objc.issues.oclint.OCLintSensor(org.sonar.api.config.Configuration,org.sonar.api.batch.fs.FileSystem,fr.insideapp.sonarqube.objc.issues.oclint.interfaces.OCLintJSONDatabaseBuildable,fr.insideapp.sonarqube.objc.issues.oclint.interfaces.OCLintExtractable,fr.insideapp.sonarqube.objc.issues.oclint.interfaces.OCLintReportParsable,fr.insideapp.sonarqube.apple.commons.issues.ReportIssueRecorder)]; OR the constructors were not accessible for 'fr.insideapp.sonarqube.objc.issues.oclint.OCLintSensor' at org.picocontainer.injectors.ConstructorInjector.getGreediestSatisfiableConstructor(ConstructorInjector.java:200) at org.picocontainer.injectors.ConstructorInjector.getGreediestSatisfiableConstructor(ConstructorInjector.java:110) at org.picocontainer.injectors.ConstructorInjector.access$100(ConstructorInjector.java:51) at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:331) at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270) at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364) at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56) at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64) at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91) at org.picocontainer.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:606) at org.picocontainer.DefaultPicoContainer.getComponents(DefaultPicoContainer.java:587) at org.sonar.core.platform.ComponentContainer.getComponentsByType(ComponentContainer.java:291) at org.sonar.scanner.bootstrap.AbstractExtensionDictionnary.completeScannerExtensions(AbstractExtensionDictionnary.java:82) at org.sonar.scanner.bootstrap.AbstractExtensionDictionnary.getExtensions(AbstractExtensionDictionnary.java:77) at org.sonar.scanner.bootstrap.AbstractExtensionDictionnary.getFilteredExtensions(AbstractExtensionDictionnary.java:67) at org.sonar.scanner.sensor.ModuleSensorExtensionDictionnary.selectSensors(ModuleSensorExtensionDictionnary.java:40) at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$0(ModuleSensorsExecutor.java:52) at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77) at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:52) at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
Community EditionVersion 8.9.10 (build 61524)
Vulnerabilities are reported twice each time.
$ sonar-scanner
10:47:44.322 INFO: Sensor MobSFScan Sensor for Swift [sonarapple]
10:47:44.322 INFO: Running 'mobsfscan analyze'...
10:47:56.145 INFO: Found issues: 197
10:47:56.378 INFO: Sensor MobSFScan Sensor for Swift [sonarapple] (done) | time=12057ms
Logs show the correct number of issue reported (197), but once analyzed : SonarQube says there are 346 vulnerabilities.
That is not exactly twice the issue initially reported (probably a difference with "global" issues and "source file related" issues).
SonarQube Community Edition Version 9.4 (build 54424)
Issue Description:
Error when trying to run sonar-scanner.
Command executed:
sonar-scanner
Complete output when running sonar-scanner, including the stack trace and command used:
sonar-scanner
INFO: Scanner configuration file: /Users/otazihosni/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: /Users/otazihosni/Documents/Workspace/cs_aoc_appofcard/ios/sonar-project.properties
INFO: SonarScanner 4.7.0.2747
INFO: Java 11.0.14.1 Eclipse Adoptium (64-bit)
INFO: Mac OS X 12.3 x86_64
INFO: User cache: /Users/otazihosni/.sonar/cache
INFO: Scanner configuration file: /Users/otazihosni/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: /Users/otazihosni/Documents/Workspace/cs_aoc_appofcard/ios/sonar-project.properties
INFO: Analyzing on SonarQube server 9.8.0.63668
INFO: Default locale: "fr_FR", source code encoding: "UTF-8"
INFO: Load global settings
INFO: Load global settings (done) | time=217ms
INFO: Server id: 147B411E-AYXEDHUzDfraOlGr0hIz
INFO: User cache: /Users/otazihosni/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=187ms
INFO: Load/download plugins (done) | time=292ms
INFO: Process project properties
INFO: Process project properties (done) | time=8ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=1ms
INFO: Project key: fr.sephora.aoc
INFO: Base dir: /Users/otazihosni/Documents/Workspace/cs_aoc_appofcard/ios
INFO: Working dir: /Users/otazihosni/Documents/Workspace/cs_aoc_appofcard/ios/.scannerwork
INFO: Load project settings for component key: 'fr.sephora.aoc'
INFO: Load project settings for component key: 'fr.sephora.aoc' (done) | time=168ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=242ms
INFO: Load active rules
INFO: Load active rules (done) | time=4755ms
INFO: Load analysis cache
INFO: Load analysis cache (404) | time=164ms
WARN: Property 'sonar.password' is deprecated. It will not be supported in the future. Please instead use the 'sonar.login' parameter with a token.
INFO: Load project repositories
INFO: Load project repositories (done) | time=163ms
INFO: Indexing files...
INFO: Project configuration:
WARN: File '/Users/otazihosni/Documents/Workspace/cs_aoc_appofcard/ios/xcodebuild.log' is bigger than 20MB and as consequence is removed from the analysis scope.
WARN: File '/Users/otazihosni/Documents/Workspace/cs_aoc_appofcard/ios/Pods/CS_iOS_SDK/ContentsquareModule.xcframework/ios-arm64_x86_64-simulator/dSYMs/ContentsquareModule.framework.dSYM/Contents/Resources/DWARF/ContentsquareModule' is bigger than 20MB and as consequence is removed from the analysis scope.
WARN: File '/Users/otazihosni/Documents/Workspace/cs_aoc_appofcard/ios/Pods/GoogleMaps/Maps/Frameworks/GoogleMapsCore.framework/GoogleMapsCore' is bigger than 20MB and as consequence is removed from the analysis scope.
WARN: File '/Users/otazihosni/Documents/Workspace/cs_aoc_appofcard/ios/Pods/GoogleMaps/Maps/Frameworks/GoogleMaps.framework/GoogleMaps' is bigger than 20MB and as consequence is removed from the analysis scope.
WARN: File '/Users/otazihosni/Documents/Workspace/cs_aoc_appofcard/ios/Pods/GoogleMaps/Base/Frameworks/GoogleMapsBase.framework/GoogleMapsBase' is bigger than 20MB and as consequence is removed from the analysis scope.
WARN: File '/Users/otazihosni/Documents/Workspace/cs_aoc_appofcard/ios/Pods/Batch/Batch.xcframework/ios-arm64_arm64e_armv7/Batch.framework/Batch' is bigger than 20MB and as consequence is removed from the analysis scope.
WARN: File '/Users/otazihosni/Documents/Workspace/cs_aoc_appofcard/ios/Pods/KlarnaMobileSDK/ios/XCFramework/full/universal/KlarnaMobileSDK.xcframework.zip' is bigger than 20MB and as consequence is removed from the analysis scope.
WARN: File '/Users/otazihosni/Documents/Workspace/cs_aoc_appofcard/ios/Pods/KlarnaMobileSDK/ios/XCFramework/full/universal/KlarnaMobileSDK.xcframework/ios-arm64_i386_x86_64-simulator/dSYMs/KlarnaMobileSDK.framework.dSYM/Contents/Resources/DWARF/KlarnaMobileSDK' is bigger than 20MB and as consequence is removed from the analysis scope.
WARN: File '/Users/otazihosni/Documents/Workspace/cs_aoc_appofcard/ios/Pods/KlarnaMobileSDK/ios/XCFramework/full/universal/KlarnaMobileSDK.xcframework/ios-arm64_armv7/KlarnaMobileSDK.framework/KlarnaMobileSDK' is bigger than 20MB and as consequence is removed from the analysis scope.
WARN: File '/Users/otazihosni/Documents/Workspace/cs_aoc_appofcard/ios/Pods/GoogleAppMeasurement/Frameworks/GoogleAppMeasurement.framework/GoogleAppMeasurement' is bigger than 20MB and as consequence is removed from the analysis scope.
WARN: File '/Users/otazihosni/Documents/Workspace/cs_aoc_appofcard/ios/Pods/SwiftLint/swiftlint' is bigger than 20MB and as consequence is removed from the analysis scope.
INFO: 2393 files indexed
INFO: 20250 files ignored because of scm ignore settings
INFO: Quality profile for css: Sonar way
INFO: Quality profile for js: Sonar way
INFO: Quality profile for json: Sonar way
INFO: Quality profile for objc: Objective-C
INFO: Quality profile for swift: Swift
INFO: Quality profile for yaml: Sonar way
INFO: ------------- Run sensors on module AOC
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=214ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=12ms
INFO: Sensor IaC CloudFormation Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC CloudFormation Sensor [iac] (done) | time=920ms
INFO: Sensor IaC Kubernetes Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC Kubernetes Sensor [iac] (done) | time=551ms
INFO: Sensor Swift Sensor [sonarapple]
INFO: Analyzing source files
WARN: Unexpected error creating text range on file fr.sephora.aoc:Common/Common/Tools/Factories.swift for token ( on (144, 22) - (144, 22)
java.lang.IllegalArgumentException: Start pointer [line=144, lineOffset=22] should be before end pointer [line=144, lineOffset=22]
at org.sonar.api.utils.Preconditions.checkArgument(Preconditions.java:43)
at org.sonar.api.batch.fs.internal.DefaultInputFile.newRangeValidPointers(DefaultInputFile.java:365)
at org.sonar.api.batch.fs.internal.DefaultInputFile.newRange(DefaultInputFile.java:306)
at fr.insideapp.sonarqube.apple.commons.antlr.HighlighterVisitor.fillContext(HighlighterVisitor.java:127)
at fr.insideapp.sonarqube.swift.antlr.SwiftHighlighterVisitor.fillContext(SwiftHighlighterVisitor.java:120)
at fr.insideapp.sonarqube.apple.commons.antlr.CustomTreeVisitor.fillContext(CustomTreeVisitor.java:52)
at fr.insideapp.sonarqube.apple.commons.antlr.ParseTreeAnalyzer.analyze(ParseTreeAnalyzer.java:65)
at fr.insideapp.sonarqube.swift.SwiftSensor.execute(SwiftSensor.java:50)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:61)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:79)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:61)
at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:401)
at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:397)
at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:366)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:135)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
WARN: Unexpected error creating text range on file fr.sephora.aoc:Common/Common/Tools/Factories.swift for token ( on (144, 42) - (144, 42)
java.lang.IllegalArgumentException: Start pointer [line=144, lineOffset=42] should be before end pointer [line=144, lineOffset=42]
at org.sonar.api.utils.Preconditions.checkArgument(Preconditions.java:43)
at org.sonar.api.batch.fs.internal.DefaultInputFile.newRangeValidPointers(DefaultInputFile.java:365)
at org.sonar.api.batch.fs.internal.DefaultInputFile.newRange(DefaultInputFile.java:306)
at fr.insideapp.sonarqube.apple.commons.antlr.HighlighterVisitor.fillContext(HighlighterVisitor.java:127)
at fr.insideapp.sonarqube.swift.antlr.SwiftHighlighterVisitor.fillContext(SwiftHighlighterVisitor.java:120)
at fr.insideapp.sonarqube.apple.commons.antlr.CustomTreeVisitor.fillContext(CustomTreeVisitor.java:52)
at fr.insideapp.sonarqube.apple.commons.antlr.ParseTreeAnalyzer.analyze(ParseTreeAnalyzer.java:65)
at fr.insideapp.sonarqube.swift.SwiftSensor.execute(SwiftSensor.java:50)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:61)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:79)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:61)
at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:401)
at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:397)
at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:366)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:135)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
WARN: Unexpected error creating text range on file fr.sephora.aoc:AppOfCards/Application/Coordinators/Coordinator.swift for token if on (64, 8) - (64, 6)
java.lang.IllegalArgumentException: Start pointer [line=64, lineOffset=8] should be before end pointer [line=64, lineOffset=6]
at org.sonar.api.utils.Preconditions.checkArgument(Preconditions.java:43)
at org.sonar.api.batch.fs.internal.DefaultInputFile.newRangeValidPointers(DefaultInputFile.java:365)
at org.sonar.api.batch.fs.internal.DefaultInputFile.newRange(DefaultInputFile.java:306)
at fr.insideapp.sonarqube.apple.commons.antlr.HighlighterVisitor.fillContext(HighlighterVisitor.java:127)
at fr.insideapp.sonarqube.swift.antlr.SwiftHighlighterVisitor.fillContext(SwiftHighlighterVisitor.java:120)
at fr.insideapp.sonarqube.apple.commons.antlr.CustomTreeVisitor.fillContext(CustomTreeVisitor.java:52)
at fr.insideapp.sonarqube.apple.commons.antlr.ParseTreeAnalyzer.analyze(ParseTreeAnalyzer.java:65)
at fr.insideapp.sonarqube.swift.SwiftSensor.execute(SwiftSensor.java:50)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:61)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:79)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:61)
at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:401)
at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:397)
at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:366)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:135)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Environment:
Apple M1 Max
macOS Monterey Version 12.3
SonarQube: 8.9.10
sonar-apple-plugin-0.2.1
java version: 17.0.5.
Thanks in advance for your help.
Can i scan the project without xcodebuild if i don't need the test coverage?
Is it appropriate to only install SwiftLint and OCLint then run the sonar-scanner?
When running the analysis on a project with Swift and Objective-C code, Objective-C issues are not reported.
# Run tests with xcpretty to generate test report in build/reports/junit.xml
# Also saves Xcode log to build/xcodebuild.log (this is necessary for Objective-C code analysis)
# Don't forget to add -workspace to the build command if your project is part of a workspace
$ xcodebuild \
-project MyApp.xcodeproj \
-scheme MyApp \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 11 Pro' \
-derivedDataPath ./derivedData \
clean test | tee build/xcodebuild.log | xcpretty --report junit
# Generate coverage report to build/reports/cobertura.xml
# Don't forget to activate 'Gather coverage' option in the app scheme
$ slather coverage --cobertura-xml --output-directory build/reports --scheme MyApp MyApp.xcodeproj
# Saves Periphery log to build/periphery.log (this is necessary for Swift dead code analysis)
# Don't forget to add --workspace to the build command if your project is part of a workspace
$ periphery scan \
--project "MyApp.xcodeproj" \
--schemes "MyApp" \
--targets "MyApp" \
--skip-build \
--index-store-path ./derivedData/Index/DataStore \
--format xcode \
--quiet | tee build/periphery.log
# Run the analysis and publish to the SonarQube server
$ sonar-scanner
No OCLint issue reported into the logs.
SonarQube Community Edition Version 9.4 (build 54424)
After installing the plugin (version 0.4.0) on SonarQube 10.4. I noticed Swift files are not indexed anymore.
Watching at the logs (with -X) it says "indexed with no language" when indexing .swift files.
The same project is ok when analysis is performed on a SonarQube 9.9.
SonarQube 10.4 Community Edition
SonarScanner 5.0.1
Java 17.0.7
macOS 14.2
# Run tests xcrun xcodebuild \ -project MyApp.xcodeproj \ -scheme MyApp \ -sdk iphonesimulator \ -destination 'platform=iOS Simulator,name=iPhone 11 Pro' \ -derivedDataPath ./derivedData \ -resultBundlePath build/result.xcresult \ OTHER_CFLAGS="\$(inherited) -gen-cdb-fragment-path build/compilation_database" \ -quiet \ clean test
this command must be work in test?
15:32:53.579 INFO: Sensor SwiftLint Sensor [sonarapple]
15:32:53.580 INFO: Sensor SwiftLint Sensor [sonarapple] (done) | time=1ms
seem SwiftLint doesn't scan any file with no result
However, Swift Sensor [sonarapple] logged with done and execute for 30000ms.
Any configuration missed will make SwiftLint does not work?
It would be amazing to explain better how to use Periphery with your tool
I can't see anything regarding the unused code. Can you give me an example of what value I should put in the sonar.apple.periphery.indexStorePath
field? I put [...]/Index.noindex/DataStore
but maybe it's not the right path? Or is there something else I need to configure in my SonarQube prject?
If I run Periphery locally on my machine it works normally
P.S.
Thank you for your amazing plugin, it's brilliant
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.