Skip to content

Commit

Permalink
Merge pull request #101 from WideSpectrumComputing/master
Browse files Browse the repository at this point in the history
chore: addressing code issues highlighted by SonarCloud, code  cleanup
  • Loading branch information
akornich authored May 26, 2021
2 parents 81390e0 + 5feca18 commit 7197317
Show file tree
Hide file tree
Showing 28 changed files with 368 additions and 86 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ The change log has moved to this repo's [GitHub Releases Page](https://github.co

## Release Notes

**2.0.0-beta.22**
**2.0.0-beta.21**
- feat: new RollbarAUL module is code complete

**2.0.0-beta.15**
- fix: resolve #81 - SPM - Resolving Package Graph Failed

Expand Down
14 changes: 14 additions & 0 deletions Demos/macosAppSwift/macosAppSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
55098C6725FA930D0045C180 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55098C6625FA930D0045C180 /* ContentView.swift */; };
55098C6925FA93110045C180 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 55098C6825FA93110045C180 /* Assets.xcassets */; };
55098C6C25FA93110045C180 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 55098C6B25FA93110045C180 /* Preview Assets.xcassets */; };
552689F12657381B004D6036 /* RollbarAUL in Frameworks */ = {isa = PBXBuildFile; productRef = 552689F02657381B004D6036 /* RollbarAUL */; };
552689F326573831004D6036 /* RollbarPLCrashReporter in Frameworks */ = {isa = PBXBuildFile; productRef = 552689F226573831004D6036 /* RollbarPLCrashReporter */; };
5544A01F25FB074300C710A1 /* RollbarCommon in Frameworks */ = {isa = PBXBuildFile; productRef = 5544A01E25FB074300C710A1 /* RollbarCommon */; };
5544A02125FB074300C710A1 /* RollbarNotifier in Frameworks */ = {isa = PBXBuildFile; productRef = 5544A02025FB074300C710A1 /* RollbarNotifier */; };
5544A02325FB074300C710A1 /* RollbarSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 5544A02225FB074300C710A1 /* RollbarSwift */; };
Expand All @@ -33,6 +35,8 @@
files = (
5544A01F25FB074300C710A1 /* RollbarCommon in Frameworks */,
5544A02125FB074300C710A1 /* RollbarNotifier in Frameworks */,
552689F326573831004D6036 /* RollbarPLCrashReporter in Frameworks */,
552689F12657381B004D6036 /* RollbarAUL in Frameworks */,
5544A02325FB074300C710A1 /* RollbarSwift in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -105,6 +109,8 @@
5544A01E25FB074300C710A1 /* RollbarCommon */,
5544A02025FB074300C710A1 /* RollbarNotifier */,
5544A02225FB074300C710A1 /* RollbarSwift */,
552689F02657381B004D6036 /* RollbarAUL */,
552689F226573831004D6036 /* RollbarPLCrashReporter */,
);
productName = macosAppSwift;
productReference = 55098C6125FA930D0045C180 /* macosAppSwift.app */;
Expand Down Expand Up @@ -352,6 +358,14 @@
/* End XCConfigurationList section */

/* Begin XCSwiftPackageProductDependency section */
552689F02657381B004D6036 /* RollbarAUL */ = {
isa = XCSwiftPackageProductDependency;
productName = RollbarAUL;
};
552689F226573831004D6036 /* RollbarPLCrashReporter */ = {
isa = XCSwiftPackageProductDependency;
productName = RollbarPLCrashReporter;
};
5544A01E25FB074300C710A1 /* RollbarCommon */ = {
isa = XCSwiftPackageProductDependency;
productName = RollbarCommon;
Expand Down
17 changes: 16 additions & 1 deletion Demos/macosAppSwift/macosAppSwift/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import SwiftUI
import RollbarNotifier
import RollbarSwift
import RollbarAUL

struct ContentView: View {

Expand Down Expand Up @@ -92,7 +93,21 @@ func handleSwiftError() {
let config = RollbarConfig();
config.destination.accessToken = "2ffc7997ed864dda94f63e7b7daae0f3";
config.destination.environment = "samples";
config.developerOptions.transmit = true;

// AUL capture setup:
// config.developerOptions.transmit = true;
// config.telemetry.enabled = true;
// config.telemetry.captureLog = true;
//
// Rollbar.initWithConfiguration(config);
// RollbarAulStoreMonitor.sharedInstance().configureRollbarLogger(Rollbar.currentLogger());
// let aulOptions = RollbarAulStoreMonitorOptions();
// aulOptions.addAulSubsystem("DataAccessLayer");
// aulOptions.addAulSubsystem("Model");
// aulOptions.addAulCategory("CompanyOrg");
// RollbarAulStoreMonitor.sharedInstance().configure(with: aulOptions);
//
// RollbarAulStoreMonitor.sharedInstance().start();

let logger = RollbarLogger(configuration: config);

Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ All the active development will be done within this SDK repository.

![CI Build with Unit Tests](https://github.com/rollbar/rollbar-apple/workflows/CI%20Build%20with%20Unit%20Tests/badge.svg)

<!--
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=rollbar-apple&metric=alert_status)](https://sonarcloud.io/dashboard?id=rollbar-apple)
-->
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=rollbar-apple&metric=security_rating)](https://sonarcloud.io/dashboard?id=rollbar-apple)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=rollbar-apple&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=rollbar-apple)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=rollbar-apple&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=rollbar-apple)
Expand All @@ -44,14 +46,19 @@ All the active development will be done within this SDK repository.
[![Platform](https://img.shields.io/cocoapods/p/RollbarNotifier.svg?label=RollbarNotifier)](https://docs.rollbar.com/docs/apple)
[![Platform](https://img.shields.io/cocoapods/p/RollbarDeploys.svg?label=RollbarDeploys)](https://docs.rollbar.com/docs/apple)
[![Platform](https://img.shields.io/cocoapods/p/RollbarCommon.svg?label=RollbarCommon)](https://docs.rollbar.com/docs/apple)
[![Platform](https://img.shields.io/cocoapods/p/RollbarKSCrash.svg?label=RollbarKSCrash)](https://docs.rollbar.com/docs/apple)
[![Platform](https://img.shields.io/cocoapods/p/RollbarAUL.svg?label=RollbarAUL)](https://docs.rollbar.com/docs/apple)
[![Platform](https://img.shields.io/cocoapods/p/RollbarSwift.svg?label=RollbarSwift)](https://docs.rollbar.com/docs/apple)
[![Platform](https://img.shields.io/cocoapods/p/RollbarPLCrashReporter.svg?label=RollbarPLCrashReporter)](https://docs.rollbar.com/docs/apple)
[![Platform](https://img.shields.io/cocoapods/p/RollbarKSCrash.svg?label=RollbarKSCrash)](https://docs.rollbar.com/docs/apple)

[![CocoaPods](https://img.shields.io/cocoapods/v/RollbarNotifier?label=RollbarNotifier)](https://cocoapods.org/pods/RollbarNotifier)
[![CocoaPods](https://img.shields.io/cocoapods/v/RollbarDeploys?label=RollbarDeploys)](https://cocoapods.org/pods/RollbarDeploys)
[![CocoaPods](https://img.shields.io/cocoapods/v/RollbarCommon?label=RollbarCommon)](https://cocoapods.org/pods/RollbarCommon)
[![CocoaPods](https://img.shields.io/cocoapods/v/RollbarKSCrash?label=RollbarKSCrash)](https://cocoapods.org/pods/RollbarKSCrash)
[![CocoaPods](https://img.shields.io/cocoapods/v/RollbarAUL?label=RollbarAUL)](https://cocoapods.org/pods/RollbarAUL)
[![CocoaPods](https://img.shields.io/cocoapods/v/RollbarSwift?label=RollbarSwift)](https://cocoapods.org/pods/RollbarSwift)
[![CocoaPods](https://img.shields.io/cocoapods/v/RollbarPLCrashReporter?label=RollbarPLCrashReporter)](https://cocoapods.org/pods/RollbarPLCrashReporter)
[![CocoaPods](https://img.shields.io/cocoapods/v/RollbarKSCrash?label=RollbarKSCrash)](https://cocoapods.org/pods/RollbarKSCrash)


## Setup Instructions

Expand Down
2 changes: 1 addition & 1 deletion RollbarAUL.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Pod::Spec.new do |s|

s.version = "2.0.0-beta.21"
s.version = "2.0.0-beta.22"
s.name = "RollbarAUL"
s.summary = "Application or client side SDK for interacting with the Rollbar API Server."
s.description = <<-DESC
Expand Down
2 changes: 1 addition & 1 deletion RollbarAUL/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RollbarAUL

This is an SDK module implements RollbarNotifier integration with Apple Unified Logging (AUL).
This is an SDK module implements RollbarNotifier integration with Apple Unified Logging (AUL) and allows capture of the AUL entries as corresponding Rollbar Telemetry log events.


Main abstractions:
Expand Down
2 changes: 1 addition & 1 deletion RollbarCommon.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Pod::Spec.new do |s|

s.version = "2.0.0-beta.21"
s.version = "2.0.0-beta.22"
s.name = "RollbarCommon"
s.summary = "Application or client side SDK for interacting with the Rollbar API Server."
s.description = <<-DESC
Expand Down
18 changes: 16 additions & 2 deletions RollbarCommon/Sources/RollbarCommon/NSJSONSerialization+Rollbar.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,44 @@ + (nullable NSData *)rollbar_dataWithJSONObject:(id)obj
safe:(BOOL)safe {

if (safe) {

if ([obj isKindOfClass:[NSArray class]]) {

NSMutableArray *newArr = [NSMutableArray array];
for (id item in obj) {

if ([item isKindOfClass:[NSDictionary class]]) {

[newArr addObject:[[self class] rollbar_safeDataFromJSONObject:item]];
} else {

[newArr addObject:item];
}
}
return [NSJSONSerialization dataWithJSONObject:newArr
options:opt
error:error];
} else if ([obj isKindOfClass:[NSDictionary class]]) {

return [NSJSONSerialization dataWithJSONObject:[[self class] rollbar_safeDataFromJSONObject:obj]
options:opt
error:error];
}
}

return [NSJSONSerialization dataWithJSONObject:obj
options:opt
error:error];
}

+ (NSMutableDictionary *)rollbar_safeDataFromJSONObject:(id)obj {
+ (nonnull NSMutableDictionary *)rollbar_safeDataFromJSONObject:(nullable id)obj {

NSMutableDictionary *safeData = [NSMutableDictionary new];
if (nil == obj) {

return safeData;
}

[obj enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {

if ([obj isKindOfClass:[NSDictionary class]]) {
Expand Down Expand Up @@ -73,7 +85,7 @@ + (NSMutableDictionary *)rollbar_safeDataFromJSONObject:(id)obj {
} else if ([obj isKindOfClass:[NSError class]] && (nil != [obj userInfo])) {

NSDictionary* userInfoData = [[self class] rollbar_safeDataFromJSONObject:[obj userInfo]];
if (userInfoData) {
if (nil != userInfoData) {

[safeData setObject:userInfoData forKey:key];
}
Expand All @@ -91,6 +103,7 @@ + (NSMutableDictionary *)rollbar_safeDataFromJSONObject:(id)obj {
options:(NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves)
error:&error];
if ((error == nil) && (nil != json)) {

NSDictionary *jsonData = [[self class] rollbar_safeDataFromJSONObject:json];
if (jsonData) {

Expand All @@ -106,6 +119,7 @@ + (NSMutableDictionary *)rollbar_safeDataFromJSONObject:(id)obj {
NSStringFromClass([obj class]));
}
}];

return safeData;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN

/// Turns JSON-like object structure into a valid NSJSONSerialization structure
/// @param obj JSON-like object
+ (NSMutableDictionary *)rollbar_safeDataFromJSONObject:(id)obj;
+ (nonnull NSMutableDictionary *)rollbar_safeDataFromJSONObject:(nullable id)obj;

/// Byte-length of a NSData representation of a JSON structure
/// @param jsonData NSData representation of a JSON structure
Expand Down
2 changes: 1 addition & 1 deletion RollbarDeploys.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Pod::Spec.new do |s|

s.version = "2.0.0-beta.21"
s.version = "2.0.0-beta.22"
s.name = "RollbarDeploys"
s.summary = "Application or client side SDK for interacting with the Rollbar API Server."
s.description = <<-DESC
Expand Down
2 changes: 1 addition & 1 deletion RollbarKSCrash.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Pod::Spec.new do |s|

s.version = "2.0.0-beta.21"
s.version = "2.0.0-beta.22"
s.name = "RollbarKSCrash"
s.summary = "Application or client side SDK for interacting with the Rollbar API Server."
s.description = <<-DESC
Expand Down
2 changes: 1 addition & 1 deletion RollbarNotifier.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Pod::Spec.new do |s|

s.version = "2.0.0-beta.21"
s.version = "2.0.0-beta.22"
s.name = "RollbarNotifier"
s.summary = "Application or client side SDK for interacting with the Rollbar API Server."
s.description = <<-DESC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#pragma mark - constants

static NSString * const NOTIFIER_VERSION = @"2.0.0-beta.21";
static NSString * const NOTIFIER_VERSION = @"2.0.0-beta.22";

static NSString * const NOTIFIER_NAME = @"rollbar-apple";

Expand Down
14 changes: 12 additions & 2 deletions RollbarNotifier/Sources/RollbarNotifier/DTOs/RollbarLevel.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@implementation RollbarLevelUtil

+ (NSString *) RollbarLevelToString:(RollbarLevel)value; {

switch (value) {
case RollbarLevel_Debug:
return @"debug";
Expand All @@ -19,21 +20,30 @@ + (NSString *) RollbarLevelToString:(RollbarLevel)value; {
}
}

+ (RollbarLevel) RollbarLevelFromString:(NSString *)value {
+ (RollbarLevel) RollbarLevelFromString:(nullable NSString *)value {

if (NSOrderedSame == [value caseInsensitiveCompare:@"debug"]) {
if (nil == value) {

return RollbarLevel_Info; // default case...
}
else if (NSOrderedSame == [value caseInsensitiveCompare:@"debug"]) {

return RollbarLevel_Debug;
}
else if (NSOrderedSame == [value caseInsensitiveCompare:@"warning"]) {

return RollbarLevel_Warning;
}
else if (NSOrderedSame == [value caseInsensitiveCompare:@"critical"]) {

return RollbarLevel_Critical;
}
else if (NSOrderedSame == [value caseInsensitiveCompare:@"error"]) {

return RollbarLevel_Error;
}
else {

return RollbarLevel_Info; // default case...
}
}
Expand Down
13 changes: 11 additions & 2 deletions RollbarNotifier/Sources/RollbarNotifier/DTOs/RollbarSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@implementation RollbarSourceUtil

+ (NSString *) RollbarSourceToString:(RollbarSource)value {

switch (value) {
case RollbarSource_Client:
return @"client";
Expand All @@ -21,14 +22,22 @@ + (NSString *) RollbarSourceToString:(RollbarSource)value {
}
}

+ (RollbarSource) RollbarSourceFromString:(NSString *)value {
if (NSOrderedSame == [value caseInsensitiveCompare:@"client"]) {
+ (RollbarSource) RollbarSourceFromString:(nullable NSString *)value {

if (nil == value) {

return RollbarSource_Server; // default case...
}
else if (NSOrderedSame == [value caseInsensitiveCompare:@"client"]) {

return RollbarSource_Client;
}
else if (NSOrderedSame == [value caseInsensitiveCompare:@"server"]) {

return RollbarSource_Server;
}
else {

return RollbarSource_Server; // default case...
}
}
Expand Down
Loading

0 comments on commit 7197317

Please sign in to comment.